Rust-GPU / Rust-GPU/rust-gpu

[Migrated] Large array variable initialization (`let arr = [0; 32 * 1024];`) compiles very slowly.

Open
#64 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Rust
Stars
3.4k
Forks
126
PR merge metrics
No merged PRs in 30d

Description

Issue automatically imported from old repo: https://github.com/EmbarkStudios/rust-gpu/issues/1132
Old labels: t: bug
Originally creatd by pyranota on 2024-02-11T13:28:58Z


EDIT(@eddyb): while there are reasons to avoid such arrays, the slowdown is the immediate Rust-GPU bug - I've left unchanged the original text, but used strikethrough for parts that don't apply, IMO.


User should not be able to create large sized arrays in rust-gpu shaders.
Stack is limited, and large sized data-structures should be moved in buffers.
Plus it makes compilation incredibly slow (I assume this syntax [0; SIZE] translates to spirv's [0, 0, 0, 0, 0, ... SIZE])

Expected Behaviour

spirv-builder should throw an error, when user creates large array in stack

Example & Steps To Reproduce
  1. Setup basic rust-gpu shader
  2. let arr = [0; 32 * 1024];
  3. cargo build

System Info

  • Rust: rustc 1.75.0 (82e1608df 2023-12-21)
  • OS: Pop!_OS
  • GPU: nvidia 1060
  • SPIR-V: SPIRV-Tools v2022.2-dev unknown hash, 2022-02-16T16:37:15

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

The issue names no source file or test; begin with the minimal rust-gpu shader reproducer using let arr = [0; 32 * 1024];, then run cargo build and trace the compilation path responsible for the slowdown. Done means this large array initializer no longer makes compilation incredibly slow, with a regression test if the relevant test location can be identified.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.