d3d12/shadow: allocate cold buffer and window copies outside table write locks (D3D12-SHADOW-UNLOCK-ALLOC) #3139
Open
zmasi wants to merge 2 commits from
upstream-pr/3139 into main
pull from: upstream-pr/3139
merge into: ProjectLeonida:main
ProjectLeonida:main
ProjectLeonida:claude/loop-total
ProjectLeonida:claude/pops-collision-seed
ProjectLeonida:claude/dstorage-hold-page-reads
ProjectLeonida:claude/host-image-copy-switch
ProjectLeonida:feat/gdk-lifecycle-window-hook
ProjectLeonida:claude/d16s8-uav-nvidia-fallback
ProjectLeonida:feat/mfplat-offline-shim
ProjectLeonida:claude/gameinput-slow-reader
ProjectLeonida:fix/rt-null-barrier-clear
ProjectLeonida:claude/depth-resolve-sample-positions
ProjectLeonida:integration/palmetto-parity
ProjectLeonida:claude/valu-literal-sext
ProjectLeonida:claude/slot74-pool-handle
ProjectLeonida:claude/rgb9e5-uint-alias-view
ProjectLeonida:claude/fssm-root-layout-tables
ProjectLeonida:feat/gdk-speech-display-lifecycle
ProjectLeonida:asset-audio-skip-current
ProjectLeonida:qemmhd/old-9940-rectangle-quad-lists
ProjectLeonida:feat/ws2-offline-shim
ProjectLeonida:qemmhd/rt-d16-unorm-uav
ProjectLeonida:feat/xs-device-stops-7-9
ProjectLeonida:qemmhd/rt-depth-same-base-shapes
ProjectLeonida:qemmhd/rt-lazy-attachment-variant
ProjectLeonida:feat/acphal-xma2-decoder
ProjectLeonida:asset-audio-skip
ProjectLeonida:codex/coord-claim-check-20261124-7e48
ProjectLeonida:feat/xs-frame-pacing-presentx
ProjectLeonida:feat/xs-device-vm-options
ProjectLeonida:old-pr/9844
ProjectLeonida:old-pr/9978
ProjectLeonida:old-pr/9815
ProjectLeonida:old-pr/10057
ProjectLeonida:old-pr/9874
ProjectLeonida:old-pr/9965
ProjectLeonida:old-pr/9863
ProjectLeonida:old-pr/10068
ProjectLeonida:old-pr/10066
ProjectLeonida:old-pr/10067
ProjectLeonida:old-pr/10007
ProjectLeonida:old-pr/10061
ProjectLeonida:old-pr/10065
ProjectLeonida:old-pr/10059
ProjectLeonida:old-pr/10063
ProjectLeonida:old-pr/10055
ProjectLeonida:old-pr/10062
ProjectLeonida:old-pr/10042
ProjectLeonida:old-pr/10041
ProjectLeonida:old-pr/10049
ProjectLeonida:old-pr/10047
ProjectLeonida:old-pr/10046
ProjectLeonida:old-pr/10045
ProjectLeonida:old-pr/10056
ProjectLeonida:old-pr/10043
ProjectLeonida:old-pr/10036
ProjectLeonida:old-pr/10034
ProjectLeonida:old-pr/9984
ProjectLeonida:old-pr/10052
ProjectLeonida:old-pr/10038
ProjectLeonida:old-pr/10033
ProjectLeonida:old-pr/10028
ProjectLeonida:old-pr/10050
ProjectLeonida:old-pr/9891
ProjectLeonida:old-pr/9889
ProjectLeonida:old-pr/10051
ProjectLeonida:old-pr/10019
ProjectLeonida:old-pr/10027
ProjectLeonida:old-pr/10029
ProjectLeonida:old-pr/10031
ProjectLeonida:old-pr/10026
ProjectLeonida:old-pr/9941
ProjectLeonida:old-pr/10030
ProjectLeonida:old-pr/10040
ProjectLeonida:old-pr/9990
ProjectLeonida:old-pr/10021
ProjectLeonida:old-pr/9962
ProjectLeonida:old-pr/10022
ProjectLeonida:old-pr/10020
ProjectLeonida:old-pr/10015
ProjectLeonida:old-pr/10025
ProjectLeonida:old-pr/9886
ProjectLeonida:old-pr/10048
ProjectLeonida:old-pr/10014
ProjectLeonida:old-pr/10011
ProjectLeonida:old-pr/9861
ProjectLeonida:old-pr/10010
ProjectLeonida:old-pr/10008
ProjectLeonida:old-pr/9860
ProjectLeonida:old-pr/10006
ProjectLeonida:old-pr/9920
ProjectLeonida:old-pr/9995
ProjectLeonida:old-pr/10000
ProjectLeonida:old-pr/10016
ProjectLeonida:old-pr/10004
ProjectLeonida:old-pr/10023
ProjectLeonida:old-pr/9982
ProjectLeonida:old-pr/9981
ProjectLeonida:old-pr/9983
ProjectLeonida:old-pr/9970
ProjectLeonida:old-pr/9969
ProjectLeonida:old-pr/9968
ProjectLeonida:old-pr/9971
ProjectLeonida:old-pr/9972
ProjectLeonida:old-pr/9942
ProjectLeonida:old-pr/9963
ProjectLeonida:old-pr/9960
ProjectLeonida:old-pr/9964
ProjectLeonida:old-pr/9985
ProjectLeonida:old-pr/9973
ProjectLeonida:old-pr/9862
ProjectLeonida:old-pr/9953
ProjectLeonida:old-pr/10017
ProjectLeonida:old-pr/9952
ProjectLeonida:old-pr/9955
ProjectLeonida:old-pr/9946
ProjectLeonida:old-pr/9954
ProjectLeonida:old-pr/9938
ProjectLeonida:old-pr/9956
ProjectLeonida:old-pr/9856
ProjectLeonida:old-pr/9947
ProjectLeonida:old-pr/9924
ProjectLeonida:old-pr/9961
ProjectLeonida:old-pr/9927
ProjectLeonida:old-pr/9979
ProjectLeonida:old-pr/10032
ProjectLeonida:old-pr/9926
ProjectLeonida:old-pr/5237
ProjectLeonida:old-pr/9951
ProjectLeonida:old-pr/9931
ProjectLeonida:old-pr/9902
ProjectLeonida:old-pr/9921
ProjectLeonida:old-pr/9994
ProjectLeonida:old-pr/9775
ProjectLeonida:old-pr/9768
ProjectLeonida:old-pr/9905
ProjectLeonida:old-pr/9936
ProjectLeonida:old-pr/9901
ProjectLeonida:old-pr/9904
ProjectLeonida:old-pr/9906
ProjectLeonida:old-pr/9988
ProjectLeonida:old-pr/9908
ProjectLeonida:old-pr/9909
ProjectLeonida:old-pr/9911
ProjectLeonida:old-pr/9912
ProjectLeonida:old-pr/9913
ProjectLeonida:old-pr/9887
ProjectLeonida:old-pr/9916
ProjectLeonida:old-pr/9919
ProjectLeonida:old-pr/9925
ProjectLeonida:old-pr/9933
ProjectLeonida:old-pr/9935
ProjectLeonida:old-pr/9918
ProjectLeonida:old-pr/9879
ProjectLeonida:old-pr/9880
ProjectLeonida:old-pr/9881
ProjectLeonida:old-pr/9996
ProjectLeonida:old-pr/9876
ProjectLeonida:old-pr/9892
ProjectLeonida:old-pr/9899
ProjectLeonida:old-pr/9915
ProjectLeonida:old-pr/9914
ProjectLeonida:old-pr/9872
ProjectLeonida:old-pr/9869
ProjectLeonida:old-pr/9866
ProjectLeonida:old-pr/9819
ProjectLeonida:old-pr/10012
ProjectLeonida:old-pr/9857
ProjectLeonida:old-pr/9893
ProjectLeonida:old-pr/9897
ProjectLeonida:old-pr/9928
ProjectLeonida:old-pr/9868
ProjectLeonida:old-pr/9917
ProjectLeonida:old-pr/9940
ProjectLeonida:old-pr/9873
ProjectLeonida:old-pr/9816
ProjectLeonida:old-pr/10009
ProjectLeonida:old-pr/9900
ProjectLeonida:old-pr/9966
ProjectLeonida:old-pr/9859
ProjectLeonida:old-pr/9843
ProjectLeonida:old-pr/9991
ProjectLeonida:old-pr/10058
ProjectLeonida:old-pr/9883
ProjectLeonida:old-pr/9838
ProjectLeonida:old-pr/9835
ProjectLeonida:old-pr/9959
ProjectLeonida:old-pr/9895
ProjectLeonida:old-pr/9837
ProjectLeonida:old-pr/9858
ProjectLeonida:old-pr/9865
ProjectLeonida:old-pr/9864
ProjectLeonida:old-pr/9840
ProjectLeonida:old-pr/9820
ProjectLeonida:old-pr/4669
ProjectLeonida:old-pr/9848
ProjectLeonida:old-pr/9850
ProjectLeonida:old-pr/9810
ProjectLeonida:old-pr/9799
ProjectLeonida:old-pr/9853
ProjectLeonida:old-pr/9875
ProjectLeonida:old-pr/9831
ProjectLeonida:old-pr/9796
ProjectLeonida:old-pr/9801
ProjectLeonida:old-pr/9813
ProjectLeonida:old-pr/9794
ProjectLeonida:old-pr/7417
ProjectLeonida:old-pr/9781
ProjectLeonida:old-pr/9806
ProjectLeonida:old-pr/9958
ProjectLeonida:old-pr/9809
ProjectLeonida:old-pr/9791
ProjectLeonida:old-pr/9792
ProjectLeonida:old-pr/10053
ProjectLeonida:old-pr/9784
ProjectLeonida:old-pr/9789
ProjectLeonida:old-pr/9849
ProjectLeonida:old-pr/9846
ProjectLeonida:old-pr/9773
ProjectLeonida:old-pr/9785
ProjectLeonida:old-pr/9803
ProjectLeonida:old-pr/9826
ProjectLeonida:old-pr/9839
ProjectLeonida:old-pr/9922
ProjectLeonida:old-pr/9948
ProjectLeonida:old-pr/7189
ProjectLeonida:old-pr/9957
ProjectLeonida:old-pr/9823
ProjectLeonida:old-pr/9807
ProjectLeonida:old-pr/9851
ProjectLeonida:old-pr/9774
ProjectLeonida:old-pr/9830
ProjectLeonida:old-pr/9836
ProjectLeonida:old-pr/9822
ProjectLeonida:old-pr/9783
ProjectLeonida:old-pr/9833
ProjectLeonida:old-pr/9890
ProjectLeonida:old-pr/9770
ProjectLeonida:old-pr/9769
ProjectLeonida:old-pr/9772
ProjectLeonida:old-pr/9787
ProjectLeonida:old-pr/9852
ProjectLeonida:old-pr/9834
ProjectLeonida:old-pr/9845
ProjectLeonida:old-pr/9871
ProjectLeonida:old-pr/9771
ProjectLeonida:old-pr/9776
ProjectLeonida:old-pr/10005
ProjectLeonida:old-pr/9949
ProjectLeonida:old-pr/9923
ProjectLeonida:old-pr/9805
ProjectLeonida:old-pr/9829
ProjectLeonida:old-pr/9790
ProjectLeonida:old-pr/9827
ProjectLeonida:old-pr/9929
ProjectLeonida:old-pr/9855
ProjectLeonida:old-pr/9934
ProjectLeonida:old-pr/9907
ProjectLeonida:old-pr/9910
ProjectLeonida:old-pr/9779
ProjectLeonida:old-pr/9780
ProjectLeonida:old-pr/9885
ProjectLeonida:old-pr/9882
ProjectLeonida:old-pr/9877
ProjectLeonida:old-pr/9998
ProjectLeonida:old-pr/4251
ProjectLeonida:old-pr/9987
ProjectLeonida:old-pr/9989
ProjectLeonida:old-pr/9950
ProjectLeonida:old-pr/9777
ProjectLeonida:old-pr/10044
ProjectLeonida:old-pr/9884
ProjectLeonida:old-pr/2906
ProjectLeonida:old-pr/5076
ProjectLeonida:old-pr/9937
ProjectLeonida:old-pr/9986
ProjectLeonida:old-pr/3014
ProjectLeonida:old-pr/9943
ProjectLeonida:old-pr/9939
ProjectLeonida:old-pr/4682
ProjectLeonida:old-pr/4765
No reviewers
Labels
Clear labels
No items
No labels
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.
Reference
ProjectLeonida/mandy!3139
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3139"
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?
Imported from ubiquitarianism/leonida. Originally posted by zmasi on 2026-12-02T13:36:02Z.
Claimed in the coordination issue as:
D3D12-SHADOW-UNLOCK-ALLOC(https://github.com/ProjectLeonida/mandy/issues/2570#issuecomment-7345440394)Addresses #3105 (does not close it: eliminates exclusive
BUFFERSandLOOSEtable write-lock contention across slow D3D12 host/card buffer creation onleonida-list-Nthreads; companion timeline attribution is in #3136).What and why
shadow::exact(d3d12/crates/leonida-gpu/src/shadow.rs:7700) already dropped its table lock before callingshared_buffer(CreateCommittedResource+MakeResident+Map) because holding the map lock across kernel/WDDM buffer creation serialized allleonida-list-Nthreads (WaitOnAddress). However, bothshadow::lookup(BUFFERS) andshadow::loose(LOOSE) still held exclusiveRwLockwrite guards across cold D3D12 allocations — matching #3105's stall trace pattern where oneleonida-list-Nthread hits an unhooked WDDM allocation/residency call insidelist::with_statewhile peerleonida-list-Mthreads block inWaitOnAddresslinked to it:shadow::lookup()(BUFFERS) cold allocation outsideBUFFERS.write():place_for,shared_buffer, andcard_forallocations outsideBUFFERS.write(), deduplicated per(start, resource, generation)viaBUFFERS_INFLIGHTwith an unwind-safe guard so panics orNonereturns always clean up the in-flight slot and wake waiters without poisoning.Entry.generation(NEXT_BUFFER_GEN) +entry.endto prevent ABA/resurrection ifunregisterorregisterraces mid-allocation, retries in-place opening across transientwatch::Remappingwindows (watch::change_over()) soLEONIDA_PORT_CONSTANTS=1/LEONIDA_INPLACEbuffers are not demoted to copies during streaming, and runsnote_carded+elide_note_boundsunderbuffers()strictly on winning publication (Shadow::newattachescard/mappedimmediately after allocation so unwinds never leak global byte counters).shadow::loose()(LOOSE) read-lock hits & unlocked cold window creation:tails()andany && fine()) underLOOSE.read()and coordinates cold(start, len)window creation (place_for,window_mapped_for,shared_buffer,window_card_for) outsideLOOSE.write()viaLOOSE_INFLIGHT, keepingArc::strong_count >= 2until followers clone and runnote_asksolet_go_idleremains race-free.Tested
python -I scripts/red_green.py HEAD --no-fetch --no-python:verdict: red then green(3/3new concurrency/race/unwind regression tests fail onmainand pass onHEAD;692tests pass on both).--release, 7 hot reader list threads + 1 thread in a simulated50 mscold allocation):BUFFERS(lookup/find): max reader stall48.241 ms->0.237 ms(203xlower stall latency;217,090->1,604,541reader ops).LOOSE(loose): max reader stall47.883 ms->0.026 ms(1,841xlower stall latency;194,799->2,368,813reader ops).x86_64-pc-windows-msvc):cargo test -p leonida-gpu [--features diagnostics] --lib --target x86_64-pc-windows-msvc shadow::—70 passed, 0 failedin both default anddiagnosticsbuilds (covering hot-read non-blocking during coldBUFFERS/LOOSEmisses, single-allocation deduplication on concurrent same-key misses,16 MiBcard-eligible unregister race + panic unwind with zerolive_span_bytes()leak, andLEONIDA_WINDOWS_BAR_MBindependence).cargo clippy -p leonida-gpu [--features diagnostics] --all-targets --no-deps --target x86_64-pc-windows-msvc—0warnings inshadow.rs.python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/shadow.rsandpython -I tests/test_text_write_line_endings.py— exit0.GPUs tested: NVIDIA GeForce RTX 3090 24 GB, driver 610.88, Windows 11 Pro
10.0.26200(D3D12 host/card buffer unit tests and multi-thread contention benchmarks; no retail title run).AI-assisted: yes — authored with Gemini 4 Carbon (High) and independently audited across two read-only review cycles by Gemini 4 Neon (XHigh) (which caught and verified pre-logging
Shadowattachment for unwind byte-counter safety andwatch::change_over()in-place retry during concurrent page remaps).Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).docs/design.md, with how it was confirmed.Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T14:40:59Z.
Ran natively on Windows 11, head
2bc1f6f43merged into currentmain(69cd4106c, merges cleanly), on WARP and on one NVIDIA desktop card. I also wrote some throwaway stress tests (not pushed) and ran them on the merge and onmainalone.Suites on the merge
cargo test -p leonida-gpu --lib --features diagnostics, WARPcargo test -p leonida-gpu --lib(default features), WARPunlock_alloc_tests, WARP and NVIDIAcargo clippy -p leonida-gpu --all-targets --features diagnosticsshadow.rsThe new tests return early when there is no host. A host was present in both runs (the panic-unwind case in
unregister_race_...only passes when the allocation path actually runs).Races, leaks and duplicates (stress, 20 rounds each, WARP and NVIDIA, merge vs
main)mainfinds over 48 cold buffers, no churn: allocations / copies per bufferunregister+registerwith a new size: a second copy for a buffer that was never re-registeredpeekshowing an old-size copy after the roundLIVEcount and bytes,live_span_bytes()after unregistering, both casesfinds over 24 cold 4 MiB windows: allocations / copies per window /LIVEafterLIVEafter, a normal buffer right afterIn the churn rounds the merge makes more copies than it hands out (for example 1,591 made, 1,352 seen). Those are the
Stalecopies dropped afterregisterraced the allocation. All of them were freed:LIVEwent back to zero every round.One behaviour
maindoes not have:findcan returnNonefor a live bufferlookupnow gives up after 8Staleoutcomes in a row. One thread re-registers a single buffer in a loop while 8 threadsfindit, 24,000 asks per run:Noneon the mergeNoneonmainmainthe loop waits behind each allocation)When I raised the bound from 8 to 1,000 locally, the merge went to 0
Noneat the 20 us pacing. So these are theStaleretries running out. The setup is artificial, and I don't know whether a title ever re-registers one buffer this fast. If it does, the draw gets no copy at all, wheremaingives one. Falling through to theloosepath or retrying without a bound would avoid that.Opt-in finer windows (
LEONIDA_WINDOW_KB=256,find_any), WARPThread A asks for a 1 MiB range and is held inside its window allocation. Thread B then asks for 64 bytes inside that range:
mainholder/longest_tailnow pick the key under the read lock, and the in-flight table only joins asks with the exact same key. So overlapping asks that race make more than one window, whichmainavoided by holding the write lock. Only withLEONIDA_WINDOW_KBbelow 4096 orLEONIDA_WINDOW_TAILS=1, and it costs memory and copies, not correctness. I did not tryLEONIDA_WINDOW_TAILS=1on its own.Lock hold time with real allocations (no simulated sleep)
The bench in the PR compares a sleep under the lock against a sleep outside it, so it shows what the design allows but not what an allocation costs. Here, one thread makes 64 real cold copies of 16 MiB buffers in a row while 6 threads look up a buffer that already has its copy. 3 runs each, ranges across runs:
main, WARPmain, NVIDIAOn
mainthe slowest lookup matches the slowest allocation, so readers wait out the whole allocation. On the merge they don't. The allocations themselves take about as long as before.Overlap with #2981
Both PRs edit
shadow.rs, and they conflict when merged together (5 hunks). Three hunks are only the two new test modules colliding at the end of the file. The other two are real: #2981 adds anaccountfield toCard, and the twoCard { .. }literals this PR rewrites inbuild_buffer_shadowandbuild_loose_shadowdon't have it. Whichever lands second has to addaccount: CardAccount::Bufferandaccount: CardAccount::Windowthere. Otherwise it won't compile, andDrop for Shadowwould release from the wrong counter. I did not resolve or build the combination.Not checked: in-game run; the combination with #2981;
LEONIDA_WINDOW_TAILS=1on its own;LEONIDA_PORT_CONSTANTS=1and in-place (LEONIDA_INPLACE) paths under concurrency; the debug layer.GPUs tested: one NVIDIA desktop card + WARP.
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by lixonik on 2026-12-02T15:27:32Z.
RUN (in game) -- unit tests + 300 s render-path verification for PR #3139:
2bc1f6f43mainSHA:acc350745(git merge --no-ff, clean merge)python -I scripts/check_no_game_data.pyPASScargo test -p leonida-gpu --features diagnostics --lib --locked shadow::-- 70 passed, 0 failed, 3 ignored (including all 4 newshadow::unlock_alloc_tests::*concurrency/coalescing/unwind tests)diagprofile (diagnostics,dlss,mimalloc), Series S profile, DLSS on, Frame Gen off, same restored save snapshot2bc1f6f43onacc350745)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. Steady-state idle-camera FPS and preparing time matchmainwithin run-to-run variance (as expected, since lockless cold allocation targets cold-miss stalls on recording threads rather than hot-cache steady-state frames).Verdict: PASS.
AI-assisted: yes (Antigravity).
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T16:26:00Z.
Verified here: it applies, and the whole
shadowgroup passes with it - 70 tests, 0 failed, including the four new ones that are the point of the change.Those four are the right four for "allocate outside the table write locks": a miss not blocking hot reads (the property the change exists for), two concurrent misses making one allocation (the failure mode of moving allocation out - a storm of duplicates), and an unregister racing an allocator panic cleaning up without a leak or a deadlock (the one that only shows up in a crash report months later). All pass, and nothing else in the module moved.
What that does not measure: the contention it is meant to reduce. A test can show that a miss no longer blocks a reader; it cannot show how much time that saves in the title, and I did not run one - the numbers for that would need a run, which this machine cannot do.
And one thing to keep an eye on:
unregister_race_and_allocator_panic_clean_up_without_leak_or_deadlockis a name that describes a real hazard - if it ever goes flaky, it is worth reading before skipping it.AI-assisted: yes - DeepSeek v4.1 (flash).
Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:02:07Z.
Light code review only, not built (Windows-only
leonida-gpu). Ready, based on the runs already posted on this head.2bc1f6f43, merge base044339e4c, 63 behind currentmain45dc41f95. A trial merge is clean. CI on the head: all 6 checks pass.main. This satisfies the render-path gate.shadowgroup passes.Review notes on
d3d12/crates/leonida-gpu/src/shadow.rs(1,046 added, 178 removed):place_for,shared_bufferandcard_forallocation now happens outsideBUFFERS.write()andLOOSE. Work is de-duplicated through an in-flight table with an unwind guard. EachEntry.generationplusendcheck on publication guards against ABA whenunregisterorregisterraces the allocation. This is the right shape for #3105: blocking WDDM calls no longer serialize theleonida-list-Nthreads.Shadow::newright after allocation, so a loser does not leak them. I did not trace every unwind path in a diff this size. The in-game and unit runs above are the evidence for those paths, not this review.Verdict: ready.
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T23:11:53Z.
VERIFY-3139 — Windows nativo: 70 pruebas de
shadowpasan y el control muerde el coalescingad72eee3f—shadow.rs, +1046/−178 (the branch also mergesmain,2bc1f6f43)044339e4cRan at the head
Negative control (synthetic): I made the in-flight table never find its own entry (
map.get(&key).cloned().filter(|_| false)), so every concurrent miss allocates its own, rebuilt and ran:The test bites on the mechanism the commit adds — a per-key in-flight map with a
Condvar: one thread builds, the others wait and take the published value, and a hit never touches the table's write lock at all.Why the shape is right for what it is: this is a lock-hold-time change, so the tests are named after the property rather than the function — "a lookup miss does not block hot buffer reads", "…hot window reads", "concurrent misses coalesce a single allocation", "unregister race and allocator panic clean up without leak or deadlock". Those are the four ways this kind of change breaks, and each has one.
What I could not test
shadow), not the full suite on the merged tree.Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by kaoru-maki on 2026-12-03T05:26:44Z.
For a follow-up to the cold allocation in
shadow::lookup, could we measure allocator time and the wait on unrelated hot lookups separately? A burst of misses for different keys would help show how far the stall spreads. Run the two versions in both orders from the same initial state.Synthetic test. Park the allocation for key A, queue a second cold miss for B, and look up the already-ready key C. With unlocked allocation, C should complete while A is still paused. Record the longest hot lookup wait in each run.
Imported from ubiquitarianism/leonida. Originally posted by kaoru-maki on 2026-12-03T05:26:57Z.
A follow-up to the unlocked allocation would be to install the ready buffer in a per-resource record. Validate the generation and range and install the handle while holding the same entry guard used to retire the resource. That would move final handle publication off the global index write lock.
Synthetic race test. Pause the builder for generation 1 of resource A after allocation. Unregister A, register it again as generation 2, and resume the old builder. Assert that the old candidate is discarded and generation 2 stays current. Publishing A should also allow lookups of an unrelated ready entry to finish.
Imported from ubiquitarianism/leonida. Originally posted by kaoru-maki on 2026-12-03T08:07:20Z.
Follow-up with four matched A/B pairs using this PR head (
2bc1f6f43399) merged locally into cleanmain(d9b618f10150). I used an RTX 5070 Ti Laptop GPU (12 GB) on Windows 11 with NVIDIA driver 621.47, native 2560×1440 DLAA, no frame generation, and Smooth Motion off. The order wasA B B A A B B Aafter two warm-ups. Each measured run started from the same prepared PSO cache snapshot.The paired change in median frame time was −0.43 ms for B versus A (95% CI −0.98 to +0.13 ms). The early window showed fewer long frames. The full-route result was inconclusive.
Run report in #2464.
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T08:18:46Z.
I ran the requested two-cold-key control against the actual lookup paths on
maind9b618f1and this head2bc1f6f4. The same test-only hook parked cold lookup A for 150 ms immediately before its host allocation. Fresh threads then calledfindfor cold key B and for an unrelated ready key C. C had an empty thread-local cache, and the test checked that it returned the existingArc. The run order was A/B, B/A, A/B.mainThe timings are from the synthetic 150 ms pause in a Windows MSVC build under Wine 11.22. The four existing
shadow::unlock_alloc_testspassed, with the separate ignored benchmark left ignored. This isolates the spread of the table-lock wait. AI-assisted with OpenAI Codex.Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T10:28:16Z.
I checked the #2981 overlap with this exact head (
2bc1f6f43) onmaind9b618f10. The #2981 headb020637acstill conflicts here in five hunks ofshadow.rs. A local resolution kept this PR’s unlocked allocation and publication, setCardAccount::Bufferon the cold buffer constructor andCardAccount::Windowon the cold window constructor, and kept both test modules.The resolved diagnostics build passed the
shadow::suite on AMD Radeon (RADV 26.3.1, Wine 11.22, vkd3d-proton 3.1.0). 73 passed, 0 failed, 3 ignored. A separate synthetic test usedLEONIDA_CARD_ALL=1andLEONIDA_WINDOWS_OWN=1to exercise both actual constructors. Freeing the buffer returnedCARD_BYTES[0]to baseline while leaving the window’s reservation live. Freeing the window then returnedWINDOW_CARD_BYTESto baseline.BY_ADDRESS_USEDstayed at baseline throughout.git diff --checkpassed.AI-assisted verification with OpenAI Codex.
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.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.