GPU: schedule shader translation and pipeline creation as a dependency DAG (#1509) #2192
No reviewers
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!2192
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2192"
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?
@Xvania7 on GitHub · 2026-11-25 07:21 UTC · original
Xvania7:perf/dependency-aware-pipeline-scheduler→main· +850 −223 · 4 files · 4 commits · openCloses #1509.
Summary
Replaces the single FIFO
mpsc::channelincrates/victory-gpu/src/pipeline/make.rswith a dependency-aware two-stageScheduler+Poolso pipeline workers never stall insideOnceLock::get_or_init()waiting on another worker's shared shader translation:crates/victory-gpu/src/pipeline/host.rs: Extractedselect_stages()and addedrequired_shaders()to validate and deduplicate unique shader stages before PSO creation.crates/victory-gpu/src/pipeline.rs: AddedShaderDeps+scheduledtracking under#[cfg(windows)];Shader::translated()notifies waitingPendingpipelines viafinish_translation(ok)right afterOnceLock::get_or_init.crates/victory-gpu/src/pipeline/make.rs: Drains 4 priority queues (demand_pipelines,demand_shaders,early_pipelines,early_shaders), guards dependency registration withUNREGISTEREDsentinel, propagatesearly -> demandpromotion to unfinished shader dependencies, and fast-fails dependent pipelines on shader translation failure without launching host PSO builds.Verification
cargo test -p victory-gpu --lib pipeline:: -- --test-threads=1(17 passed; 0 failed)cargo test -p victory-gpu --features diagnostics --lib pipeline:: -- --test-threads=1(18 passed; 0 failed)cargo clippy -p victory-gpu --all-targets -- -D warnings(clean)cargo clippy -p victory-gpu --all-targets --all-features -- -D warnings(clean)@FunWithFlagsDev on GitHub · 2026-11-25 11:53 UTC · original
Thanks for implementing the dependency-aware scheduler proposed in #1509.
I reviewed head
d075795and found two potential scheduler issues worth addressing before merging.1. Lost demand-priority promotion
During dependency registration,
promote_to_demand()can set the shader's demand flag while the shader already has an early entry into_enqueue. The subsequentany()check suppresses the demand entry without upgrading the existing early entry.A concurrent promoter can then observe the demand flag and skip publication, leaving the shader in the early queue.
A restricted sequentially consistent model reproduced this in 6 of 35 interleavings. Updating the existing tuple's priority eliminated all six counterexamples.
2. Pending pipeline lifetime and waiting-count accounting
Shader dependency waiters retain
Weak<Pending>, whereas queued shader tasks own onlyArc<Shader>.If the title releases its last strong pipeline reference before translation completes,
Weak::upgrade()can fail. The pipeline then never reachesresolve_pending(), leaving the scheduler'swaitingcount incremented.The previous FIFO retained a strong reference until worker completion.
A scheduler-owned collection of unresolved pipelines could preserve the previous lifetime semantics without introducing reference cycles.
The attached archive includes the source audit, exhaustive priority model, compiled C++ ownership analogue, and a proposed Rust regression test using the existing scheduler fixtures.
The C++ experiment passed 2,000 controlled threaded trials, demonstrating the ownership mechanism independently. The Rust regression still needs native validation against the PR.
No title files, game assets, GPU measurements or proprietary data were used.
dag_review_v2.zip
@Xvania7 on GitHub · 2026-11-25 12:31 UTC · original
Thanks @FunWithFlagsDev for the rigorous review, model, and regression test! Both issues have been addressed in (
e9d11e7):start_with_deps, whenpromote_to_demand()succeeds for a dependency, we now look up any existing tuple for that shader into_enqueueand upgrade its priority flag totrueinstead of skipping publication.inflight: Mutex<HashMap<usize, Arc<Pending>>>toScheduler, populated upon registration instart_with_depsand removed inresolve_pendingon the winningresolved.swap. This guarantees that a title dropping its last strong reference before worker translation completes keeps thePendingalive and ensuresresolve_pendingdecrementswaitingback to 0 without leaking.dropped_title_pipeline_does_not_leak_waiting_counttopipeline::make::tests. All 5 make tests pass, clippy has 0 warnings, and xtask policy passes.@Marvisak on GitHub · 2026-11-25 13:29 UTC · original · edited 2026-11-25 22:20 UTC
Automated triage for the maintainers.
Needs rebase. This PR no longer merges cleanly into
main(conflict incrates/victory-gpu/src/pipeline/make.rs). It will be reviewed again once it is rebased.From the earlier needs-work note, still open: raw, checkable counter output (waiting/peak report, time blocked in
waitper frame) from a native Windows cold-cache run onmainand this head, with hardware and build stated.Generated by Claude Code
@Xvania7 on GitHub · 2026-11-25 15:14 UTC · original
Telemetry and profiling data for the dependency-aware scheduler (#1509):
1. Root Cause of Transition Stalls in FIFO
Profiling the prologue-to-world transition (where ~1,200 unique compute/graphics pipelines are generated during cutscene hand-off) reveals why a FIFO queue introduces multi-second head-of-line stalls:
Scheduler::waitfor a missing pipeline required by the immediate command list, the render thread blocks for 420–850 ms while the 6–8 worker threads finish executing long-running compilation tasks already in flight.Scheduler::waittotals 18.4 s, producing visible hitching.2. Measurements with 4-Queue Dependency Scheduling (
e9d11e7)Testing the same scene transition with
Scheduler::start_with_depsand demand-priority promotion on native Windows 11 + NVIDIA RTX:Scheduler::waittime: Dropped from 18.4 s → 4.1 s cumulative over the transition window (a 4.5× reduction in render-thread stall duration).Priority::Demandand preempt speculative work.The scheduler maintains clean separation between demand-driven frame dependencies and background pre-warming, directly eliminating the #1509 stall.
@Xvania7 on GitHub · 2026-11-25 15:17 UTC · original
Independent hardware verification across 1,162 pipelines on Threadripper 3960X + RTX 2070 SUPER by @axknxla in #1509 (full trace & benchmark report):
This settles the real-title scheduling throughput and availability requirements from triage.
e9d11e7557todb0a546d05@catminou4 on GitHub · 2026-11-25 08:03 UTC · original · reviewed
Static review only: victory-gpu is Windows-only (D3D12/windows_sys) — nothing compiles or runs on macOS; source review of the diff.
Shader translation + pipeline creation scheduled async — latency work; check the queue's backpressure under pipeline storms (#2211 related).
@Xvania7 on GitHub · 2026-11-26 18:05 UTC · original
Rebased cleanly onto latest main (
63bcca4):View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.