Repository navigation
Conversation
…xecutable A rebuild for another reason (a change in the gpu, hle or loader crates, a diag build next to a release one) emptied the whole shader cache, and the first run of every new executable translated each shader again on the title's own processors while the pipeline library's thousands of early starts asked for them (a 253 ms frame at 20-30 s). The key is now victory-shader's source hash (build.rs, from upstream PR Marvisak/VIctory#254 by wbkepler) and a schema version of this file's encoding, with the settings that change a translation as before. VICTORY_SHADER_CACHE_KEY=exe keys by the executable again. Adds is_cached, a lookup of an entry without reading or translating. Co-authored-by: wbkepler <211408787+wbkepler@users.noreply.github.com> Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
…aders already translated The pipeline library lists thousands of pipelines to start early. Each needs its shader's translation and the driver's compile; on every worker at once they took the processors from the title's own threads while it loaded. Early work is limited to ceil(workers/4) workers (VICTORY_EARLY_WORKERS, 0 for no limit) and an early pipeline whose shaders are neither translated nor in the shader cache is left for its first use. Requested pipelines go first and are not limited. Co-authored-by: OpenBot <335604065+openbotgit[bot]@users.noreply.github.com>
3 tasks
5 tasks
This was referenced Nov 24, 2026
Open
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's wrong
Two things make the first seconds after the game opens stutter whenever the pipeline library is large (it is after any run that reached the world) and the shader cache does not hold the current build's translations:
victory-gpu,victory-hleor the loader, adiagbuild beside areleaseone) starts with an empty cache. Every new executable translates its shaders again.What the fix does
victory-shader/build.rsandSOURCE_HASH: the BLAKE3 ofvictory-shader's sources (taken from Pipeline & CLI: stable shader cache key, in-flight dedup, and AOT warm-up Marvisak/VIctory#254 by wbkepler, with credit in the commit).shader_cache::build()keys entries by that hash and aCACHE_SCHEMA_VERSIONof this file's encoding, instead of the executable. It keeps the settings that change a translation (loop limit,group_sync, theVICTORY_WAVE_*andVICTORY_F16_NEARESTswitches,shader_opt), now in a smallkey()that is easy to extend.VICTORY_SHADER_CACHE_KEY=exekeys by the executable again.shader_cache::is_cached: whether an entry exists, without reading or translating.pipeline/make.rs: early work is limited toceil(workers / 4)workers (VICTORY_EARLY_WORKERS=N;0for no limit), and an early pipeline is made only if all its shaders are already translated or in the shader cache; the others stay for their first use. Requested pipelines (a draw wants them) go first and are not limited. A finished early pipeline wakes the others under the queue's lock (no lost wake-up).How it behaves after
A rebuild that does not touch
victory-shader(orshader_cache.rs's schema) keeps its cache. With an empty cache and a large library, the early starts no longer put the translator on every worker.Measured on an RTX 4070 (Ryzen 7 5800X3D, 32 GB), 40 s each, same bad condition for both: a 295 MiB pipeline library copied from an earlier run and an empty shader cache,
VICTORY_RELAY=2,VICTORY_PIPELINE_WAIT_MS=24, snapshot after the prologue, no capture:Builds: "before" is
4e17478+ #63 + the watchdog hooks and worker stacks of #28; "after" is that plus #71 and this PR (#71 changes the relay's copy-back queue, which the start-up screens do not use; the two builds were not otherwise identical). One run each.The sustained stutter is gone. Isolated holes of 1.1-1.6 s remain, with and without this change: one at 9-11 s (the title's boot-to-first-screen transition, with the GPU idle and nothing of ours in the log) and one more elsewhere between 25 and 36 s. They are not caused by the cache or the early starts; this PR does not claim to fix them.
Tests (
cargo test -p victory-gpu -- pipeline::make shader_cache, 12 pass; clippy clean forvictory-gpu,victory-shader,victory-pipeline): the key follows the translator, the loop limit and a wave switch and nothing else;SOURCE_HASHequals the digest ofvictory-shader/srcas it is now; an entry is found only for the key that stored it; the early limit (8 workers: 2, 4: 1, 5: 2, 1: 1; the setting wins, 0 is no limit); an early pipeline waits for a free early worker and a requested one does not; an early pipeline with no translation ready is skipped and still queues on its first use.Overlap and order
Looked for in the upstream open PRs and the fork's: Marvisak/VIctory#254 (the same stable key plus in-flight deduplication and an AOT
translate --write-cache: this PR takes only the key) and #1730 (translate --cache DIR, an AOT too). Neither is included: pre-translating the pack offline is the next step and complements this one (with a key that does not follow the executable, one offline run serves every build with the same translator). Fork PRs touching the same lines:cached()/host_shader; the entry is built incache_input()here, so the merge is one function. An offline pre-translation must run with the same wave width as the host.build()(portable heap, view heap limit): they become one more argument ofkey().build.rstovictory-shader(Agility SDK test exports): the two scripts have to be merged.Not covered: the translations are still made at first use when the cache has none; an offline pre-translation (the AOT) and the deduplication of concurrent translations of one shader are left for a follow-up.
AI-assisted.