Asynchronous Pipline Creation using CPU shaders
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 4.3k
- Forks
- 300
- Avg merge
- 2d 13h
- Merged PRs (30d)
- 61
Description
This is part of my investigation into startup time on Android ([#gpu > Android Startup Time Investigation](https://xi.zulipchat.com/#narrow/stream/197075-gpu/topic/Android.20Startup.20Time.20Investigation)).
We should create the compute pipelines asynchronously, by using the CPU shaders whilst the GPU pipelines are being created (except perhaps for `fine`).
This is especially important for first-run performance, when pipeline caches built in to drivers won't have been filled yet. On my Google Pixel 6, creating pipelines with a cold cache takes approximately 1.7 seconds. This does not give a good user experience for the first run of the app[^caching].
This has been somewhat mitigated by #455, as prior to that this took more than 4 seconds.
This 1.7 seconds currently blocks app startup, but using the CPU shaders instead means renderer creation takes 140ms instead.
Note that this does have an impact on frame latency - my measurements suggest that each frame of Tiger takes 30ms when using the CPU shaders vs <10ms with the GPU shaders. So overall, this approach should be expected to save ~ $1700-140-20=1540$ milliseconds, i.e. about 1.5 seconds on time to first frame on first run. This is the vast majority of the current time to first frame.
This is also applicable to desktop use cases[^no_cache_command], but is not the motivating example, because the startup time is shorter, even with a cold cache.
[^caching]: Note that on current `main` there is no pipeline caching on Android. This is blocked on gfx-rs/wgpu#5319
[^no_cache_command]: `MESA_SHADER_CACHE_DISABLE=1 cargo run -p with_winit --release` can be used with Mesa to test the time without caches - it takes ~200ms with 14 threads, versus ~5ms with the cache on my machine.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing renderer creation and GPU pipeline creation in the Android startup path, using the linked Android Startup Time Investigation for context. Use the Mesa cache-disabled command described in the issue to measure cold-start behavior; done means CPU shaders can cover startup while GPU pipelines are created asynchronously, with GPU shaders used afterward and the `fine` case considered separately.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- android, rust
- Domain
- computer-graphics, mobile-dev, performance
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100