D3D12.X: recycle driver timing slots after thread exit #3107
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3107"
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 ivall/xcl. Originally posted by Prime1997 on 2026-11-28T07:13:28Z.
Driver-call timing now releases its slot when a thread exits. The NVIDIA branch previously assigned 64 slots over the entire process lifetime, so later threads silently lost timing and the full-suite timing assertion failed.
Rebased onto main (2026-11-28).
nvidia-devwas merged intomainby #3203, so this PR now targetsmainand its branch was rebased ontomain765b2c5bfff6754e8c9886a73e188a86aca3c64c: headc08bd75d4e246a223baef36e3c2c40313514dfa7(was95119afe19105b4800ffc4e6d6f007c5f69dc564). The only conflict was the README.md bullet. On the rebased head, on the same RTX 3060 Ti PC, debug profile:cargo check -p xcl --all-targetsexited 0, andcargo test -p xcl --lib -- --test-threads=4 a_driver_snapshot_never_combines_two_calls a_nested_driver_guard_does_not_end_a_later_outer_call an_outer_driver_guard_keeps_its_lease_after_the_tls_owner_drops driver_timing_survives_more_than_64_exited_threads exhausted_driver_slots_can_be_claimed_after_release simultaneous_driver_slot_claims_are_distinct the_ring_holds_what_was_noted_last d3d12x::watchgave 15 passed, 0 failed, 0 ignored, no SKIPPED. The whole suite and the paired title runs have not been rerun on this head; every other result below is from the earlier head. The rebase and its conflict resolution were done with Claude Code.What is in it
e429936chas nowatch.rstiming registry. Open/draft searches found no matching slot repair. #3018 reports the same test failure but changes DXC compilation, not slot ownership.Tested
cargo test --locked -p xcl --lib --target-dir <isolated-target> --no-runpassed for both controls.54225f58plus onlydriver_timing_survives_more_than_64_exited_threads: 0 passed, 1 failed, 0 ignored, 1,806 filtered; no SKIPPED messages. The unchanged API stopped timing at thread 64.cargo test --locked -p xcl --lib --target-dir <isolated-target> hle::d3d12x::watch::tests:: -- --nocapture --test-threads=1: 15 passed, 0 failed, 0 ignored, 1,797 filtered; no SKIPPED messages.a_thread_in_the_driver_is_seen_until_it_returns, after diagnostic-slot exhaustion.Regression run
Pending paired clean-head main/PR title runs; no smoke block claimed.
Not tested
AI use
Codex (GPT-6) diagnosed the baseline failure, checked overlap, implemented and independently reviewed the repair, ran the focused controls/tests and prepared this PR.
Optional temporary Discord for coordinating contributor work, testing and comparing results: https://discord.gg/6B4TykyC4W
Imported from ivall/xcl. Originally posted by JJAutoCompare on 2026-11-28T07:37:57Z.
Tested
Exact
95119afe19105b4800ffc4e6d6f007c5f69dc564on Windows 11 x64 build 26200.9974, Ryzen 7 3800X, Rust 1.100.1 MSVC debug. The pinned executable used a verified Git archive with one private test inserted inwatch.rs. All 386 original Git blobs matched after excluding the fixture.I ran
<libtest.exe> <filter> --exact --nocapture --test-threads=1for each CPU test.hle::d3d12x::watch::tests::a_recycled_driver_slot_preserves_the_other_live_snapshotrecorded Execute in slot 0 and Present in slot 1. Slot 0 went idle after the first thread joined. A third thread reused it with its own active Present record while the live record in slot 1 kept the same timestamp, call kind, and thread ID.hle::d3d12x::watch::tests::a_thread_in_the_driver_is_seen_until_it_returnspassed.2 passed, 0 failed, 0 ignored, 0 runtime skips. Both native processes exited 0, with 1,812 filtered out per invocation.
Not tested
Real driver calls, GPU execution, the base revision, performance, retail smoke, or the full suite.
AI use
T3 Code through the Codex harness (
gpt-6.2-sol) verified the source and executable, reran the tests, and wrote this report.Imported from ivall/xcl. Originally posted by vasanex on 2026-11-29T04:23:24Z.
How this was run: the suite ran once on the 11 of your PRs that build on this base, merged together (#3047 #3048 #3049 #3091 #3092 #3103 #3104 #3105 #3107 #3123 #3125; a local tree, only #3125 needed a resolution in README and the
sparse.rstest module); the base alone gave 2608 passed, 0 failed, 49 ignored with the same 27SKIPPEDlines (21 no wave64, 3 refused per-lane f16/f32 forms, 2 heap windows opt-in, 1 driver cache needs Developer Mode). This PR alone was merged onto the base, built (cargo build --workspace, then release), its modules' lib tests run (debug), and smoke-run once for 60 s (scripts/smoke.ps1, retail title, front end,XCL_PREPARE=0). The smoke numbers are for my local merged tree, not a clean-head block for the description.AI use: Claude Code (Claude Opus 5.5 and Claude Fable 5.2) ran the builds, tests and title runs, reviewed the diff and wrote this; the code points cited were checked against the merged tree.
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T22:38:33Z.
merge-check
base:
beeb81be4b(mergeable cleanly on current main)head:
c08bd75d4emerge: clean
build: cargo check -p xcl --all-targets -> ok
tests: non-GPU lib tests of touched module (watch 15 passed, including 65-thread slot reuse test). Full workspace suite and GPU tests not run.
review: none blocking. Slots are leased per thread via Rc lease and returned on thread exit; versioned records (odd = writing) prevent torn reads.
performance: a few SeqCst stores per timed driver call; no overhead seen. Tested in a combined 600 s retail run on main
beeb81be+ 13 PRs (warm cache, defaults) vs baseline: presents/2 s 3.27 vs 3.29, peak commit 35,016 vs 35,767 MB, local video memory 14.19-14.76 vs 14.32-14.95 GB, 0 pipeline waits >= 1 s vs 5, 0 device removals, 0 crashes. Combined result across all 13 PRs, not isolated to this PR.verdict: not yet: full workspace suite not run on its own merge.
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti, driver 32.0.16.1074, AMD Ryzen 9 9950X, Windows 11 Pro 26200 / Claude Code (claude-opus-5-5)
Imported from ivall/xcl. Originally posted by bmjask on 2026-11-29T22:44:18Z.
Review: COMMENTED
Critical review of current head
c08bd75d. I found no ownership blocker in the per-thread timing-slot lease: the slot is returned on thread exit and the lease keeps an outer call valid after the TLS owner drops. The important remaining coverage is concurrent churn with more than 64 short-lived threads while one outer guard remains active; the included tests address the isolated cases, and existing Windows reports show them passing. Keep the no-slot fallback observable so timing data loss is not silent if all 64 slots are simultaneously occupied. No local Windows run; nonblocking review.Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T05:33:02Z.
Review (head
c08bd75d, diff read, not a merge-check; draft, so not built or run):PR checksrequires for a runtime change. AI use says "Claude Code" for the rebase without naming the model.a_driver_snapshot_never_combines_two_calls(watch.rs~751) writes start times 11 and 22 into a real global slot; if a GPU test in the same process has startedxcl-gpu-watch, that thread logs a stalled driver call and a report. Noise, not a failure, but a private slot would avoid it.e429936chas no watch.rs timing registry" is out of date.Fine: slots are claimed with an atomic compare-and-swap and released only after the thread-local lease and any active call guard are gone and the slot is cleared; a version counter stops the watch thread from pairing an old call's time with a new thread's id;
try_withavoids a panic during thread-local teardown; nested calls stay untimed.driver_timing_survives_more_than_64_exited_threadsfails on main, which never reuses a slot. The added cost is a few atomics per ExecuteCommandLists / Present (a thread killed with TerminateThread keeps its slot, as on main).AI review: Claude Code (Claude Opus 5.5), posted by Foniass without a human check of each point.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T17:01:50Z.
Test report (not a merge-check: draft,
PR descriptionred)base:
b2b1f109d2head:
c08bd75d4emerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2908 passed, 0 failed, 51 ignored; SKIPPED: 28 (20 no wave64, 2 no d3d12SDKLayers.dll, 1 no D3D12 debug layer, 1 no heap windows, 1 cannot disable the driver cache, 3 others; the same set as on main); failing: none
review: not repeated here; my review of this same head is at https://github.com/xcl-dev/xcl/pull/3107#issuecomment-7301887863, and its findings stand. This run adds what reading couldn't: whether the change merges, builds and passes the whole suite on current main.
performance: no smoke run.
assessment: merges, builds and passes the whole suite on current main (0 failed, its new tests included); the findings in my review stand
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
AI-written and posted by Foniass without a human check of each point.
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.