d3d12: per-pipeline waiter wakeups and live-waiter priority donation (D3D12-PIPELINE-WAIT-AND-SLOW-EARLY) #3132
Code
Clone this repository
Checkout
From your project repository, check out a new branch and test the changes.
git fetch -u origin "github-pr/3132:github-pr/3132" git switch "github-pr/3132"
Open
leonida/mandy
zmasi wants to merge 4 commits from
github-pr/3132 into main
pull from: github-pr/3132
merge into: leonida:main
leonida:main
leonida:github-pr/3295
leonida:beta
leonida:docs/changelog-3483-3500
leonida:github-pr/3294
leonida:github-pr/2975
leonida:github-pr/2815
leonida:feat/gate-driver-start
leonida:feat/skip-pipelines-release
leonida:perf/lazy-compare
leonida:perf/mwaitx-wait
leonida:test/prio-ceiling-main
leonida:fix/ab-cpu-stdout
leonida:fix/gate-old-crashes
leonida:diag/ab-cpu
leonida:test/main-0312
leonida:github-pr/3291
leonida:diag/indirect-clamp-census
leonida:feat/barrier-enhanced
leonida:perf/texture-frame-ceiling
leonida:perf/dstorage-threads
leonida:fix/console-queue-dma-tables
leonida:fix/port-descriptors-record-parts
leonida:fix/frame-waits-fence
leonida:fix/console-sampler-words
leonida:fix/graphics-userdata-spill
leonida:fix/xg-reserved-layout-rotation
leonida:fix/barrier-console-flags
leonida:fix/switches-wait-test-child
leonida:test/list-value-waits
leonida:test/lot-gxdk-0412
leonida:fix/bvh-compacted-size
leonida:docs/i18n-quickstarts
leonida:feat/native-pipeline-slots
leonida:fix/clippy-leonida-gpu
leonida:fix/list-value-producers
leonida:fix/descriptor-page-straddle
leonida:fix/xmem-low-window
leonida:fix/ffx-jitter-never-zero
leonida:fix/run-stdout-closed
leonida:github-pr/2892
leonida:github-pr/2896
leonida:feat/warm-save-every
leonida:github-pr/2980
leonida:github-pr/2994
leonida:github-pr/3005
leonida:github-pr/3010
leonida:github-pr/3136
leonida:github-pr/3303
leonida:github-pr/3220
leonida:github-pr/3143
leonida:github-pr/3330
leonida:github-pr/3226
leonida:github-pr/3187
leonida:carry/3395
leonida:github-pr/2946
leonida:github-pr/2947
leonida:github-pr/2945
leonida:github-pr/2983
leonida:github-pr/3001
leonida:github-pr/3372
leonida:github-pr/3128
leonida:github-pr/3296
leonida:github-pr/2588
leonida:github-pr/3119
leonida:github-pr/3378
leonida:fix/crash-diagnostics
leonida:feat/dlss-mip-bias
leonida:fix/retired-out-of-order
leonida:fix/dxr-postbuild-barrier
leonida:fix/amd-relay-default
leonida:fix/removed-report-wait
leonida:feat/heap-twin
leonida:feat/vram-margin
leonida:github-pr/2472
leonida:github-pr/3123
leonida:github-pr/3088
leonida:assets/annonce-v1
leonida:github-pr/2794
leonida:github-pr/3300
leonida:github-pr/3304
leonida:github-pr/3308
leonida:github-pr/3367
leonida:github-pr/3369
leonida:fix/launcher-dlss-diagnostics
leonida:github-pr/3269
leonida:github-pr/2957
leonida:github-pr/3205
leonida:fix/crash-zero-guard
leonida:github-pr/3185
leonida:github-pr/3099
leonida:github-pr/3104
leonida:github-pr/3348
leonida:github-pr/3379
leonida:github-pr/3377
leonida:perf/darner-title-priority-ceiling
leonida:github-pr/3376
leonida:gh-readonly-queue/main/pr-3311-b5c45b663dbc5a9c3532bb3f307e5f81b32faefa
leonida:gh-readonly-queue/main/pr-3088-af22e7847ff5808f72d1a1881c24be2fafd20b54
leonida:gh-readonly-queue/main/pr-3123-7f3fa026a94c6646e89244f28e1ce22290361867
leonida:github-pr/3373
leonida:github-pr/3368
leonida:github-pr/3198
leonida:gh-readonly-queue/main/pr-3354-637baa0b77ba47222e7280b17c1a59c6a1781d57
leonida:gh-readonly-queue/main/pr-3365-d7a0e0196a43834813014b4bd3aa5502a8263b14
leonida:gh-readonly-queue/main/pr-3361-5dfe8bbd05ed12fb2f2e1718d9af77a7c5f46fd8
leonida:gh-readonly-queue/main/pr-3366-8da9148204e9d12c585efa9ac2b7cc1ab08c7682
leonida:github-pr/3346
leonida:github-pr/3375
leonida:github-pr/2958
leonida:github-pr/3151
leonida:github-pr/3307
leonida:github-pr/3278
leonida:github-pr/3374
leonida:fix/runtime-test-conservative-fixtures
leonida:github-pr/3366
leonida:ci/shard-semantic-linux
leonida:github-pr/3354
leonida:docs/fg-limit-fps-switch
leonida:github-pr/3365
leonida:fix/read-file-hard-link
leonida:github-pr/3364
leonida:fix/book-slot-heap-never-read
leonida:github-pr/3361
leonida:github-pr/3263
leonida:github-pr/3360
leonida:github-pr/3353
leonida:github-pr/3331
leonida:fix/alias-later-queued-submissions
leonida:github-pr/3352
leonida:github-pr/3228
leonida:github-pr/3349
leonida:claude/gallant-sagan-aamatr
leonida:github-pr/3200
leonida:github-pr/3323
leonida:github-pr/3332
leonida:github-pr/3340
leonida:github-pr/3311
leonida:github-pr/3334
leonida:github-pr/3297
leonida:github-pr/3256
leonida:github-pr/2567
leonida:github-pr/2851
leonida:d3d12/agility-sdk-621
leonida:github-pr/3164
leonida:github-pr/3114
leonida:github-pr/3050
leonida:github-pr/3113
leonida:github-pr/3326
leonida:github-pr/3144
leonida:github-pr/2642
leonida:github-pr/3072
leonida:github-pr/2789
leonida:github-pr/2643
leonida:github-pr/3009
leonida:github-pr/3035
leonida:github-pr/3031
leonida:github-pr/2686
leonida:github-pr/2834
leonida:github-pr/3321
leonida:github-pr/3325
leonida:github-pr/3290
leonida:github-pr/3324
leonida:github-pr/3130
leonida:claude/fervent-curie-m19lnr
leonida:github-pr/3309
leonida:github-pr/3305
leonida:github-pr/3306
leonida:github-pr/3302
leonida:github-pr/3301
leonida:github-pr/3345
leonida:github-pr/3211
leonida:github-pr/3027
leonida:github-pr/3286
leonida:github-pr/3235
leonida:github-pr/3265
leonida:github-pr/3275
leonida:codex/skip-no-hit-ray-passes
leonida:github-pr/2823
leonida:github-pr/2911
leonida:github-pr/3262
leonida:github-pr/3125
leonida:github-pr/3206
leonida:github-pr/3250
leonida:github-pr/3238
leonida:github-pr/3188
leonida:github-pr/2952
leonida:github-pr/3217
leonida:github-pr/3168
leonida:t3/preserve-fsr-sdk-restart-path
leonida:t3/propagate-host-failure-hresult
leonida:github-pr/3209
leonida:t3/launcher-custom-parameters
leonida:github-pr/3207
leonida:github-pr/3183
leonida:github-pr/3160
leonida:github-pr/3201
leonida:ci/less-to-run
leonida:github-pr/2930
leonida:github-pr/2797
leonida:github-pr/2999
leonida:perf/native-compute-shader-forms
leonida:github-pr/3191
leonida:github-pr/3011
leonida:github-pr/3019
leonida:github-pr/2996
leonida:gh-readonly-queue/main/pr-2789-45dc41f95c1cd0dcc29c2c50582e0e9af8a77259
leonida:claude/blissful-franklin-ukp7ag
leonida:github-pr/3141
leonida:github-pr/3156
leonida:github-pr/3150
leonida:github-pr/3153
leonida:github-pr/3163
leonida:github-pr/3142
leonida:github-pr/3139
leonida:github-pr/2841
leonida:github-pr/3069
leonida:github-pr/3098
leonida:github-pr/3107
leonida:github-pr/3071
leonida:github-pr/2774
leonida:github-pr/2889
leonida:github-pr/3075
leonida:github-pr/2661
leonida:github-pr/3064
leonida:github-pr/3054
leonida:github-pr/3049
leonida:github-pr/2855
leonida:github-pr/2943
leonida:github-pr/3016
leonida:github-pr/2887
leonida:github-pr/3006
leonida:github-pr/3003
leonida:github-pr/2993
leonida:notes/card-time-and-plant-flicker
leonida:github-pr/2989
leonida:feat/vulkan-rs
leonida:github-pr/2985
leonida:github-pr/2951
leonida:github-pr/2982
leonida:github-pr/752
leonida:github-pr/792
leonida:github-pr/2877
leonida:github-pr/2654
leonida:github-pr/2893
leonida:github-pr/2948
leonida:github-pr/2944
leonida:github-pr/2919
leonida:github-pr/2915
leonida:archive/ci/less-to-run/20261202T1121Z
leonida:github-pr/2800
leonida:github-pr/2822
leonida:github-pr/2833
leonida:github-pr/2840
leonida:github-pr/2831
leonida:github-pr/2832
leonida:github-pr/2801
leonida:github-pr/2890
leonida:github-pr/2891
leonida:github-pr/2664
leonida:github-pr/2807
leonida:rt-call-trace
leonida:github-pr/2755
leonida:perf/ahead-split
leonida:github-pr/2587
leonida:github-pr/2698
leonida:github-pr/2609
leonida:github-pr/3219
leonida:docs/readme-runtime-proposal
leonida:github-pr/2017
leonida:github-pr/1741
leonida:github-pr/1667
leonida:codex/coord-claim-check-20261124-7e48
No reviewers
Assignees
Clear assignees
No assignees
Labels
Clear labels
bug
Something isn't working
dependencies
Pull requests that update a dependency file
documentation
Improvements or additions to documentation
enhancement
New feature or request
missing claim
Needs a claim in #14
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
No labels
bug
dependencies
documentation
enhancement
missing claim
needs rebase
needs-triage
question
ready-for-agent
submodules
Projects
Clear projects
No items
No project
Milestone
Clear milestone
No items
No milestone
Dependencies
No dependencies set
Notifications
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".
No due date set.
Reference
leonida/mandy!3132
Loading…
Reference in a new issue
No description provided.
Delete branch "github-pr/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?
This branch is out-of-date with the base branch
Reviewers 0 approvals
Details
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Claimed in the coordination issue as:
D3D12-PIPELINE-WAIT-AND-SLOW-EARLY(https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7343615179)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.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).
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).
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).
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
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.
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).
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.