d3d12: the contended-lock test waits for the holder, not for a thread to start (GPU-TIMELINE-REPORT-WAIT-HANDSHAKE) #3050
Open
Neutron-0 wants to merge 1 commit from
upstream-pr/3050 into main
pull from: upstream-pr/3050
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!3050
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3050"
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 Neutron-0 on 2026-12-02T05:38:41Z.
Claimed in the coordination issue as: GPU-TIMELINE-REPORT-WAIT-HANDSHAKE
What and why
real_waits_are_recorded_with_who_ended_them(d3d12/crates/leonida-gpu/src/timeline/report.rs, tests) holds a mutex, spawns a thread that is to block on it, sleeps a fixed 20 ms so that the thread has reachedlock.lock()by then, lets go, and asserts that the trace recorded a wait of 10 ms or more naming this thread as the waker.The 20 ms is a bet on the scheduler. On a loaded machine the new thread has not been started inside it, so it acquires the lock at once, no wait of 10 ms or more exists, and the assert fails with
left: Noneagainstright: Some(this thread). Measured onmain60f7dcd: 3 failures in 40 whole-suite runs ofcargo test -p leonida-gpu --lib --features diagnostics. The failing line is the assert, not the recorder: the recorder had nothing to name because there was no wait.The test is under the diagnostics feature, so the default
--librun does not compile it; it is the run the layer's own diagnostics build uses.What changed
standing()counter for that lock says that the wait has been reached (the wrapper takes the counter before it waits), and only then does this thread start its hold of 30 ms. The wait is therefore the holder's hold and not the time the waiter took to arrive: however late the waiter is woken up, the wait is 30 ms.lastis still taken before the contention, so none of this enters the chain.Verification (CPU-only, no game files, no GPU)
On this head, based on
main0ae5a2664(the branch's base; it merges cleanly into the currentmainba9e65cec):left: None,right: Some(27892)- the flake, every time.Trace::wakermade to returnNone, this test fails, since the chain is built from the wakes.cargo test -p leonida-gpu --lib --locked --features diagnostics): 3 runs on this head - two clean, 749 passed and 0 failed, 59 ignored each, and one withwatch.rs's known parallel race (watch::many_askers_tests::no_mapping_is_lost_between_askers, claimed underD3D12-GPU-TEST-PARALLEL-FLAKES), 748 passed and 1 failed. This test failed in none of them. The stock test failed in this suite 3 times in 40 runs onmain60f7dcd.descriptor.rs'srecords_copied_as_bytes_are_made_at_the_next_sync, the parallel raceD3D12-GPU-TEST-PARALLEL-FLAKEScovers (claimed by lixonik); one run with the same item'swatch.rsrace; one run withtexture.rs'salias_cast_tests::committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers, the parallel race #2854 fixes. Fifteen parallel runs in all, and this test failed in none of them.cargo test -p leonida-gpu --features diagnostics --lib timeline::report -- --test-threads=1: 6 passed, 0 failed, 59 ignored.cargo test -p leonida-gpu --lib --locked): 667 passed, 1 failed, 59 ignored. The failure wastexture.rs'salias_cast_tests::committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers, the parallel race #2854 fixes; it passes alone (6 passed, 1 ignored) and is not this test.cargo clippy -p leonida-gpu --lib --features diagnostics --tests: nothing in this file.What this does not do
It does not serialise the suite and does not touch the other parallel races in this crate (
watch.rs,descriptor.rs,texture.rs,pool.rs), which are claimed elsewhere. It changes only this test, so it would also stand if the suite were serialised later: this test's wait is no longer a thing to hide.Notes
The repository's own workflows ran on this head in the contributor's fork, where no maintainer's approval is needed, and they are green:
check,linux-python-and-viewerandsemantic-testssuccess,d3d12 (windows-latest)success (CI 47158599080; No Game Data 47158606629; D3D12 runtime 47158614758).change-scopeis the one job that cannot be produced that way: it only runs on apull_requestevent, so it needs the base repository's run.Checklist
main0ae5a2664(the branch's base); the branch merges cleanly into the currentmainba9e65cec.python -I scripts/check_no_game_data.pyclean.GPUs tested: n/a (a CPU-only test of the diagnostics recorder; it needs no GPU and no game files)
AI-assisted: yes - MiniMax M3.1 Flash (NVIDIA, via OpenCode) wrote the change, with independent read-only review agents (GLM-5.3 Flash via NVIDIA, Kimi K3.1 Pro via NVIDIA, and DeepSeek V4.1 Flash Free via OpenCode) and human reviews on this pull request.
Imported from ubiquitarianism/leonida. Originally posted by ecox982745 on 2026-12-02T05:42:38Z.
CPU-only review at
82e4a68b9. The handshake fixes a holder that starts late. It still permits the waiter to be descheduled after the holder signals and before the waiter attemptslock.lock()(timeline/report.rs:1463). If the holder runs its 30 ms sleep and releases the lock during that interval, the waiter acquires immediately and the new 10 ms assertion fails. The 30 ms holder-start perturbation exercises a different schedule.I checked the schedule in a small CPU-only model of the mutex and condvar handoff. Six ordinary attempts waited about 31 ms. Six with the waiter held until the release acquired in at most 0.001 ms. This models the synchronization sequence. The Rust trace test itself was not executed. A contrived delay immediately before the wait timer would exercise the remaining window in the Rust test.
The trace lookup also runs after
second.join(). If the holder is descheduled between dropping the lock and returning from the thread,max_by_key(|w| w.t1)can select the join wait. Consider timestamping the lock call with the trace clock and restricting the lookup to that interval. For the minimum-duration assertion, a bounded retry of an attempt where there was no measured lock contention would distinguish an unlucky schedule from attribution failure.AI-assisted review. No GPU or game files used.
Imported from ubiquitarianism/leonida. Originally posted by Neutron-0 on 2026-12-02T06:06:58Z.
One review round found a second way for this test to fail, and it is fixed in this head (
3f6545b0b).The join below is a wait of its own: the wrappers record it like any other wait of this thread. If the worker is slow to exit, that wait is later than the wait for the lock and is at least 10 ms long, so the assertion could pick it - and a join names no waker, so it failed with
left: None, the same shape as the flake this pull request removes. The ticks are now taken before the join and the waits are bounded by them, so the wait for the lock is the one that is measured.Measured here: with 30 ms between the holder's release and its exit, this head passes, and the head without the bound fails with
left: None.The wait for the holder's word is bounded as well (two seconds), so a holder that never takes the lock fails the test instead of hanging it.
On this head: whole diagnostics suite 2 runs, 749 passed and 0 failed each; the test itself 20 of 20 runs; default suite 668 passed, 0 failed.
Imported from ubiquitarianism/leonida. Originally posted by Neutron-0 on 2026-12-02T06:19:22Z.
One practical note on #3050: its three workflow runs (
D3D12 runtime,CI,No Game Data) are ataction_requiredon the head3f6545b0b. A fork run of a first-time contributor needs a maintainer to approve it before the jobs run; approving them would let the checks run. The same was asked for #2864's runs.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T12:39:51Z.
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by Kal0s-design on 2026-12-02T14:47:00Z.
Ran natively on Windows 11, head
3f6545b0bmerged into currentmain(2fc7383b9, clean merge), debug build,--locked.cargo test -p leonida-gpu --lib --features diagnostics, 3 runs (LEONIDA_D3D12_WARP=1, so the suite's few GPU tests ran on WARP only)cargo test -p leonida-gpu --libcargo clippy -p leonida-gpu --all-targets --features diagnosticstimeline/report.rs(the findings it reports are elsewhere and already onmain)Repeat counts. I built two diagnostics test binaries from the same merged tree. One has
main's version of the test and one has this head's. Each run launches the test binary as its own process with onlyreal_waits_are_recorded_with_who_ended_themselected.maintestAll 200 failures on
mainunder load wereno entry found for keyattrace.waits[&second]. The spawned thread recorded no waits at all: it was not scheduled within the 20 ms, so it never blocked on the lock. That is the same root cause as theleft: Nonefailure in the description, just one line earlier. Without the added load neither version failed on this machine, so the flake here needs load.Can it hang? No. With a throwaway variant where the holder never sets the flag or notifies, the test fails after 2.05 s with
the holder did not take the lock within two seconds.The window from the earlier review is real, but the load did not hit it. With a throwaway variant that sleeps 40 ms between the holder's notification and
let blocked = Instant::now(), the test failed (one run) withthis thread was to wait on the lock, and waited 11.3µs. So a waiter that is descheduled after the holder's word can still fail, as the earlier review described. It now fails at the new duration assertion with a clear message, not at the attribution. Under the 48-process load above that never happened in 200 runs. Reading the code (I only ran the 40 ms delay), the waiter blocks for about 30 ms minus its own delay, and the assertion needs 10 ms. So a delay of about 20 ms betweenwait_timeoutreturning andlock()is enough to fail. That margin is about the same size asmain's 20 ms bet. The difference is which delay it is: a woken thread that already exists has to lose 20 ms, wheremainneeded a new thread to start within 20 ms. Under this load the second happened every time and the first never did. A longer holder sleep (e.g. 100 ms) would widen the margin for slower CI machines, at the cost of test time.Not checked: CI runners, a heavier or real-time-priority load, loads other than CPU spinning (I/O, memory), the whole diagnostics suite under load.
GPUs tested: WARP only for the suite (the test this PR changes is CPU-only).
AI-assisted: yes (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-02T14:55:56Z.
Review: COMMENTED
I reproduced the late-waiter case on
3f6545b0merged ontoacc350745under Wine 11.22. A 70 ms delay after the holder signalled and before the waiter calledlock()let the 30 ms hold expire. The duration assertion then measured 400 ns, consistent with the earlier native Windows result. Previous verificationA local test-only variant removed that dependency. It armed a flag for the specific waiter thread immediately before the contended
lock(). The existing recorderstanding()hook signalled that the thread reached the instrumented wait. Only then did the holder start the measured 30 ms hold, with a two-second bound for a missing wait. The same 70 ms perturbation passed 3/3, including the assertion that the holder was the waker. This keeps the Rust mutex and tests the actual wait rather than increasing the scheduler allowance.The binaries in this probe had no debug symbols, so the local variant checked that the stack sites existed and left symbol-name resolution outside the measurement. No production code was changed. AI-assisted with OpenAI Codex.
Imported from ubiquitarianism/leonida. Originally posted by Neutron-0 on 2026-12-02T15:28:24Z.
Second review round, two findings, both fixed in
6a674a118.The wait that was measured could have been the wrong one. The condvar's wait is ended by the same holder that holds the lock, so it names the same waker, and the earlier shape took the latest wait of 10 ms or more - which could be that one. With a holder that waits 10 ms before it signals and keeps the lock for 1 ms, the lock's own wait is 1 ms and the condvar's is 10 ms: the earlier shape picked the condvar's wait, saw the holder as its waker and passed, while the lock's wait was never checked. The wait is now pinned by the ticks around the lock call - the one inside a try's own ticks - and it has to be 10 ms or more. With that same holder the test now fails and says so: "no try of the five waited on the lock for 10 ms or more".
The timing bet was moved, not removed. If the machine does not wake the test thread up inside the holder's 30 ms, the lock is free before the test thread asks for it and there is no wait at all - the same class of failure as the one this pull request removes. The holder is now started again and the try repeated, five tries at most, and the test fails only when none of them waited. Measured: with the first try asking for the lock 40 ms after the holder let it go, this head passes and the same head with one try fails.
Also: the first half's gate wait is bounded by two seconds now, like the new one, so a worker that dies fails the test instead of hanging it.
On this head: the test 20 of 20 runs; whole diagnostics suite 2 runs, 749 passed and 0 failed each; default suite 667 passed, 1 failed -
texture.rs's known race (#2854), which passes alone and is not this test.Imported from ubiquitarianism/leonida. Originally posted by Neutron-0 on 2026-12-02T17:29:42Z.
Third round, and the late-waiter window that @merzleckeier reproduced and @Kal0s-design measured is now closed by the recorder itself. New head
1c1f92f80.What changed. The holder takes the lock first and keeps it. The waiter waits for the word that says so, asks for the lock and blocks inside it. The recorder's own
standing()counter for that lock then says that the wait has been reached - the wrapper takes that counter before it waits (hooks.rs:52-58) - and only then does the holder start its hold of 30 ms. So the wait is the holder's hold and not the scheduler's: however late the machine wakes the waiter up, the wait is 30 ms.The counter is a hash of the address into 4096 slots (
record.rs:1422-1428), so another object can share the slot and the holder may see the wait before it is really there. The try is then made again, three tries at most, and the test fails only when none of them waited.The perturbations both of you used, on this head. The waiter asks for the lock 70 ms late (merzleckeier's delay) - and I put that delay on every try, not only the first: the test passes. The wait cannot be shortened by a late waiter any more, because the hold does not start before the recorder says the wait has begun.
The other hole the second review found is closed too. The wait that is measured is the one inside a try's own ticks (the ticks around the lock call), so the join - a wait of its own - and the first half's condvar wait cannot be mistaken for it. With a holder that keeps the lock for 1 ms, so the wait it measures is too short, the test now fails and says what the trace holds:
no try of the 3 waited on the lock for 10 ms or more: [Some(1.2785), Some(1.1458), Some(1.1336)] ms. Those are the recorded waits, not the wall clock around the lock call - the earlier message mixed the two up, which made it read as a contradiction.The 10 ms floor is a liveness floor, not a filter, and the comment says so: a wait of a few microseconds is the lock being free, and is not recorded at all.
@MoonEyes, on the in-game run. This pull request changes one test function inside
#[cfg(test)]ind3d12/crates/leonida-gpu/src/timeline/report.rs, and the whole diff is that one file. There is no product code in it: the recorder, the wrappers and the report are untouched, so nothing here can change what the title renders, and there is nothing in it for an in-game run to catch. The test itself only compiles with--features diagnostics(timeline.rs:42-47), so the default CI job does not build it either. If a maintainer still wants a run on this head, that is their call - I have no game files here.On this head: the test 20 of 20 runs; whole diagnostics suite 2 runs, 748 passed and 1 failed then 749 passed and 0 failed - the failure was
texture.rs's known parallel race (#2854), which passes alone and is not this test; default suite 668 passed, 0 failed; clippy says nothing in this file.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T18:00:25Z.
Code review of the new head
1c1f92f80(third round, pushed 17:29 UTC today; merge base0ae5a2664, merges cleanly into currentmain45dc41f95). Not built:leonida-gpu's timeline hooks are Windows-only. No CI run exists on this head yet; the Windows runs in this thread are on3f6545b0band6a674a118, not on this head.What changed in this round: the holder takes the lock, sets
taken, then spins onrecord::stood_at(object)(the recorder's per-objectSTOOD_ATcounter,record.rs:1426-1449, incremented byhooks::waitbefore the real wait,hooks.rs:52-58) before it starts its 30 ms hold. Three tries, the first one with a wait of 10 ms or more inside its own[at, locked]ticks must name the holder as waker. That removes the scheduler bet that @ecox982745 and @merzleckeier showed for the earlier heads: the hold only starts once the waiter is provably inside the wait.Points to check on Windows before merge
objectassumes the stdMutex's futex word sits at theMutex's own address.let object = &*lock as *const Mutex<()> as u64;is compared with the addresshooks::waitreceives, which for a contendedstd::sync::Mutexis the address of its internal futex passed toWaitOnAddress.std::sync::Mutex<T>is{ inner: sys::Mutex, poison: Flag, data }withoutrepr(C), so the field order (and thus whether the futex is at offset 0) is the compiler's choice, andplace()is a Fibonacci hash of the exact address, so a 1-byte offset lands in another slot. If it does not match, every try returnsNoneafter 2 s and the test fails with "the waiter did not reach the lock's wait". It passes for the author on 1.98.1, so it probably holds today, but it rests on std internals. A one-line note in the test, or derivingobjectfrom a recorded wait rather than from theMutexpointer, would make that explicit.TEST_GLOBAL_LOCK, the only other standing waits during the try are this test's own threads, so the retry is enough.Relation to #2933: both PRs fix the same flaky test (
real_waits_are_recorded_with_who_ended_them) under different claim IDs. #2933 still sleeps 50 ms after areadyflag that is set beforelock(), so its waiter can be descheduled between the flag and the lock: the same window this PR closes. Only one should land; this one is the stronger fix.Not run here. Before merge: one Windows run of
cargo test -p leonida-gpu --features diagnostics --lib timeline::report -- --test-threads=1and the full-parallel run on1c1f92f80merged ontomain, ideally repeated (it is a flake fix), plus the CI approval.Verdict: ready pending a Windows run on the current head (no defect found in the code; the open point is the std-layout assumption in 1).
AI-assisted verification: Claude Opus (Claude Code), separate agent per batch.
Generated by Claude Code
Imported from ubiquitarianism/leonida. Originally posted by Neutron-0 on 2026-12-02T18:07:58Z.
Fourth round: the roles are the stock ones again, and the wording now says only what the code does. New head
6934967a0.What changed since the last round. The test thread is the holder again, as in the original test: it takes the lock, spawns the waiter, and the waiter asks for the lock and blocks inside it. The recorder's
standing()counter for that lock says when the waiter has reached that wait, and only then does the holder start its hold of 30 ms. So:The key the test uses is the mutex's own address. A temporary probe showed that the recorded wait's
objectfield equals it exactly, and the selection now filters on that object, so a wait on something else cannot be measured by mistake.The waits are still three samples, not three retries: the counter is a hash of the address into 4096 slots and the recorder is process-wide, so another waiter or a timer can share the slot and the hold can begin before the waiter is really there. The test fails only when none of the three waited, and the failure message says how many samples the recorder reported at the lock's object:
Those are the recorded waits, not the wall clock around the lock call - the earlier message mixed the two up, which made it read as a contradiction.
The perturbations both of you used, on this head. The waiter thread starts 70 ms late (merzleckeier's delay) - I put that delay on every sample, not only the first: the test passes. The wait cannot be shortened by a late waiter any more, because the hold does not start before the recorder says the wait has begun.
On this head: the test 20 of 20 runs; whole diagnostics suite 2 runs, 749 passed and 0 failed both times; default suite 667 passed, 1 failed - the known
texture.rsparallel race (#2854), which passes alone and is not this test; clippy says nothing in this file.Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-02T22:01:13Z.
This pull request touches the render path, so it needs an in-game run before it can be merged: unit tests and CI do not catch rendering regressions (a device loss after an earlier merge is why this gate exists).
Could you, or anyone with a working setup, post a run report on the current head merged onto current
main:mainSHA it was merged onto;mainalone for comparison, if you can.Please do not attach logs or screenshots that show game content. If a run on this exact head is already posted, a link to it in a reply is enough.
AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by fiestorra on 2026-12-02T22:30:28Z.
VERIFY-3050 — Windows nativo: 15 pruebas del informe pasan, y la trampa de
diagnosticsotra vez(this PR)0ae5a2664(behindmainb41763227)main—merge-treeclean,git merge --no-ffcleanRan
The trap, recorded because it bit me twice tonight (#3005 was the other):
mod reportis#[cfg(all(windows, feature = "diagnostics"))](timeline.rs:46). Without--features diagnosticsthe module is not compiled, andcargo test -p leonida-gpu --lib reportanswers0 passed; 762 filtered outwith exit 0 — a verifier would record "no tests" for fifteen.What the change is: the stall-report test's worker wait is now a bounded one —
— so a worker that never signals fails the test in two seconds instead of hanging the suite, which is what the old blocking
waitdid. The contended-lock part of the test is reworked with it.Negative control (synthetic): I set the timeout to
Duration::ZEROso the wait expires at once:The assertion is live and its message is accurate — the worker does not finish within a zero-length wait. What I did not build is the honest other half: the unbounded wait with a worker that never signals, because that control hangs the runner (which is precisely the failure this PR removes) and needs a harness timeout to observe.
What I could not test
diagnosticssuite: 828 filtered out — only the report module was run under the feature.Written with an AI assistant.
Imported from ubiquitarianism/leonida. Originally posted by MoonEyes on 2026-12-03T00:38:29Z.
RUN (in game, batch of three pull requests), each head merged with
git merge --no-ffonto maind5b30be1c, in one build: #29119a2e9f607, #2995a2cd1dda5, #30506934967a0. RTX 4060 8 GB, driver 610.88, Windows 11. Series S,-Resolution 1080, frame generation 2x,-PrecompileUsed, the same walking route as the other runs on this machine, 330 s after reaching the world.For reference, the same machine and route rendered 13.3 to 17.2 fps on other batches in the last day. These fps are a check that nothing fell over, not a measurement of a gain.
Verdict: PASS for the in-game gate (300 s or more in the world, no device loss) for this batch, on the heads listed above. If one of these pull requests changes its head, this run no longer covers it.
Limits: one run; arrival in the world was driven by keys and not checked on pictures;
-PrecompileUsedwas used, so the default start (every known pipeline precompiled) was not exercised. #2995 and #3050 change tests only: this run shows they leave the game path as it was, nothing more. #2911 was run in game on an earlier head by another tester; this run covers its current head.AI-assisted (Claude Code).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T00:59:28Z.
Review: COMMENTED
I rebuilt
6934967amerged ontod5b30be1with Rust 1.98.1 and Windows MSVC, then ran it under Wine 11.22 with the original adjacent PDB. All sixtimeline::report::tests::tests passed on the unmodified source, including the symbol-name and waker assertions. In a disposable copy, delaying every waiter by 70 ms beforelock()also passed 3/3. The subsequent #3230 merge to1a163523changes the launcher, docs and launcher tests. The #3050 merge remains clean and its Rust sources and Cargo inputs are identical across those two bases.One remaining case is reproducible. I used the same delay and held a
record::standing()guard for a different synthetic object in the same bucket for all three samples. It failed 3/3 with recorded lengths["-", "-", "-"], while the diagnostic reported the waiter at the object in all three samples. Each sample uses the same mutex address and therefore the same bucket. A single long-lived collision can make all three holds start before their waiter reaches the lock.This is a test-only false negative under the forced collision. A test-only per-waiter signal from the actual
standing()call would make the handshake independent of the shared bucket and preserve the existing trace assertions. All probes were synthetic. AI-assisted with OpenAI Codex.Imported from ubiquitarianism/leonida. Originally posted by Neutron-0 on 2026-12-03T05:42:36Z.
Windows run report on the current head (
f95dc3224), as asked.f95dc3224. It merges cleanly into the currentmain45dc41f95(git merge-treewrites a tree with no conflict; the branch's base is0ae5a2664).d3d12/rust-toolchain.tomlpins). No GPU and no game files are used by this test: it is the diagnostics recorder's own test, on the CPU.cargo test -p leonida-gpu --features diagnostics --lib timeline::report -- --test-threads=1: 6 passed, 0 failed, 59 ignored, 1.20 s.cargo test -p leonida-gpu --lib --locked --features diagnostics):descriptor::tests::records_copied_as_bytes_are_made_at_the_next_sync, the known parallel race indescriptor.rsthatD3D12-GPU-TEST-PARALLEL-FLAKEScovers (claimed by lixonik); it is not this test6934967a0, the same test with only the note below added since): four runs clean, one with the knownwatch.rsrace (watch::tests::a_write_opens_the_view_it_goes_through, the same item). Ten parallel runs in all, and this test failed in none of them.On your point 1 (the std-layout assumption). The head now filters the measured wait on the recorder's own object, so a different layout cannot be measured by mistake, and the failure message says how many samples the recorder reported at the lock's object - none of them if the key is wrong. The assumption is written down in the test as well:
About the in-game run in your first comment: this pull request changes one test function inside
#[cfg(test)]ind3d12/crates/leonida-gpu/src/timeline/report.rs, and the whole diff is that one file. There is no product code in it - the recorder, the wrappers and the report are untouched - so it cannot change what the title renders, and there is nothing in it for an in-game run to catch. The test only compiles with--features diagnostics, so the default CI job does not build it either. I have no game files here, so I cannot post a run in the world; if you want one on this head anyway, that is your call.Imported from ubiquitarianism/leonida. Originally posted by Neutron-0 on 2026-12-03T06:09:50Z.
Head moved to
856320528- the only changes since the head MoonEyes ran in game (6934967a0) are three comments and the wording of one assertion message; no code path changed.report.rs:1457-1460: the note on the recorder's key for the lock (the one MoonEyes asked for).report.rs:1473-1475: the comment on the two-second bound now says what is true - a waiter that never arrives is reported as not reached instead of hanging the spin, and the join below still waits for the waiter to finish, which it does once the lock is released.report.rs:1521-1522: the failure message now says "the recorder's counter saw the waiter's key in N of them" instead of "the recorder reported the waiter at the lock's object in N of them" - in the case where the standard library's layout moves the wait primitive, the recorder did record the wait, just under another key, so the old wording was not exact.Those are the two optional findings of the fifth review round (GLM-5.3 Flash via NVIDIA, verdict PASS-with-nits, no must-fixes). The third optional finding (a named struct instead of a 4-tuple) and the fourth (the 4096-slot table can make
released()record a phantom wake) are test-local and deliberately left alone; the second is inrecord.rs, which this pull request does not touch.Windows run report on
856320528856320528. It merges cleanly into the currentmaind9b618f10(git merge-treewrites a tree with no conflict; the branch's base is0ae5a2664).d3d12/rust-toolchain.tomlpins). No GPU and no game files are used by this test: it is the diagnostics recorder's own test, on the CPU.cargo test -p leonida-gpu --features diagnostics --lib timeline::report -- --test-threads=1: 6 passed, 0 failed, 59 ignored, 1.19 s.cargo test -p leonida-gpu --lib --locked --features diagnostics):texture::alias_cast_tests::committed_and_placed_r32_uint_textures_cast_to_r9g9b9e5_under_legacy_barriers, the parallel race #2854 fixes; it is not this testWith the five runs on the previous head and the five before that, fifteen parallel runs of the suite over three heads of this branch, and this test failed in none of them. The three failures were each a different known parallel race in this crate (
descriptor.rs,watch.rs,texture.rs), all claimed elsewhere -D3D12-GPU-TEST-PARALLEL-FLAKEScovers the first two and #2854 the third.Imported from ubiquitarianism/leonida. Originally posted by Neutron-0 on 2026-12-03T12:57:11Z.
@merzleckeier - the case you forced is fixed in the new head, and your probe is what shows it.
What you forced. A
record::standing()guard for a different object in the same bucket of the recorder's table, held for the whole test, and a waiter 70 ms late. Every sample used the same mutex, so every sample shared one bucket: the holder's hold began before the waiter was really inside the wait, and the test failed 3 of 3.What changed. Each sample has a lock of its own now:
The recorder's key is computed per sample, and the trace filter uses that sample's key (
w.object == *object). The three locks are alive at the same time, so their addresses differ and their buckets differ. A collision of your kind now reaches one sample and not all of them, and the test fails only when none of the samples waited.Your probe on both heads. The probe is a test-only change: a standing guard for a different object in the same bucket as the first lock, held for the whole test, plus the 70 ms delay on the waiter.
856320528: FAILED,no sample of the 3 waited on the lock for 10 ms or more: ["-", "-", "-"] ms; the recorder's counter saw the waiter's key in 3 of them- the same shape you reported.47d95f543: ok, 5 of 5 runs.On the per-waiter signal you propose. A signal from the actual
standing()call is the clean fix, but it has to come from the recorder:record::standing()counts per hash bucket, and only the recorder knows which thread stood there. Making it per waiter is a change inrecord.rs, which is not test code, and this pull request is test-only on purpose - that is what keeps @MoonEyes's in-game gate on solid ground ("nothing in it can change what the title renders"). I did not want to widen this pull request's scope for it, so I made the samples independent of each other instead.If you want the recorder-level signal, say so and I will do it as a separate pull request: a
d3d12:one, with the recorder change and a test of its own.On the head.
47d95f543is the new head. Since the head @MoonEyes ran in game (6934967a0) the changes are three comments, the wording of one assertion message, and this per-sample-lock change - still only test code, and the whole diff is still the one file.Evidence on the new head (Windows 11, AMD 780M iGPU, Rust 1.98.1; no game files and no GPU are used by this test):
cargo test -p leonida-gpu --lib --locked --features diagnostics timeline::report::tests::real_waits: 20 of 20 runs ok.cargo test -p leonida-gpu --lib --locked --features diagnostics): 3 runs - two clean, 749 passed and 0 failed, 59 ignored each, and one withwatch.rs's known parallel race (watch::many_askers_tests::no_mapping_is_lost_between_askers, claimed underD3D12-GPU-TEST-PARALLEL-FLAKES), 748 passed and 1 failed. This test failed in none of them.cargo clippy -p leonida-gpu --lib --features diagnostics --tests: nothing in this file (the crate's 10 warnings are in other files, on this old base).AI-assisted: yes (MiniMax M3.1 Flash via OpenCode wrote the change; separate read-only review agents audited it).
Imported from ubiquitarianism/leonida. Originally posted by merzleckeier on 2026-12-03T12:58:27Z.
Thanks, the test-only change resolves my review point. I rechecked
47d95f54onmainb053a181with Rust 1.98.1 targeting Windows MSVC under Wine 11.22. The unmodified build passed all 17 timeline tests, including the symbol-name and waker assertions.For the collision, I built a separate test copy of each head on the same base. One synthetic object occupied the first lock’s recorder bucket. In any sample where that bucket was already occupied, I held the waiter until after the holder released its lock. This makes the false signal deterministic without relying on a fixed startup delay.
6934967a: all three samples saw the occupied bucket and the original assertion failed in 3/3 runs.47d95f54: only the first sample saw the occupied bucket. The existing assertion found a wait of at least 10 ms and attributed it to the correct waker in 5/5 runs.These runs exercised the CPU diagnostics on the current head. AI-assisted (Codex).
Imported from ubiquitarianism/leonida. Originally posted by Neutron-0 on 2026-12-03T17:25:00Z.
The three workflow runs on this head are waiting for a maintainer's approval. They are
action_required- a fork run of a first-time contributor waits for one: 47109751347 (CI), 47109751317 (No Game Data) and 47109751091 (D3D12 runtime), all on head47d95f54.The same workflows ran on this exact head in the contributor's fork, where no approval is needed, and they are green:
checksuccess,linux-python-and-viewersuccess,semantic-testssuccessno-game-datasuccessd3d12 (windows-latest)successchange-scopeis the one job that cannot be produced that way: it only runs on apull_requestevent (ci.yml:34), so it needs the approval itself.@merzleckeier has re-verified this head independently: the unmodified build passes all 17 timeline tests on
mainb053a181with Rust 1.98.1 targeting Windows MSVC under Wine 11.22, and the probe that forces the recorder's bucket collision fails 3/3 on the old head and passes 5/5 on this one.Approving the runs (or merging) would let this account open its next pull request: GitHub allows it one open pull request while it is a first-time contributor, and this one holds the slot.
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.