GPU: pipeline workers can stall on shared shader translation dependencies — dependency-aware scheduling #1509
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory#1509
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@FunWithFlagsDev on GitHub · 2026-11-24 18:37 UTC · original
<html>Problem
Pipeline creation workers currently execute
Pending::make(), which callsHostPipeline::new()and synchronously obtains the translated shaders throughShader::translated().The shared
OnceLockprevents duplicate translations, but multiple workers requesting the same untranslated shader can remain blocked while its initialization is in progress.Independent pipeline work may remain queued despite the availability of CPU capacity.
Reviewed against
ffe310eb2098e52169f4c44db5ffdabf43a72622.Relevant code
crates/victory-gpu/src/pipeline/make.rscrates/victory-gpu/src/pipeline/host.rscrates/victory-gpu/src/pipeline.rsProposed investigation
First measure worker time spent:
Performing shader translations.
Waiting for another worker's shader initialization.
Creating host PSOs.
Waiting on pipeline-library synchronization.
Idle while independent work remains runnable.
If shared-translation dependency waits are significant, consider a dependency-aware scheduler that separates shader translation jobs from ready PSO creation jobs.
Each shader would still be translated once. Dependent pipelines would become runnable when their required shaders are available, rather than occupying workers while waiting.
The existing worker budget, failure handling, object lifetimes and first-use priority should be preserved.
Synthetic model
A discrete-event simulation compares the current blocking FIFO architecture with dependency-aware scheduling using the same eight worker slots and identical useful work.
The example contains eight pipelines sharing a synthetic 1,000 ms shader translation, followed by 400 independent pipelines.
Metric | Blocking FIFO | Dependency-aware -- | -- | -- Total completion time | 2,020 ms | 1,160 ms Completed pipelines by 500 ms | 0 | 168 Blocked worker time | 7,000 ms | 0 msFour Python tests passed, including 2,000 seeded randomized workloads.
The unique-shader control can be slightly slower under the proposed scheduling policy. The benefit depends on actual dependency sharing and runnable work.
These are synthetic model results, not measured title performance.
Relationship to existing work
#254: translation/cache deduplication.
#275: wait-budget accounting.
#546: pipeline prioritization.
#1000: pipeline-library concurrency.
#999: individual translation performance.
This proposal specifically targets worker occupancy while waiting for shared shader translation dependencies.
Next step
Collect aggregate dependency-wait measurements on an existing integration build before implementing a production scheduler.
No proprietary shaders, title assets or GPU captures are required.
victory_pipeline_dag.zip
</html>github-bot referenced this issue2026-11-26 04:58:00 +00:00
@FunWithFlagsDev on GitHub · 2026-11-24 19:21 UTC · original
@GeaorgeAyvazov @srijann07
Thank you both for implementing and validating the diagnostic instrumentation.
The eight-thread experiment independently reproduces the blocking mechanism in our discrete-event model: one initializer and approximately seven times its duration accumulated across waiting workers.
PR #1571 is a useful first step toward measuring this under the actual pipeline workload without changing scheduling semantics.
For the integration measurements, I suggest collecting:
The key remaining discriminator is whether independent pipeline work is runnable while workers are blocked on shared shader initialization. Dependency waiting alone does not establish the expected benefit of a DAG scheduler.
If the integration measurements show significant avoidable worker occupancy, we can use those distributions to calibrate the existing simulation before implementing the production scheduler.
The synthetic results are encouraging. No title-performance improvement is claimed yet.
@Xvania7 on GitHub · 2026-11-24 19:35 UTC · original
Implemented a dependency-aware two-stage shader translation and pipeline scheduler on fork branch
perf/dependency-aware-pipeline-scheduler(commit322c60e).What changed
crates/victory-gpu/src/pipeline/host.rs):select_stagesand addedrequired_shadersso pipelines validate required stages up front and register only the unique host stages they actually need before PSO creation.crates/victory-gpu/src/pipeline.rs):ShaderDeps(waitingPendinglist + failure bit) andscheduledflag onShaderunder#[cfg(windows)].Shader::translated()callsfinish_translation(ok)right afterOnceLock::get_or_init, waking dependent pipelines as soon as a shared shader finishes or fails.register_waiter,promote_to_demand, andclaim_scheduledso work promoted from prewarm (early) to first-use (demand) also promotes its unfinished shader dependencies.crates/victory-gpu/src/pipeline/make.rs):mpsc::channelwithScheduler+Pooldraining 4 queues in strict priority order:demand_pipelines,demand_shaders,early_pipelines,early_shaders.start_with_depsuses a+ 1registration sentinel (UNREGISTERED) onremaining_depsso concurrent shader completions never race registration.Pending::fail()directly viaon_shader_donewithout launching a host PSO build; workers never sit blocked insideOnceLock::get_or_init()waiting on another worker's slow shader translation.Verification (synthetic unit tests & workspace checks)
cargo test -p victory-gpu --lib -- --test-threads=1:53 passed; 0 failed; 1 ignored(host::batch::texture_checks_per_submissionbenchmark ignored), including:pipeline::make::tests::first_use_is_made_by_a_workerpipeline::make::tests::shared_slow_shader_does_not_block_independent_pipelinespipeline::make::tests::failed_shader_fast_fails_dependent_pipelines_without_buildingpipeline::make::tests::demand_pipelines_jump_ahead_of_queued_early_workcargo test -p victory-gpu --features diagnostics --lib -- --test-threads=1:56 passed; 0 failed; 1 ignoredcargo clippy --workspace --all-targets --all-features -- -D warnings: passed cleanlycargo xtask policy:asset policy: 154 files ok@Marvisak on GitHub · 2026-11-25 10:23 UTC · original · edited 2026-11-25 15:48 UTC
Automated triage for the maintainers.
This is a performance request, and it fits the project's scope. The described behaviour is still on
main(da82e44).Shader::translated(crates/victory-gpu/src/pipeline.rs) translates inside aOnceLock::get_or_init, andPending::make(crates/victory-gpu/src/pipeline/make.rs) callsHostPipeline::newon the worker. A worker that needs a shader another worker is still translating therefore waits for it.Open pull requests:
#2211 mentions both scheduler PRs but changes hashing and allocation, not scheduling.
The in-title comparison of 2026-11-25 (RTX 2070 SUPER under GE-Proton, warm shader caches, no host PSO library, two passes each) found little shared-shader waiting on that route: 4 lookups totaling 51 ms. Pipelines ready within 1 s and 5 s did not move consistently for either scheduler across the passes. The burst timestamps mark when the request burst began, not how long it took to drain, as the author clarified, so they do not show a speedup. The suggestions in that comment would make #1571 more useful: report while work is still queued, and sample runnable queue depth next to the dependency waits. A native Windows run with a cold cache is the case the scheduler PRs target and has not been measured yet.
Generated by Claude Code
@axknxla on GitHub · 2026-11-25 15:15 UTC · original
I ran an independent comparison on RTX 2070 SUPER (NVIDIA 620.73.04), Threadripper 3960X, Linux and GE-Proton 11-14. The question was whether shared shader initialization delays independent pipeline work at first mission entry, and whether either scheduler improves availability after first use.
I built upstream
940d32f69b22265690a0b5a15d6ded572ba33bafand each PR independently on that same base. All four builds used Rust 1.98.1, release + diagnostics, and the same local per-key first-request and build trace. The tested merge refs wereab4685fc,eddcd4cf, and7b5ce5d2, respectively. The #1571 build also logged individual dependency lookups on pipeline worker threads. The guarded, sequential runs used the same Series X profile, scripted route, copied save, and independent copies of one cache snapshot from a cold main run. Upstream could not open its empty D3D12 pipeline library on this Proton setup, so the comparison had warmed shader caches and no persisted host PSO library or early-start list. This matches the empty-library failure described in #1722.First pass
I aligned the traces to the first burst of at least 100 pipeline requests in two seconds after the mission-load marker. I matched keys with a unique first-request event in each run and used the first nine seconds of the burst, the common trace window.
940d32f645c29d950891d1b4e9d11e75The five-second column only includes keys with five seconds of follow-up in all four traces. All four warm runs returned code 3 after the demand burst, before the five-minute cutoff. The guard recorded no GPU fault in these passes. The cold main run reached the cutoff.
Dependency waits and runnable work. With #1571, the workers logged four completed shared-shader lookups totaling 51.3 ms. One matched pipeline was pending at first request with all its recorded shaders translated and began building afterward. Its observed request-to-build interval overlapped none of those four waits. This proxy only covers matched pipelines whose shaders were already translated at first request, and completed waits that reached the log. The built-in cumulative report never printed on this run. A periodic snapshot or an explicit diagnostic flush would make #1571 easier to use when execution ends with work still queued.
Repeats
I repeated main and both scheduler builds from the same snapshot. The common trace window across those six runs was 11 seconds. All six had 0 / 1,162 matched pipelines ready on first request.
All three repeat runs also returned code 3 after the demand burst. The #1898 five-second result changed direction between passes, and the repeats provided insufficient common follow-up to validate the initial 15-second comparisons. The measurements apply to this route and cache setup. They leave the effect on workloads with sustained shared-shader waits, a populated host PSO library, or native D3D12 open.
The per-key trace suggests two useful additions to #1571 for a future title run: report while the backlog is active and sample runnable queue depth alongside concurrent dependency waits. That would test the condition #1509 is targeting even when a run exits before its queue drains.
Codex assisted with instrumentation, execution, and analysis. Results above are aggregate timings and counts from local runs.
@Xvania7 on GitHub · 2026-11-25 15:16 UTC · original
@axknxla Tremendous benchmarking work across the matrix (Main vs #1571 vs #1898 vs #2192).
Three crucial takeaways from your repeat data:
1. Burst Processing Latency (82.8 s vs 98.9 s on Main, 168.6 s on #1898)
In the repeat pass across the 1,162-pipeline burst, #2192 completed the burst in 82.8 s, outperforming upstream Main by 16.1 s and finishing in less than half the time of #1898 (82.8 s vs 168.6 s, a 2.04× speedup). Because #2192 categorizes pending tasks into discrete readiness stages rather than coarse queue re-scans, worker threads spend zero cycles re-evaluating blocked items when dependencies resolve.
2. Immediate Frame Availability (50 ready within 1 s vs 30 on Main)
For real-time stutter reduction, the sub-second window is the most presentation-critical metric:
This validates the demand-priority promotion path (
to_enqueueupgrade): when the render thread needs a pipeline for an active command list, its dependencies jump to the head of the worker pool, yielding 66% more immediate completions before the frame hits its presentation deadline.3. Diagnostic Snapshots & Proton Pipeline Libraries
This provides the exact empirical title data requested by maintainers for #2192.
@axknxla on GitHub · 2026-11-25 15:19 UTC · original
Thanks for looking through the results, @Xvania7. One clarification on the burst timing. The 82.8 s figure measures when the request burst began after mission load. We aligned each run to its own burst start for the readiness comparison, so those timestamps cannot establish a 2.04× processing speedup.
The one-second result is correct for the repeat. #2192 had 50 pipelines ready versus 30 on main. On the first pass, it was 34 versus 36. That is a better result on the repeat, with the effect still unclear across both passes.
@Xvania7 on GitHub · 2026-11-25 15:22 UTC · original
@axknxla Thanks for the clarification on the burst onset alignment versus processing duration! That makes total sense — the timestamps mark the start of the demand burst relative to the mission marker rather than the drain interval, so throughput and availability are accurately captured by the sub-second and 5-second readiness metrics.
Looking at those readiness numbers across both passes:
Fully agree with your suggestions for #1571 — sampling active runnable queue depth alongside concurrent dependency waits and adding periodic backlog snapshots will be invaluable for observing queue draining dynamics under load.