Repository navigation
D3D12-TIMELINE-REPORT-WAKER-ISOLATION: synchronize thread startup in timeline::report wait test - #2933
Conversation
|
Controlled second-worker scheduling check at
The failures had no matching waker. Delayed startup no longer consumes the holder’s wait window. The deliberately injected stall after |
KelboLive
left a comment
There was a problem hiding this comment.
Diagnosis and fix both hold up. At 4× oversubscription the parent commit failed this test in 10/24 suite runs (report.rs:1455 "no entry found for key"; :1459 None vs Some(tid)); this branch is 0/24 at 4× and 0/16 at 8×, and 20/20 on the exact timeline::report filter. The flags are sound: one store, acquire load, no lost wakeup, no lock-order issue, and yield_now prevents starvation.
It narrows rather than closes, though: ready is still published before lock.lock() (:1453-1454), so a stall after publication is covered only by the fixed 50 ms hold (40 ms above the 10 ms filter). I injected 60 ms there and it fails 3/3; 60 ms after waiting.store fails the work assertion 2/2. The fix removes the startup-latency charge against the window — which is the real runner behaviour it was fighting — but a scheduling stall inside the window still flakes.
Two suggestions:
- Drop the
>= 10 msduration filter (:1475) and assert on the wait that ends at the release (the last wait ofsecond) and its waker. That removes one avoidable failure mode and tests the property rather than a duration. - Prefer a
std::sync::Barrierover theyield_nowspin (:1416): if the test thread panics beforewaiting.store(:1437), the worker spins forever (libtest still exits, but it burns CPU). The pre-existinggate.1.waitalready has that hazard; a barrier would remove the class.
The .get(&second).into_iter().flatten() change is a strict improvement over the index panic either way. Merge-tree against current main is clean, and #2884 is complementary (different test, same thread-startup class, mutually exclusive via TEST_GLOBAL_LOCK).
Claimed in the coordination issue as: D3D12-TIMELINE-REPORT-WAKER-ISOLATION (#2570 (comment); ref finding #2570 (comment))
What and why
timeline::report::tests::real_waits_are_recorded_with_who_ended_them(d3d12/crates/leonida-gpu/src/timeline/report.rs) intermittently failed under parallel whole-suite runs (reported 3/40 onmain) because it assumed newly spawned threads reached their synchronization points within fixed sleeps:secondwas spawned while the test thread heldlock, slept a fixed 20 ms, and droppedlock. Under parallel test contention, thread creation/startup could consume >10 ms sosecondeither waited less than the 10 ms filter or never contended at all (contended == None).workerstarted its timed work span immediately on spawn without waiting for the test thread to acquiregate.0and entergate.1.wait.Fix:
workerwith an unhookedAtomicBool(waiting) set while holdinggate.0, then sleep 10 ms before starting the 40 ms timed span sogate.1.waitoverlaps the full span.secondwith an unhookedAtomicBool(ready) set immediately beforelock.lock(), and holdlockfor 50 ms afterreadyis observed so slow thread startup cannot eat the 10 ms wait filter.trace.waits.get(&second).into_iter().flatten()instead of direct map indexing.Tested
cargo test --locked -p leonida-gpu --lib --features diagnostics timeline::report::tests: 6 passed, 0 failed.leonida-gpulib suite (--features diagnostics -- --skip depth_bounds_pipeline_loads_and_filters_draws), 15 consecutive runs: 15/15 passed, 0 failures inreal_waits_are_recorded_with_who_ended_them(724 passed, 0 failed, 59 ignored per run).python -I scripts/check_no_game_data.py d3d12/crates/leonida-gpu/src/timeline/report.rs: clean.GPUs tested: n/a (CPU-only timeline hook test; Windows 11).
AI-assisted: yes — Gemini 4 Neon (implementation and an independent read-only reviewer pass).
Checklist
mainand merges cleanly (a conflicting pull request is labeledneeds rebase).