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

Open
github-bot wants to merge 1 commit from github-bot/gh-1832 into main AGit
Owner

@⁠marquezinii on GitHub · 2026-11-24 21:35 UTC · original
marquezinii:activity-watch-time → main · +59 −4 · 4 files · 1 commits · open

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.
**@⁠marquezinii** on GitHub · 2026-11-24 21:35 UTC · [original](https://github.com/xcl-dev/xcl/pull/1832) `marquezinii:activity-watch-time` → `main` · +59 −4 · 4 files · 1 commits · open 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](https://git.gtahub.st/github/xcl-dev--xcl/pulls/1832) 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 #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.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 05:06:42 +00:00
Author
Owner

@⁠kanade333 on GitHub · 2026-11-24 23:39 UTC · original

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

  • The world: these runs stay on the start screen, which is where the look matters least. In thread dumps of a world run on another local tree the title's thread was in title_textures::refresh in 6 of 8 dumps (my comment on #505), so this line in the world is what I would like to see next.
  • XCL_ACTIVITY unset, as the description asks: the script sets it.
  • The test suite, AMD, Intel, Wine.

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

**@⁠kanade333** on GitHub · 2026-11-24 23:39 UTC · [original](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7147646176) **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** - The world: these runs stay on the start screen, which is where the look matters least. In thread dumps of a world run on another local tree the title's thread was in `title_textures::refresh` in 6 of 8 dumps (my comment on #505), so this line in the world is what I would like to see next. - `XCL_ACTIVITY` unset, as the description asks: the script sets it. - The test suite, AMD, Intel, Wine. **AI use:** Claude Code (Claude Fable 5.2) built both trees, ran the script and wrote this report. I read it before posting.
Author
Owner

@⁠DavidM1911 on GitHub · 2026-11-25 00:50 UTC · original

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

  • cargo test -p xcl --lib: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.)

Thanks!

**@⁠DavidM1911** on GitHub · 2026-11-25 00:50 UTC · [original](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7148945250) Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~23 ignored. (Intermittent single-test flake / 0xc0000005 abort under parallel scheduling — tracked in #1978; clean on single-threaded rerun.) Thanks!
Author
Owner

@⁠marquezinii on GitHub · 2026-11-25 04:32 UTC · original

@⁠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.

**@⁠marquezinii** on GitHub · 2026-11-25 04:32 UTC · [original](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7152930211) @⁠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.
Author
Owner

@⁠oni-swr on GitHub · 2026-11-25 19:44 UTC · original

AMD RX 7800 XT test report

Tested locally by merging PR head 284a948c83b9af874cd05d5f054e7af927de5789 onto base main 3f2777019544c0ada2cd294aa792d3c378ff0df8 (no push). The base is an ancestor of current main and both trees merge cleanly.

Hardware and tools: AMD Radeon RX 7800 XT, driver 32.0.31035.1003; Windows 10 Pro; Rust 1.100.0 / Cargo 1.100.0; DXC 1.8.2502.11 (DXIL 1.8.2502.11). Debug test build.

cargo test --workspace --no-fail-fast -- --test-threads=4: 1,356 passed, 2 failed, 46 ignored. There were 7 SKIPPED reports: six GPU cases (wave32/wave64 variants for three unsupported instruction forms) and one heap-window case. The two failures and all 7 SKIPPED reports match the baseline (1,355 passed, 2 failed, 46 ignored).

Not tested

  • Smoke run or retail titles
  • Release build
  • Other GPUs

AI use
Codex (gpt-6-luna) ran Phase 2 tests and wrote this report (Phase 1 pre-compile / initial baseline run used Claude Code (Claude Sonnet 5.5)).

**@⁠oni-swr** on GitHub · 2026-11-25 19:44 UTC · [original](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7172705383) AMD RX 7800 XT test report Tested locally by merging PR head `284a948c83b9af874cd05d5f054e7af927de5789` onto base `main` `3f2777019544c0ada2cd294aa792d3c378ff0df8` (no push). The base is an ancestor of current `main` and both trees merge cleanly. Hardware and tools: AMD Radeon RX 7800 XT, driver 32.0.31035.1003; Windows 10 Pro; Rust 1.100.0 / Cargo 1.100.0; DXC 1.8.2502.11 (DXIL 1.8.2502.11). Debug test build. `cargo test --workspace --no-fail-fast -- --test-threads=4`: 1,356 passed, 2 failed, 46 ignored. There were 7 `SKIPPED` reports: six GPU cases (wave32/wave64 variants for three unsupported instruction forms) and one heap-window case. The two failures and all 7 `SKIPPED` reports match the baseline (1,355 passed, 2 failed, 46 ignored). **Not tested** - Smoke run or retail titles - Release build - Other GPUs **AI use** Codex (gpt-6-luna) ran Phase 2 tests and wrote this report (Phase 1 pre-compile / initial baseline run used Claude Code (Claude Sonnet 5.5)).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1832/head:github-bot/gh-1832'
git switch 'github-bot/gh-1832'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1832'
git switch 'github-bot/gh-1832'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1832'
git switch 'github-bot/gh-1832'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1832'
git switch 'main'
git merge --squash 'github-bot/gh-1832'
git switch 'main'
git merge --ff-only 'github-bot/gh-1832'
git switch 'main'
git merge 'github-bot/gh-1832'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.