Skip to content

D3D12.X: XCL_ACTIVITY logs the CPU time of the looks before each submit - #1832

Open
marquezinii wants to merge 1 commit into
xcl-dev:mainfrom
marquezinii:activity-watch-time
Open

marquezinii wants to merge 1 commit into
xcl-dev:mainfrom
marquezinii:activity-watch-time

Conversation

@marquezinii

@marquezinii marquezinii commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Before every title submit, XCL looks for the CPU's writes. It runs GetWriteWatch over the watched ranges, copies what changed into sparse video memory, and uploads title textures again, all on the title's own submitting thread. On slower CPUs that look is most of the frame: @AlexLopezDevelop's i9-9900K sits at 2–6 fps with it in #582. The only record of it today is the sparse windows timing line, cumulative since the start and logged at power-of-two submit counts. From that line, a report at a few fps cannot tell how much of each second went to the look, or whether pipeline waits or the GPU are to blame instead.

With XCL_ACTIVITY=1, every 2 s now also logs one line about the looks of the last 2 s:

looks before submits (2 s): 13 looks took 29 ms (1.5 % of the time): write-watch 1 ms (5.2 MB watched a look, 26 pages written), copies into sparse video memory 27 ms, the rest 0 ms

The line gives:

  • the number of looks and their whole time, as a share of the 2 s (over 100 % when several threads submit);
  • the write-watch scan, with the MB it watched a look and the pages it found written;
  • the copies into sparse video memory (sparse::before_execute: lock wait, chunk scan, upload);
  • the rest: the look's lock, the title textures uploaded again, vram::before_execute.

This is meant to settle, from a tester's log, which of #582 / #1034 (the look), #1269 (pipeline compiles) or the GPU holds a slow run. The MB-per-look figure is the one #1034's description and ivall's request on #582 ask for ("ms per look, bytes per look"). Without XCL_ACTIVITY nothing is logged. The look itself gains two Instant::now() calls and a sum over the cached ranges (69 ranges a look in #582's numbers).

Related and different: #1065 (XCL_GPU_TIMING) times the whole ExecuteCommandLists call, #899 counts pipeline waits at a bind, and #1766 (XCL_GPU_PROFILE) times console programs on the GPU. None of them splits the look.

What is in it

  • crates/xcl/src/hle/d3d12x/sparse.rs: note_watch also counts looks and the bytes watched, plus note_look for a whole look; look_counters(), and look_line() for the log line; a unit test for the line.
  • crates/xcl/src/hle/d3d12x/title_textures.rs: refresh times the whole look, and refresh_once passes the bytes of the ranges it watched.
  • crates/xcl/src/host.rs: the XCL_ACTIVITY thread logs the line every 2 s.
  • HANDOFF.md: the line, next to what XCL_ACTIVITY already logs.

Tested

  • NVIDIA GeForce RTX 5070 12 GB, driver 621.40; Ryzen 5 5600X; Windows 11 Pro 26300; Rust 1.99.1 MSVC; DXC 1.9.2602.17; debug.
  • cargo test --workspace -- --test-threads=4 on 284a948: 960 passed, 0 failed, 43 ignored. SKIPPED: the wave64 cases of lower / lower_dxil and gpu_geometry_wave32_prefix_count_over_a_mask, gpu_wave32_program_in_wave64_hardware (no wave64), the f16 and conversion forms lower_dxil refuses in wave32, heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows), pso_measurement_compiles_an_exact_synthetic_record (cannot disable the driver cache).
  • The project's test title through xcl run with XCL_ACTIVITY=1: the line above, logged at 4 s, next to its activity (2 s) line. The first 2 s logged 0 looks.

Regression run
Run by @kanade333 on an NVIDIA GeForce RTX 5080, 60 s each, release, retail title on its start screen, copied from their comment as posted. scripts/smoke.ps1 sets XCL_ACTIVITY=1 itself, so these runs also exercise the new line.

main:

xcl-smoke v1
commit: 20cf13022f764208384c610c2ae6a3f4eed201a2
gpu: NVIDIA GeForce RTX 5080
title: 1e8f5e55
seconds: 60
exit: 0x0
frames shown: 1615 (PresentX 1615)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16053 MB

PR:

xcl-smoke v1
commit: 284a948c83b9af874cd05d5f054e7af927de5789
gpu: NVIDIA GeForce RTX 5080
title: 1e8f5e55
seconds: 60
exit: 0x0
frames shown: 1649 (PresentX 1649)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15257 MB

What the line said in that run, at the start screen (last of 30):

looks before submits (2 s): 240 looks took 246 ms (12.3 % of the time): write-watch 238 ms (2173.3 MB watched a look, 810 pages written), copies into sparse video memory 4 ms, the rest 3 ms

That is about 1 ms a look, nearly all of it the write-watch over 2.2 GB, which agrees with #582's 0.83 ms on the first menus.

Not tested

  • The world: @kanade333's runs stay on the start screen, where the look matters least.
  • A title with XCL_ACTIVITY unset (smoke.ps1 sets it); the line is only logged with it set.
  • AMD, Intel and Wine.

AI use

  • Claude Code (Claude Opus 5.5): wrote the change, the test and this description, and ran the tests and the test-title run on the hardware above.

Before every title submit XCL looks for the CPU's writes (write-watch
over the watched ranges), copies them into sparse video memory and
uploads changed title textures, on the title's own thread. On slower
CPUs that look is most of the frame (2-6 fps on an i9-9900K in xcl-dev#582),
but the only record of it is the cumulative timing line logged at
power-of-two submit counts, so a report at a few fps cannot say how
much of each second went there.

With XCL_ACTIVITY=1 every 2 s now also logs the looks of the last 2 s:
how many, their whole time and its share of the 2 s, the write-watch
scan with the megabytes it watched a look and the pages it found, the
copies into sparse video memory, and the rest. Without XCL_ACTIVITY
only counters are added: two Instant::now() calls per look and a sum
over the cached ranges.
@kanade333

Copy link
Copy Markdown

Regression pair on a retail title for this head (284a948), and what the new line says on its start screen. Both runs pass the same way: no device removal, no crash, 1 649 frames against 1 615 on main.

Tested

  • NVIDIA GeForce RTX 5080 16 GB (driver 610.88, 32-lane waves), AMD Ryzen 9 9950X, 32 GB RAM, Windows 11 Pro 26200, rustc 1.100.0, DXC 1.9.2602.17, release.
  • Two clean worktrees, each built in its own target directory: main 20cf130 and this PR's head 284a948.
  • scripts\smoke.ps1 -Game <retail title 1.0.2.1> -Seconds 60 -Xcl <that build's xcl.exe>, each from its own worktree, main first and this head right after it. No input, so the title stays on its start screen. The blocks below are the script's output, not edited.

Regression run

main:

xcl-smoke v1
commit: 20cf13022f764208384c610c2ae6a3f4eed201a2
gpu: NVIDIA GeForce RTX 5080
title: 1e8f5e55
seconds: 60
exit: 0x0
frames shown: 1615 (PresentX 1615)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 16053 MB

this PR's head:

xcl-smoke v1
commit: 284a948c83b9af874cd05d5f054e7af927de5789
gpu: NVIDIA GeForce RTX 5080
title: 1e8f5e55
seconds: 60
exit: 0x0
frames shown: 1649 (PresentX 1649)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 15257 MB

The new line. The script sets XCL_ACTIVITY=1 itself, so the head's run printed it 30 times. Its last three:

looks before submits (2 s): 240 looks took 240 ms (12.0 % of the time): write-watch 232 ms (2173.3 MB watched a look, 810 pages written), copies into sparse video memory 4 ms, the rest 3 ms
looks before submits (2 s): 240 looks took 246 ms (12.3 % of the time): write-watch 238 ms (2173.3 MB watched a look, 810 pages written), copies into sparse video memory 4 ms, the rest 3 ms
looks before submits (2 s): 240 looks took 246 ms (12.3 % of the time): write-watch 238 ms (2173.3 MB watched a look, 810 pages written), copies into sparse video memory 4 ms, the rest 3 ms

So on this machine, at the start screen, a look takes about 1 ms and nearly all of it is the write watch, which agrees with #582's 0.83 ms.

Not tested

AI use: Claude Code (Claude Fable 5.2) built both trees, ran the script and wrote this report. I read it before posting.

@DavidM1911

Copy link
Copy Markdown
Contributor

Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

Thanks!

@marquezinii
marquezinii marked this pull request as ready for review November 25, 2026 04:32
@marquezinii

Copy link
Copy Markdown
Contributor Author

@kanade333 thank you, that's the smoke pair this needed, plus the first look at the line on a title. I've copied both blocks into Regression run as posted, with credit, and quoted one of the lines. The PR is out of draft now.

Your reading matches mine: about 1 ms a look at the start screen, nearly all of it write-watch over 2.2 GB. Six of eight thread dumps in title_textures::refresh in the world (your #505 comment) is exactly where I'd like to see what the line says, if you get a world run with it.

AI use: Claude Code (Claude Opus 5.5) drafted this reply.

@throny throny added the goal:world-load Bears on the retail title getting past world loading label Nov 25, 2026
ozimchuk added a commit to ozimchuk/xcl-contrib that referenced this pull request Nov 25, 2026
The `looks before submits` line (xcl-dev#1832) leaves "the rest" of a look as one number. Its parts
are timed now: the view-source recheck, the VRAM pages' sync, the recheck of streamed textures
outside the write-watch, choosing the textures to upload, and the uploads (MB; the content hash
with its read, the detile, the submit with its wait), with what is left as "other". The line
also gives the longest look of the period: one slow look is a stall an average hides.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

goal:world-load Bears on the retail title getting past world loading

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants