D3D12.X: follow the GPU through each queue's submits from the progress fence #3673
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3673"
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-12-02T05:54:44Z.
Requested by Prime
At a device removal the log did not say which submit the GPU was on. The "recorded last" report comes from a ring written when work is recorded, and the title keeps recording for the ~2 s of the TDR, so the newest frames in it are ones the GPU never ran. The private progress fence that
list_x::note_submittedalready signals after each chunk of the title's work now tells us. The watch thread reads those fences ten times a second. Each finished submit gets a service time: how long the GPU was on it, without the time it waited behind earlier work. Once a minute a line per queue gives the minute's submits, median, p99 and slowest service time beside the video memory in use. At a removal a line per queue names the oldest unfinished submit, the frame it was sent in, how long the GPU had been on it and the last 16 service times. No new fence and no new Signal.Related: #1189 snapshots queue progress when a title stops presenting (opt-in
XCL_STALL_SECONDS); this one reads the existing progress fences all the time and reports at a device removal.What is in it
crates/xcl/src/hle/d3d12x/gpu_progress.rs(new): the poll, the service times, the minute lines and the report at a removal, with unit tests.crates/xcl/src/hle/d3d12x/list_x.rs: the progress records carry the frame they were sent in;progress_sincehands them out with the lock only tried;progress_summarykeeps the unfinished records when a removed device's fence reads u64::MAX.crates/xcl/src/hle/d3d12x/watch.rs: the watch thread polls before it looks for a removal.crates/xcl/src/hle/d3d12x/real.rs: the removal report is written before the "recorded last" report.crates/xcl/src/hle/d3d12x/mod.rs: the new module.Tested
1c8b5514):cargo check -p xcl --lib --tests --target x86_64-pc-windows-gnupasses. The test suite was not run on this exact branch.Regression run
Not tested
scripts/smoke.ps1on this branch; AMD.XCL_GPU_WATCH=0there is no watch thread, so nothing is polled and the removal report says so.Switches
XCL_HANG_SUBMITS(default on):=0polls, keeps and logs nothing.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T09:17:36Z.
Review (head
26083e48, diff read, not a merge-check; checks red):scripts/pr_check.pyneeds suite counts under Tested and twoxcl-smokeblocks (main and this head) under Regression run. The description has neither: onlycargo checkfor the gnu target, and "Not run yet". The feature is on by default (XCL_HANG_SUBMITSunset = on), so it needs that evidence.gpu_progress.rs ~92-103(finish), the first submit a poll sees done getsnow - max(sent, previous done_at), and every other submit finished in the same poll gets 0 (the unit test at ~285 expects this: "the third ... 0"). Take 60 fps with six 2 ms submits per poll: each poll gives one ~90 ms time and five 0s. The line then reads "median 0 ms, p99 ~90 ms", which describes the polling and not the GPU. Only times well above 100 ms mean anything. Either say so in the line and the docs, or report only submits longer than the poll interval.list_x.rs ~5458,wait_all_on), holds that Signal back. On a queue held by another queue's fence, the oldest unfinished submit is waiting, and "GPU on it for N ms" (gpu_progress.rs ~241) counts that wait as GPU work. The removal line should say it can be waiting, or the lines should be read together with the wait edges.push_bounded(gpu_progress.rs ~82) andnote_submitted's ring (list_x.rs ~2348) both keep 4096 and drop the oldest. If more than 4096 submits reach a queue between the hang and the removal, the hung submit is gone.oldest_unfinishedthen names a later one with no warning. A gap (front.seq > done + 1) would show this and could be logged.progress_sinceandcopy_new: thetake_while(seq > copied)walk and thecopiedbookkeeping. Nothing tests the change thatprogress_summaryno longer pops records when the fence reads u64::MAX (list_x.rs ~2398). The second is the one real change to existing code.Fine: diagnostics only, with no new fence and no new Signal. The sequence numbers are per queue and monotonic: they are assigned and signalled under
PROGRESSinsidequeue_submit::with, and they are u64. The submit path gains one relaxed atomic load and 8 bytes per record. The watch thread onlytry_locksPROGRESSand reads the fences with no lock held. Memory is bounded at 4096 records per queue, and the per-minute vector is drained when its line is written. No textual conflict with #3674, which is complementary. Its per-queue creation line names queues by raw address, though, while these lines useq<id>, so the two cannot be matched in a log.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-02T10:06:55Z.
Test report (not a merge-check:
PR descriptionred)base:
1c8b551475head:
26083e486fmerge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2913 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: read by one reviewer at this same head; the review is at https://github.com/xcl-dev/xcl/pull/3673#issuecomment-7340666607 and its findings stand. Most serious: a default-on diagnostic whose per-minute median and p99 measure the 100 ms poll, not GPU time.
performance: 60 s smoke of a retail title, main
1c8b5514vs this merge (26083e48): 1652 -> 1678 frames shown (101 %; last presents per 2 s: 60 61 60), peak commit 18228 -> 17406 MB, 0 device removals, 0 crashes.assessment: merges, builds and passes the whole suite on current main, and the smoke run is clean; the blocking point is in the review: a default-on diagnostic whose per-minute median and p99 measure the 100 ms poll, not GPU time
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.
Imported from ivall/xcl. Originally posted by Gevroska on 2026-12-02T10:46:44Z.
I tested the timing concern on
26083e48using the PR’sgpu_progress.rswith synthetic fence values. In one control, a dependency held the queue until 170 ms, the work finished at 172 ms, and the next poll saw it at 200 ms. The observer reported 200 ms for 2 ms of simulated execution. In another control, three completions seen in the same poll produced100 / 0 / 0 msfor two different execution schedules.I’d label the metric time between observed completions and include the polling interval next to it. A positive fence observation is useful evidence that the queue advanced. The interval includes both dependency waits and the delay before the observer polls again.
All four upstream tests and four additional controls passed in two independent runs. These were Windows CPU tests with synthetic inputs. OpenAI Codex GPT-6.2 Sol ran the tests, a separate GPT-6.2 Sol agent repeated them, and GPT-6.2 Astra drafted this comment.
I reviewed and approved this comment before posting.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T15:46:03Z.
merge-check
base:
16c2fd082ahead:
26083e486fmerge: clean
build: ok
tests: 3016 passed, 0 failed, 56 ignored; 28 skipped, the same as on main
review: 1 high, 3 medium, 1 nit (below)
performance: 60 s smoke run: 1683 → 1667 frames (99 % of main), peak commit 18505 → 18178 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 232 s there, 0 device removals, 0 crashes, 2.6 presents/s; run with
XCL_SKIP_CS=95cc13288a27a96e(the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)verdict: not yet: 1 blocking finding (critical or high, below); also
PR descriptionis redhardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5
In short: Reads each queue's existing progress fence from the watch thread ten times a second, logs per-minute service times per queue, and at a device removal names the oldest unfinished submit per queue. The head has not moved since my earlier review and test report. The removal report is useful, but the per-minute service times it logs by default measure the 100 ms poll, not GPU time, which blocks it.
High
Medium
Nit
Checked and fine
How this was tested
16c2fd08, thencargo build --workspaceandcargo test --workspace --no-fail-fast -- --test-threads=4.scripts/smoke.ps1: 60 s of a retail title on main16c2fd08and on this merge; presents per 2 s at the end: 61 60 60.XCL_RUN_SECONDS=300and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.Written by Claude Code (Claude Opus 5.5) 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.