D3D12.X: with XCL_LOOK_STATS=2 split a present's time on the submitter #2955
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/2955"
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 thisguyStan on 2026-11-27T04:43:17Z.
Part of #2688 (workstream 8). Targets
main(b38197ae).In the world, presents take most of the submitting thread's time on NVIDIA (93 % on an RTX 4080 in #2729), but
calls of the submitting thread (2 s)shows a present as onepresentsentry, with only its wait for frame N−2's copy apart. WithXCL_LOOK_STATS=2, like that wait, this adds four entries:PRESENTX_LOCK,PRESENTER),Signal,Present(a GPU-bound frame waits there),XCL_FRAME_DUMP,XCL_DUMP_TARGETS).The rest of
presentsis the plane checks, the frame-rate line and the device-removal check. When the fallback presents on a submission (no PresentX), the parts run insideExecuteCommandLists, as the copy wait does. Like it, they are sub-calls (is_sub_call, #2729), socompletedcounts each present once.XCL_STALL_TRACEtimes only the swap chain'sPresent. Diagnostics only: no change with the switch off.What is in it
crates/xcl/src/hle/api_cost.rs: the four entries, their names inCALLSand inis_sub_call, and a test that a present is counted once.crates/xcl/src/hle/d3d12x/present.rs: the timers around the two lock waits, the recording and submit,Presentand the frame-dump wait.Tested
rustc 1.100.0, DXC 1.9.2602.17; tests in debug, smokes in release.cargo test --workspace --no-fail-fast -- --test-threads=4on80e2ee45(this PR onmain7db2f391): 2595 passed, 0 failed, 49 ignored. The head2aeec61cis the same patch rebased ontob38197ae(git range-diff: unchanged); the suite was not rerun on it.nvidia-dev(merged intomainsince). The timers are the same. Onmain, the present's copy is submitted without XCL's look at the title's memory, so the recording part should be smaller there.scripts/smoke.ps1on1a6ddc2c(release; the same code asdd85383e) withXCL_LOOK_STATS=2,XCL_PREPARE=0, 60 s in the intro and menus (1354 frames, no device removal, no crash). Everycalls of the submitting thread (2 s)line (from 12 s on) has the new entries. From 14 s on, the parts add up to thepresentsentry within 0–4 ms per 2 s (the rest of a present); the first present (12 s) took 51 ms, of them 1 ms in the parts. From 26 s on, every 2 s:XCL_FRAME_DUMP): that entry is not printed.dd85383ewithXCL_LOOK_STATS=2,XCL_ACTIVITY=1,XCL_PREPARE=0, played past the intro, were stopped as the world loads by a device removal (0x887a0005, no DRED breadcrumbs) and then the title's breakpoint at the same address (at 228 s and 114 s). its base then,ecc0bb57(nvidia-dev, now part ofmain), with the timers off stops the same way (223 s), so the world itself was not reached. In the first run, while the world loaded (178–226 s, 9–13 fps), every 2 s:presentswithin 0–4 ms,ExecuteCommandListstakes 57–1005 ms.Regression run
60 s runs of
scripts/smoke.ps1(JIT path: the script setsXCL_PREPARE=0) on the same title, with no pipeline cap. Each ran on its own copy of onemainshader cache.mainis this PR's base (b38197ae).XCL_LOOK_STATSwas unset, so these runs show the switched-off path.main(b38197ae):This PR (
2aeec61c):Not tested
ecc0bb57, onnvidia-devbefore its merge) stopped with a device removal as the world loads (above), so the split in the world is not measured here. The timers-on runs were not repeated onmain.XCL_FRAME_DUMP,XCL_DUMP_TARGETS) and the composite path of a present.AI use
Imported from ivall/xcl. Originally posted by ettehn on 2026-11-27T04:51:48Z.
One accounting detail for the #2729 integration, checked at
1a6ddc2c. The submission-driven fallback callspresent_nowdirectly, so it emitsPresentRecordandPresentSwapwithout an enclosingCall::Presentsample. It runs inside the enclosingExecuteCommandListstimer. Those samples belong toSubmiton that route and toPresenton the boundary route. In both cases, #2729’s non-overlapping total should treat them as sub-calls.A standalone Windows x64 fixture compiled this head’s
api_cost.rsand fed it the fallback sequence. It reportedPresent=0,PresentRecord=12 ms,PresentSwap=20 ms,Submit=40 ms. The durations are fixture inputs. This checks the counters and the source call sites. If the new metrics are meant to break downpresents, a route guard or separate fallback labels would keep that interpretation accurate.OpenAI Codex assisted with verification.
Imported from ivall/xcl. Originally posted by thisguyStan on 2026-11-27T06:05:02Z.
Thanks, that's right: on the submission-driven fallback
present_nowruns insideExecuteCommandLists, so its parts land inSubmit, not inPresent. The copy wait already did the same. I kept the timing as it is. APresenttimer around the fallback would count the same time in both entries, andCall::Presentdeliberately covers only PresentX and the console-method fallback. Instead,dd85383esays it in the doc comment on the entries, the commit message and the description. For #2729's non-overlapping total, all four new entries belong inis_sub_callalong withPresentCopyWait, on both routes. That's in the description too, for whichever PR lands second. (Claude Code with Claude Opus 5.5 checked the call sites.)Imported from ivall/xcl. Originally posted by LocranKing on 2026-11-27T12:21:02Z.
Tested PR #2955 (
dd85383e) on Windows 11 in a180 sopen-world run withXCL_LOOK_STATS=2to cover the open-worldPresentXbreakdown noted under Not tested.Environment
32.0.16.2140)nvidia-devDXIL cache (XCL_DIRECT_DXIL=1,XCL_HEAP_WINDOWS=1,XCL_TEXTURE_LEVEL_PAGES=1,XCL_PREPARE_GRAPHICS=0,XCL_DRED=1,XCL_LOOK_STATS=2), Series S (lockhart) profile.180 sOpen-World Run (XCL_LOOK_STATS=2)exit: 0x0,0crashes,0device removals,1760frames (PresentX 1760), heavy world draws began at108.55 s, peak commit29509 MB, peak local VRAM10279 MB, peak non-local4982 MB.calls of the submitting thread (2 s)breakdown:ExecuteCommandListswaits for pipelines being builtpresentstotalwaits of a present for the one beforewaits of a present for the last frame's copycopies of a present recorded and submittedswap chain Presents180 srun874686(76,902 ms)64(3,226 ms)1760(32,086 ms)3520(0 ms)1760(0 ms)27,148 ms(84.6%)4,818 ms(15.0%)t >= 100 s)471382(50,349 ms)64(3,226 ms)108(25,543 ms)216(0 ms)108(0 ms)22,895 ms(89.6%)2,624 ms(10.3%)World observations
t >= 100 s),presents(25,543 ms) accounted for ~33.6% of{ExecuteCommandLists + presents}submitter call time (75,892 ms), andcopies of a present recorded and submitteddominatedpresentsat89.6%(22,895 msacross108presents), withswap chain Presentsat10.3%(2,624 ms) and lock/copy waits at0 ms(residual remainder24 ms/0.1%).2172 msfor2presents (2167 msincopies of a present recorded and submitted,4 msinswap chain Presents, at144.993 s) and1654 msfor1present (1653 msincopies of a present recorded and submitted, at187.661 s).Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-28T01:50:00Z.
I rebased #2955 head
dd85383elocally onto currentnvidia-devba9d1f94. The only textual conflict is theCALLSarray size inapi_cost.rs: the base has 20 calls after #2729, and this PR adds four, so the combined array needs 24 entries.There is one accompanying accounting step, as you anticipated: add all four new present timers to
is_sub_call. They run insidePresentor the submission fallback'sSubmit; leaving them top-level makes #2729's non-overlappingcompletedduration count their time twice. I extended the existing submitter-summary test with all four nonzero timers and kept its completed total at 400 ms.On the resolved, uncommitted merge:
cargo build --offline --locked -j 4 --workspacepassed;cargo test --offline --locked -j 4 -p xcl --lib hle::api_cost::tests -- --test-threads=1passed 8/0/0, with no skips. Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti (621.35), Rust 1.99.1. I did not run the full suite or clean-commit smoke on this local rebase; those remain for the updated PR head.Minimal rebase resolution and accounting test
AI use: Codex (GPT-6.2 Sol) resolved the local merge, reviewed the timer nesting, ran the build and test, and drafted this reply.
Imported from ivall/xcl. Originally posted by tiagonleal on 2026-11-30T02:49:07Z.
merge-check
base:
cb8024684chead:
2aeec61c04merge: clean
build: cargo build --workspace -> ok (also
cargo build --release -p xcl)tests: cargo test --workspace --no-fail-fast -j 8 -- --test-threads=4 -> 2810 passed, 1 failed, 51 ignored; SKIPPED: 27 lines (22
no wave64, 3 f16/f32 per-lane cases refused, 2no heap windows), the same as on the base; failing:hle::d3d12x::standin::tests::concurrent_shell_miss_reuses_winner_and_releases_loser_pipeline, which fails the same way on the base (it came in with #2369; #3474 fixes it). Base alone on this PC: 2809 passed, 1 failed, 51 ignored.review: whole diff read (+55/-5,
api_cost.rs,present.rs). Diagnostic only. The four new timers (PresentLockWait,PresentRecord,PresentSwap,PresentDumpWait) are each created throughlook_stats::deep().then(...), so withXCL_LOOK_STATSunset or at 1 a present takes no clock read and writes no counter. All four are inis_sub_call, so they are not counted twice incompleted, and the new test checks that. The parts do not add up topresentsexactly; the comment inpresent.rssays so. Checked on NVIDIA as the label asks: a 60 s run of the merged tree withXCL_LOOK_STATS=2prints, in the existing 2 s line of the submitting thread,60 presents in 21 ms, ... 120 waits of a present for the one before in 0 ms, 60 copies of a present recorded and submitted in 7 ms, 60 swap chain Presents in 12 ms, so 19 of the 21 ms are attributed. At level 2 the line gains entries, which matters only to a script that expects a fixed number of them.performance: default path: a few level checks per present, no clock and no atomics. Measured with
scripts/smoke.ps1, 60 s of a retail title, release: 1683 frames and 15318 MB peak commit with the switch unset, 1678 frames and 15738 MB withXCL_LOOK_STATS=2, against 1662 and 1684 frames, 16196 and 15752 MB on the base. No device removal, no crash.verdict: safe to merge
hardware / tool and model: RTX 5070 Ti 16 GB (617.42, wave32), Ryzen 7 9800X3D, 32 GB, Windows 11 26300, rustc 1.100.0 / Claude Code (Claude Fable 5.2 ran the build, suite and smoke and wrote this; Claude Opus 5.5 read the diff first, and I checked its main points in the merged source)
Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T04:10:30Z.
merge-check claim
head:
2aeec61c04Imported from ivall/xcl. Originally posted by jsalzy on 2026-11-30T04:18:37Z.
merge-check
base:
7c01208head:
2aeec61merge: clean (also clean on main
bfbb4db)build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2851 passed, 0 failed, 51 ignored; SKIPPED: 25 (22 no wave64 on this GPU; 2 no heap windows (opt-in XCL_HEAP_WINDOWS=1); 1 driver cache cannot be disabled without Windows Developer Mode); failing: none
review: whole diff read (+55/-5, api_cost.rs and present.rs). Diagnostic only: each of the four new timers (PresentLockWait, PresentRecord, PresentSwap, PresentDumpWait) is created through look_stats::deep().then(...), so without XCL_LOOK_STATS=2 a present gets no clock read and no counter write. All four are in is_sub_call, so completed counts a present once; the new test the_parts_of_a_present_are_not_counted_twice passes, and a_call_is_counted_with_its_time still confirms CALLS is in enum order. Minor, not blocking: the PresentRecord timer starts before the allocator Reset and is dropped on the early returns before the Signal (Reset, cast or Signal failure), so a present that fails there still counts as a copy recorded and submitted. The timer placement in present.rs has no test (it needs a real present); the unit test covers the accounting only. No duplicate found: #2729 (merged) is what this extends; #3192 and #3104 touch api_cost but not the present timers; no #1607 group.
performance: not measured. Default path: one cached level check per timer site, no clock read, no atomics.
verdict: safe to merge
hardware / tool and model: RTX 4070 SUPER 12 GB (621.24 / 32.0.16.2124), Ryzen 7 7800X3D, 32 GB, Windows 11 Pro 25H2 26200.9974, Rust 1.100.0, debug / Claude app (Claude Opus 5.5): merge, build and suite run on this PC with git and cargo only; diff review by Claude Opus 5.5.