linebender / linebender/vello

Asynchronous Pipline Creation using CPU shaders

Open
#485 1 comment 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

O-Windows
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

  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

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.