d3d12: per-pipeline waiter wakeups and live-waiter priority donation (D3D12-PIPELINE-WAIT-AND-SLOW-EARLY) #3132
Open
github-bot
wants to merge 4 commits from
github-bot/gh-3132 into main
AGit
pull from: github-bot/gh-3132
merge into: github:main
github:main
github:perf/darner-title-priority-ceiling
github:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
github:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
github:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
github:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
github:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
github:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
github:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
github:fix/runtime-test-conservative-fixtures
github:ci/shard-semantic-linux
github:docs/fg-limit-fps-switch
github:fix/runtime-test-fixture-paths
github:fix/runtime-test-fixture-readers
github:fix/read-file-hard-link
github:fix/book-slot-heap-never-read
github:fix/depth-resolve-spv-path
github:fix/indirect-unused-batched
github:gh-pr/3358/base
github:fix/xmem-refusal-diagnostics
github:gh-pr/3357/base
github:ci/shorten-ci-time
github:fix/alias-later-queued-submissions
github:claude/gallant-sagan-aamatr
github:gh-pr/3342/base
github:gh-pr/3341/base
github:d3d12/agility-sdk-621
github:gh-pr/3293/base
github:gh-pr/3319/base
github:gh-pr/3318/base
github:gh-pr/3315/base
github:gh-pr/3313/base
github:gh-pr/3314/base
github:claude/fervent-curie-m19lnr
github:gh-pr/3216/base
github:gh-pr/3272/base
github:gh-pr/3276/base
github:gh-pr/3279/base
github:gh-pr/3257/base
github:gh-pr/3258/base
github:gh-pr/3271/base
github:codex/skip-no-hit-ray-passes
github:gh-pr/3230/base
github:gh-pr/3266/base
github:gh-pr/3247/base
github:gh-pr/3246/base
github:gh-pr/3244/base
github:claude/sharp-sagan-1jqnp3
github:t3/preserve-fsr-sdk-restart-path
github:t3/propagate-host-failure-hresult
github:t3/launcher-custom-parameters
github:t3/series-x-2160-startup
github:codex/d3d12-uncapped-simulation
github:ci/less-to-run
github:perf/native-compute-shader-forms
github:claude/blissful-franklin-ukp7ag
github:codex/full-precompile-default
github:gh-pr/3166/base
github:gh-pr/3148/base
github:gh-pr/3138/base
github:gh-pr/3106/base
github:gh-pr/3057/base
github:gh-pr/2756/base
github:gh-pr/2812/base
github:gh-pr/3032/base
github:gh-pr/2992/base
github:notes/card-time-and-plant-flicker
github:gh-pr/2986/base
github:gh-pr/3000/base
github:gh-pr/2966/base
github:gh-pr/2924/base
github:gh-pr/726/base
github:gh-pr/2761/base
github:gh-pr/2663/base
github:gh-pr/2861/base
github:gh-pr/2862/base
github:gh-pr/2820/base
github:gh-pr/2811/base
github:gh-pr/2803/base
github:rt-call-trace
github:gh-pr/2802/base
github:gh-pr/2766/base
github:perf/ahead-split
github:gh-pr/2589/base
github:gh-pr/2699/base
github:gh-pr/2696/base
github:docs/readme-runtime-proposal
github:gh-pr/1346/base
github:codex/coord-claim-check-20261124-7e48
No reviewers
Labels
Clear labels
accessibility
Barrier affecting people with disabilities
area: ci
.github/ workflows and settings
area: d3d12
The D3D12 runtime in d3d12/ (Rust: leonida.exe and its crates)
area: docs
Documentation
area: launcher
The launcher (launcher/)
area: runtime (legacy)
The earlier Vulkan runtime in runtime/
area: shader translator
The shader translator (leonida-shader, tools/rdna2spirv) and its tests
area: tools
tools/ and scripts/
area: viewer
The map viewer (viewer/)
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
duplicate
This issue or pull request already exists
enhancement
New feature or request
good first issue
Good for newcomers
help wanted
Extra attention is needed
invalid
This doesn't seem right
missing claim
Needs a claim in #14
needs in-game run
Changes the code a frame runs through: needs the 300 s in-game gate (docs/game_gate.md)
needs rebase
Conflicts with the base branch: rebase it on main
needs-triage
Needs maintainer evaluation before the next triage state
question
Further information is requested
ready-for-agent
Fully specified and ready for an AFK agent
submodules
Pull requests that update submodules code
wontfix
This will not be worked on
No labels
accessibility
area: ci
area: d3d12
area: docs
area: launcher
area: runtime (legacy)
area: shader translator
area: tools
area: viewer
bug
dependencies
documentation
duplicate
enhancement
good first issue
help wanted
invalid
missing claim
needs in-game run
needs rebase
needs-triage
question
ready-for-agent
submodules
wontfix
Milestone
Clear milestone
No items
No milestone
Assignees
Clear assignees
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Dependencies
No dependencies set
Reference
github/ubiquitarianism--leonida!3132
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3132"
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?
@zmasi on GitHub · 2026-12-02 13:05 UTC · original
zmasi:perf/d3d12-pipeline-wait-and-slow-early→main· +415 −57 · 5 files · 4 commits · openClaimed in the coordination issue as:
D3D12-PIPELINE-WAIT-AND-SLOW-EARLY(#2570)Addresses #3103 (does not close it: the reporter's RTX 5080 gameplay session was not run, and first-seen or unbooked variant/masked PSOs can still compile during play).
What and why
Addresses two scheduler bottlenecks in
d3d12/crates/leonida-gpu/src/pipeline/make.rswhile preserving upstream queue ordering, frame wait budgets (#3000, #3032), and library admission rules:Pendingwaiter notification (pipeline/make/completion.rs, adapted from Foxhoundeffe3e3, GPL-3.0):static DONE: (Mutex<()>, Condvar)was global across all pipelines: every background worker completion callednotify_all(), waking everyleonida-list-*thread waiting on any slow pipeline.Pendingnow carries its own completion gate. Only the winning initializer signals thatPendingafter publishing either a builtHostPipelineor a refusal (includingLEONIDA_PIPELINE_PANIC_CATCHcaught panics).THREAD_PRIORITY_LOWEST->THREAD_PRIORITY_NORMAL):THREAD_PRIORITY_LOWEST(-2) by default (LEONIDA_PIPELINE_LOWEST), leaving multi-second driver PSO compiles preemptable by normal-priority threads even while list-recording threads block waiting for them.REQUESTEDjob (which would hold all workers at normal priority across ~1,700 cold-start requests), a worker now runs atTHREAD_PRIORITY_NORMALonly while one or more callers actually block waiting on that pipeline (until_made/ synchronousnow).EARLYworker has already entered the driver, the first waiter donates priority to that in-flight worker via a non-inheritableOpenThread(THREAD_SET_LIMITED_INFORMATION)handle opened and closed under the per-pipeline completion lock before worker exit or job reuse; when the last waiter departs (or on completion / unwind), the worker restores its configured background base (-2or-1).warm --usedsafety:slowconcurrency cap frommax(1, configured_general_workers / 4)(honoringLEONIDA_PIPELINE_WORKERSoverrides and low-RAM defaults instead of recomputing from logical CPUs alone), while keeping ordinary-before-slowEARLYpop order andREQUESTEDpromotion bypass unchanged.wanted_earlyandwarm --useddraw-only admission unchanged: unrestrictedleonida warm/-PrecompileAllalso appends>= 1 stimings toslow-pipelines.txtfor never-drawn recipes, and admittingslow-pipelines.txtintowanted_earlywould let runtime library misses callStorePipelineon never-drawn PSOs (bypassingwarm.rs::into_library's device-removal guard).Tested
a252854a2): 4 targeted regression failures on base -> green on HEAD (global completion gate contention blocking refusal waiters, missing before-claim and mid-build Win32 priority donation leaving workers at-2, and CPU-only slow cap ignoring configured pool overrides), while fast-before-slowEARLYordering and expired-request controls pass on both sides.wait_timeoutwakes:1,910 -> 0(burst) and13,966 -> 0(producer rendezvous).71.4 / 142.6 us -> 17.2 / 23.1 us(803k -> 3.60Mpublications/s; rendezvous337.0 / 866.2 us -> 54.8 / 112.8 us,123k -> 1.08Mpublications/s).-2whenREQUESTEDwithout waiters,0(THREAD_PRIORITY_NORMAL) with 1 -> 2 -> 1 active waiters, and-2immediately when the last waiter leaves before compilation finishes.rustc 1.98.1,x86_64-pc-windows-msvc):cargo test --locked --target x86_64-pc-windows-msvc -p leonida-gpu --lib pipeline::—65 passed, 0 failed, 8 ignored(4/4diagnostics completion tests also pass;1/2/8configured worker quotas verified in isolated subprocesses).1,717 passed, 75 ignoredacross runtime/shader/tool crates (sole workspace failure is pre-existingxtask::policy::tests::repository_passes_policyon untouchedhost.rs,emit/lower.rs, andamplify_dxil.rs).cargo clippy --workspace --all-targets --no-deps --locked --target x86_64-pc-windows-msvc— exit0(0warnings in touched files).python -I tools/d3d12_switches.py --check d3d12/docs/switches.md,python -I tests/test_text_write_line_endings.py, andpython -I scripts/check_no_game_data.py— all exit0.GPUs tested: NVIDIA GeForce RTX 3090 24 GB, driver 610.88, Windows 11 Pro
10.0.26200(synthetic workspace GPU + WARP tests and CPU synchronization/Win32 priority benchmarks; no retail title run).AI-assisted: yes — authored with GPT-6.2 Astra (
xhigh) with live turn-by-turn design advisories from Claude Fable 5.2 (max, which identified the never-drawnStorePipelinehazard and scoped priority donation strictly to active waiters), codebase scouting by GPT-6.2 Sol (high), and independent read-only review + re-review by Claude Opus 5.5 (max).Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.@Kal0s-design on GitHub · 2026-12-02 15:04 UTC · original
Ran natively on Windows 11, head
8eedef9b4merged into currentmain(69cd4106c, clean merge),--features diagnostics, debug test profile.Suites on the merge
leonida-gpu --lib pipeline::completion_testsandslow_slots_follow_the_configured_general_pool)leonida-gpu --libfullclippy -p leonida-gpu --features diagnostics --testspipeline/make.rs,make/completion.rs,library.rs(11 elsewhere, untouched files)tools/d3d12_switches.py --check,check_no_game_data.pyExtra throwaway tests against
Completion(not pushed), 3 runs each, all passedNORMALinside the build, all 64 returned with the result, worker back atLOWEST, waiter count 0 and no worker record leftLOWESTbefore the build endsdemand()and dropLOWEST, everyCompletionidleNORMALin A,LOWESTin B and afterdemand()guardNORMALduring,LOWESTafter the unwind, waiter count 0LOWESTafter (worker 2's priority after its build was not sampled)I also checked whether a caller blocked in
masked_for(which callsp.make()withoutdemand()) can leave a worker atLOWEST. A forced synthetic case does (-2), but the masked twin is only ever passed tomasked_for, never toready/early, so it and its own format variants are built inline on the caller and no worker holds them. The path is not reachable today.Wake latency vs
main(same test file on both sides,until_made+make_with, 8 waiters on their own pipelines, 300 trials x 8 = 2400 samples per run, 3 runs, publish to return in us, debug build so absolute numbers are higher than a release build)mainp50 / p950 lost waits on either side. In the first row
mainreturns faster, most likely because its waiters are already awake from the 64 unrelatednotify_allcalls when their own pipeline lands; on the PR they stay parked and pay a normal wake. With both sides parked (second row) the PR has a higher median and about half the p95. So in this harness the PR shows a tighter p95 when both sides are parked, not a lower median. I did not count unrelated wakeups onmain. I did not reproduce the PR's release-build numbers.Not checked: an in-game run, a release-build benchmark, behaviour with real driver compiles, and Win32 priority effects under actual CPU contention (the tests read the priority value, they do not measure scheduling).
GPUs tested: n/a (CPU-only tests).
AI-assisted: yes (Claude Code).
@merzleckeier on GitHub · 2026-12-02 15:18 UTC · original · reviewed
A live waiter cannot boost an already-running worker under Wine 11.22 with the submitted handle mask. I tested
8eedef9bonmain83046a71using the MSVC-target diagnostics build. The stockpipeline::make::suite passed 35/36.priority_tracks_live_waiters_during_an_early_buildsaw the worker stay at-2after a waiter parked, where it expected0.Logging the two calls in a scratch build showed
OpenThread(THREAD_SET_LIMITED_INFORMATION, ...)succeeded, thenSetThreadPriorityreturned zero with Win32 error 5 (ERROR_ACCESS_DENIED). Changing only the requested mask toTHREAD_SET_INFORMATIONmade all 36 tests pass in the same Wine prefix. This includes the in-flight boost, the return to base priority after the final waiter leaves, and the independence of refusal wakeups. Microsoft documents both access masks forSetThreadPriority. Win32 documentationThe result measures Win32 priority values using synthetic workers. Actual compile latency and scheduler throughput were outside the run.
git merge-treealso merged this head cleanly with #2789 and #3150 individually. AI-assisted with OpenAI Codex.@lixonik on GitHub · 2026-12-02 15:35 UTC · original
RUN (in game) -- unit tests + 300 s render-path verification for PR #3132:
8eedef9b4mainSHA:acc350745(git merge --no-ff, clean merge)python -I scripts/check_no_game_data.pyPASSpython -I tools/d3d12_switches.py --check d3d12/docs/switches.mdPASScargo test -p leonida-gpu --features diagnostics --lib --locked pipeline:: -- --skip depth_bounds_pipeline_loads_and_filters_draws-- 65 passed, 0 failed, 8 ignored (all newpipeline::make::completion_tests::*andpipeline::library::tests::a_slow_offline_timing_is_not_evidence_of_a_drawpassed; the skippeddepth_bounds_pipeline_loads_and_filters_drawstest is a pre-existing Windows 10 root-signature failure onmain, tracked in #2855)diagprofile (diagnostics,dlss,mimalloc), Series S profile, DLSS on, Frame Gen off, same restored save snapshot8eedef9b4onacc350745)mainalone (acc350745)Loaded into the world cleanly, stayed up past 300 s in-world with 0 device lost / 0 crashes / 0
ERRORlines, and closed cleanly. Rendered median FPS matchesmain(26.7vs26.8fps) with a slightly tighter slowest tenth (22.8vs21.9fps).Verdict: PASS.
AI-assisted: yes (Antigravity).
@zmasi on GitHub · 2026-12-02 15:51 UTC · original
Thanks @merzleckeier for catching and verifying that under Wine 11.22 (
OpenThread(THREAD_SET_INFORMATION, ...)vsTHREAD_SET_LIMITED_INFORMATIONforSetThreadPriority), and thanks @Kal0s-design and @lixonik for the stress suites and 315 s in-game verification on8eedef9b4!To keep
8eedef9b4's verified 315 s Windows in-game run intact for review (CONTRIBUTING.mdsingle-topic / current-head gate), I am leaving8eedef9b4untouched and will open the 1-lineTHREAD_SET_INFORMATIONWine follow-up PR as soon as this lands — or happy to pushTHREAD_SET_INFORMATIONdirectly onto this branch if a maintainer prefers.AI-assisted (Gemini 4 Carbon High).
@MoonEyes on GitHub · 2026-12-02 18:00 UTC · original
Triage of head
8eedef9b4(merge based0bf821fa, 87 commits behind;git merge-treeagainst currentmain45dc41f95: no conflicts).5 files in
leonida-gpu/src/pipeline/(+405/-44), newmake/completion.rsand its tests.CI green on the head (6 checks, including
d3d12 (windows-latest)).Existing verification: Verified on this head by @Kal0s-design (pipeline:: 66 passed, full lib 783 passed, clippy clean) and @lixonik (in game, 300+ s,
mainacc350745). @merzleckeier found that under WineSetThreadPriorityneedsTHREAD_SET_INFORMATION; the author is leaving this head untouched and will send that one-line fix separately.This check: Not re-reviewed in depth. Note for merge order: #3185 (
COMPILE_GATE, on by default) serialises every compile inlibrary::pipeline, which would largely cancel the per-pipeline waiter wake-ups and priority donation here; the two heads merge without textual conflict (merge-treeclean) but should not both land without a measurement of the combination.I did not build it: the crate is Windows-only (or the C++ runtime's Windows build), so no red/green was run here.
Verdict: ready (verified in game on this head; Wine priority fix to follow separately; watch interaction with #3185).
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
@fiestorra on GitHub · 2026-12-02 23:17 UTC · original
VERIFY-3132 — Windows nativo: las cuatro pruebas de completación pasan y el control mata dos
958bdee65,20dab512d—pipeline/make.rs,make/completion.rs(+106),make/completion_tests.rs(+133),library.rs8eedef9b4(the branch also mergesmain)Ran at the head
Negative control (synthetic): I made the worker boost unconditionally (
let boosted = set_current(THREAD_PRIORITY_NORMAL);, droppingstate.waiters != 0), rebuilt and ran:Two of the four bite, including the one that exists for exactly this: "a request whose wait budget expired does not boost a later build" — the comment is the change: "Only live callers donate priority. Queuing a cold backlog or running out of wait budget must not leave the whole worker pool boosted."
A fact worth having in the merge order: these two commits are the ones #3200 carries — I verified #3200 earlier tonight on the same pair (
20dab512d,958bdee65). So one of the two pull requests can be merged and the other closed as contained, and whichever is kept should say so in its description.What I could not test
completionwas run.Written with an AI assistant.
@zmasi on GitHub · 2026-12-03 15:09 UTC · original
Merged
origin/main(128579e9ef, including#3333compiler guard) into3e36b182d0(needs rebase), regeneratingd3d12/docs/switches.mdand wiringworker_lost(pipeline/make.rs) to callif p.made.set(None).is_ok() { p.completion.notify(); }beforep.release_claim(slot)so guarded driver-compiler crashes wake per-pipelineCompletionwaiters immediately instead of burning the wait budget (72/72pipeline::tests pass).AI-assisted: Gemini 4 Neon (XHigh) and Gemini 4 Carbon (High).
@MoonEyes on GitHub · 2026-12-03 16:18 UTC · original
In-game gate run on an RTX 4060 8 GB (driver 610.88, Windows 11), in a batch of #3132, #3200 and #3226 merged into main
d227aa73e; this PR tested at its current head3e36b182d. Series S 1080, DLSS FG 2x,play-nvidia.ps1 -SeriesS -Resolution 1080 -FrameGen 2 -PrecompileUsed, scripted walk, 330 s.AI-assisted (Claude Opus 5.5), run and read by MoonEyes' agent.
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.