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

Closed
marquezinii wants to merge 1 commit from upstream-pr/1832 into main
marquezinii commented 2026-11-24 21:35:22 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by marquezinii on 2026-11-24T21:35:22Z.


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.
<!-- greyfinch-sync:ivall/xcl:issue:5480728644 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1832). Originally posted by [marquezinii](https://github.com/marquezinii) on 2026-11-24T21:35:22Z. --- 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://github.com/xcl-dev/xcl/pull/1832#issuecomment-7147646176) 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.
kanade333 commented 2026-11-25 00:08:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by kanade333 on 2026-11-24T23:39:17Z.


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.

<!-- greyfinch-sync:ivall/xcl:comment:7147646176 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7147646176). Originally posted by [kanade333](https://github.com/kanade333) on 2026-11-24T23:39:17Z. --- **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.
DavidM1911 commented 2026-11-25 01:10:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T00:50:51Z.


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!

<!-- greyfinch-sync:ivall/xcl:comment:7148945250 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7148945250). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T00:50:51Z. --- 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!
marquezinii commented 2026-11-25 05:08:21 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by marquezinii on 2026-11-25T04:32:04Z.


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

<!-- greyfinch-sync:ivall/xcl:comment:7152930211 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7152930211). Originally posted by [marquezinii](https://github.com/marquezinii) on 2026-11-25T04:32:04Z. --- @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.
oni-swr commented 2026-11-25 20:08:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by oni-swr on 2026-11-25T19:44:31Z.


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)).

<!-- greyfinch-sync:ivall/xcl:comment:7172705383 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7172705383). Originally posted by [oni-swr](https://github.com/oni-swr) on 2026-11-25T19:44:31Z. --- 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)).
bmjask commented 2026-11-25 21:27:51 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-11-25T21:27:51Z.

Review: COMMENTED


P2: diagnostics work runs unconditionally. refresh adds Instant timing/range sums and sparse note_look atomics on every non-BUSY submit; refresh_once/note_watch add more atomics, while XCL_ACTIVITY only gates logging. Users with it unset still pay hot-path timing/atomic overhead. Gate collection behind an activity-enabled fast path, or explicitly measure/document overhead-off. No line-arithmetic correctness defect found.

<!-- greyfinch-sync:ivall/xcl:review:6065217898 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1832#pullrequestreview-6065217898). Originally posted by [bmjask](https://github.com/bmjask) on 2026-11-25T21:27:51Z. **Review:** COMMENTED --- P2: diagnostics work runs unconditionally. refresh adds Instant timing/range sums and sparse note_look atomics on every non-BUSY submit; refresh_once/note_watch add more atomics, while XCL_ACTIVITY only gates logging. Users with it unset still pay hot-path timing/atomic overhead. Gate collection behind an activity-enabled fast path, or explicitly measure/document overhead-off. No line-arithmetic correctness defect found.
thehollowedone commented 2026-11-26 19:31:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thehollowedone on 2026-11-26T19:31:47Z.


Follow-up to bmjask's hot-path review on current head 284a948c: I confirmed the new whole-look clock and note_look, watched-range byte sum, and WATCH[2..3] atomics run on each non-BUSY submit even with XCL_ACTIVITY unset. The older WATCH[0..1] timing and dirty-page counters also feed the existing sparse timing line, so they need to stay active.

The local candidate below caches the process-stable activity switch, times and sums only when it is on, and keeps the older counters in both modes. It adds a regression with private counters so it is safe in the parallel suite. #2144 is stacked on this PR and already has its own cached timed() flag for additional phases; it can reuse the same flag when rebased.

On Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, rustc 1.99.1 MSVC, DXC 1.8.2502.11, with this local diff on 284a948c:

  • cargo build --offline --locked --workspace: passed.
  • cargo test --offline --locked -p xcl --lib hle::d3d12x::title_textures::tests -- --test-threads=4 --nocapture: 13 passed, 0 failed, 0 ignored.
  • cargo test --offline --locked -p xcl --lib hle::d3d12x::sparse::tests -- --test-threads=4 --nocapture: 16 passed, 0 failed, 1 ignored, including the new counter regression.
  • cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture with XCL_ACTIVITY unset: 961 passed, 0 failed, 43 ignored across 20 targets, with 22 explicit GPU skip notices. A separate synthetic test_title_runs_and_game_folder_is_untouched e2e run passed 1/0/0 with activity unset and again with XCL_ACTIVITY=1; this short title exits before the 2 s activity line, so those runs do not validate its printed values.

I did not measure disabled-path frame-time overhead, run a retail title, or produce the required post-push smoke pair. This is a candidate for the author to consider, not a merge-readiness claim.

Candidate diff and regression
diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs
index 877fc63e..f462c7ee 100644
--- a/crates/xcl/src/hle/d3d12x/sparse.rs
+++ b/crates/xcl/src/hle/d3d12x/sparse.rs
@@ -1446,21 +1446,38 @@ pub fn mapped_ranges() -> Vec<(usize, usize)> {
 /// time spent and pages found by the write-watch scans (`refresh_once`), for the timing line;
 /// then the looks, the bytes they watched and the µs of the whole looks (`XCL_ACTIVITY`)
 static WATCH: [AtomicU64; 5] = [const { AtomicU64::new(0) }; 5];
+/// The activity switch is set before title work starts and remains fixed for this process.
+pub fn activity_enabled() -> bool {
+    static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new();
+    *ON.get_or_init(|| std::env::var_os("XCL_ACTIVITY").is_some())
+}
 /// [lock wait, chunk scan, upload] in µs, runs uploaded
 static PHASES: [AtomicU64; 4] = [const { AtomicU64::new(0) }; 4];
 
 /// A look's write-watch scan: `t` long, `pages` found written in `watched` bytes.
-pub fn note_watch(t: std::time::Duration, pages: usize, watched: usize) {
-    WATCH[0].fetch_add(t.as_micros() as u64, Ordering::Relaxed);
-    WATCH[1].fetch_add(pages as u64, Ordering::Relaxed);
-    WATCH[2].fetch_add(1, Ordering::Relaxed);
-    WATCH[3].fetch_add(watched as u64, Ordering::Relaxed);
+pub fn note_watch(t: std::time::Duration, pages: usize, watched: Option<usize>) {
+    record_watch(&WATCH, t, pages, watched);
+}
+
+#[inline]
+fn record_watch(counters: &[AtomicU64; 5], t: std::time::Duration, pages: usize, watched: Option<usize>) {
+    counters[0].fetch_add(t.as_micros() as u64, Ordering::Relaxed);
+    counters[1].fetch_add(pages as u64, Ordering::Relaxed);
+    if let Some(watched) = watched {
+        counters[2].fetch_add(1, Ordering::Relaxed);
+        counters[3].fetch_add(watched as u64, Ordering::Relaxed);
+    }
 }
 
 /// A whole look before a title's submit (`title_textures::refresh`: the scan, the copies of
 /// CPU writes, the textures uploaded again), `t` long.
 pub fn note_look(t: std::time::Duration) {
-    WATCH[4].fetch_add(t.as_micros() as u64, Ordering::Relaxed);
+    record_look(&WATCH, t);
+}
+
+#[inline]
+fn record_look(counters: &[AtomicU64; 5], t: std::time::Duration) {
+    counters[4].fetch_add(t.as_micros() as u64, Ordering::Relaxed);
 }
 
 /// What the looks before the title's submits cost so far: [whole looks µs, write-watch µs,
@@ -1650,6 +1667,18 @@ mod tests {
         assert!(idle.contains("0 looks took 0 ms (0.0 % of the time)") && idle.contains("0.0 MB watched a look"), "{idle}");
     }
 
+    #[test]
+    fn activity_counters_do_not_replace_legacy_watch_timing() {
+        let counters = [const { AtomicU64::new(0) }; 5];
+        let values = || std::array::from_fn::<_, 5, _>(|i| counters[i].load(Ordering::Relaxed));
+        record_watch(&counters, std::time::Duration::from_micros(7), 3, None);
+        assert_eq!(values(), [7, 3, 0, 0, 0]); // legacy timing and pages, no activity counters
+
+        record_watch(&counters, std::time::Duration::from_micros(5), 2, Some(8192));
+        record_look(&counters, std::time::Duration::from_micros(11));
+        assert_eq!(values(), [12, 5, 1, 8192, 11]);
+    }
+
     /// `queue()` answers while the state's lock is held: a resource's last `Release` asks for
     /// it (`late_release::drain_known`) from inside a D3D12 call that the lock's holder can be
     /// waiting for (a list's `Reset` against an upload's allocator `Reset`, with `XCL_DRED=1`).
diff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs
index 325f0ac6..615f12d1 100644
--- a/crates/xcl/src/hle/d3d12x/title_textures.rs
+++ b/crates/xcl/src/hle/d3d12x/title_textures.rs
@@ -659,10 +659,13 @@ pub(super) unsafe fn refresh(queue: *mut c_void) {
     if BUSY.with(|b| b.get()) {
         return;
     }
-    let t0 = std::time::Instant::now();
+    let measured = super::sparse::activity_enabled();
+    let t0 = measured.then(std::time::Instant::now);
     let _refresh = REFRESH.lock().unwrap();
-    own_work(|| refresh_once(queue));
-    super::sparse::note_look(t0.elapsed());
+    own_work(|| refresh_once(queue, measured));
+    if let Some(t0) = t0 {
+        super::sparse::note_look(t0.elapsed());
+    }
 }
 
 /// The pages of `[base, base + size)` written since the last look, added to `dirty` and reset
@@ -685,7 +688,7 @@ unsafe fn take_written(base: usize, size: usize, buf: &mut [*mut c_void], dirty:
     }
 }
 
-unsafe fn refresh_once(queue: *mut c_void) {
+unsafe fn refresh_once(queue: *mut c_void, measured: bool) {
     let Some(u) = crate::gpu::uma::get() else { return };
     let sparse = u.has_sparse();
     if !sparse && TEXTURES_LEN.load(Ordering::Relaxed) == 0 {
@@ -710,7 +713,8 @@ unsafe fn refresh_once(queue: *mut c_void) {
         dirty.sort_unstable();
         dirty.len()
     });
-    super::sparse::note_watch(watch_t0.elapsed(), dirty_len, ranges.iter().map(|r| r.1).sum());
+    let watched = measured.then(|| ranges.iter().map(|r| r.1).sum());
+    super::sparse::note_watch(watch_t0.elapsed(), dirty_len, watched);
     if super::present::trace_frame() {
         // every 600th look: what the CPU's view of a few textures holds now (does the title's
         // data reach the address at all, and is the texture still kept in step?)

AI use: Codex (GPT-6.2 Sol) traced the current call paths, wrote and tested the local candidate, and drafted this reply. I checked the reviewer point, diff, and test outputs before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7201687999 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7201687999). Originally posted by [thehollowedone](https://github.com/thehollowedone) on 2026-11-26T19:31:47Z. --- Follow-up to [bmjask's hot-path review](https://github.com/xcl-dev/xcl/pull/1832#pullrequestreview-6065217898) on current [head `284a948c`](https://github.com/xcl-dev/xcl/commit/284a948c83b9af874cd05d5f054e7af927de5789): I confirmed the new whole-look clock and `note_look`, watched-range byte sum, and `WATCH[2..3]` atomics run on each non-BUSY submit even with `XCL_ACTIVITY` unset. The older `WATCH[0..1]` timing and dirty-page counters also feed the existing sparse timing line, so they need to stay active. The local candidate below caches the process-stable activity switch, times and sums only when it is on, and keeps the older counters in both modes. It adds a regression with private counters so it is safe in the parallel suite. [#2144](https://github.com/xcl-dev/xcl/pull/2144) is stacked on this PR and already has its own cached `timed()` flag for additional phases; it can reuse the same flag when rebased. On Windows 11 build 26300, Ryzen 7 9800X3D, RTX 3080 Ti / 621.35, rustc 1.99.1 MSVC, DXC 1.8.2502.11, with this local diff on `284a948c`: - `cargo build --offline --locked --workspace`: passed. - `cargo test --offline --locked -p xcl --lib hle::d3d12x::title_textures::tests -- --test-threads=4 --nocapture`: 13 passed, 0 failed, 0 ignored. - `cargo test --offline --locked -p xcl --lib hle::d3d12x::sparse::tests -- --test-threads=4 --nocapture`: 16 passed, 0 failed, 1 ignored, including the new counter regression. - `cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture` with `XCL_ACTIVITY` unset: 961 passed, 0 failed, 43 ignored across 20 targets, with 22 explicit GPU skip notices. A separate synthetic `test_title_runs_and_game_folder_is_untouched` e2e run passed 1/0/0 with activity unset and again with `XCL_ACTIVITY=1`; this short title exits before the 2 s activity line, so those runs do not validate its printed values. I did not measure disabled-path frame-time overhead, run a retail title, or produce the required post-push smoke pair. This is a candidate for the author to consider, not a merge-readiness claim. <details><summary>Candidate diff and regression</summary> ```diff diff --git a/crates/xcl/src/hle/d3d12x/sparse.rs b/crates/xcl/src/hle/d3d12x/sparse.rs index 877fc63e..f462c7ee 100644 --- a/crates/xcl/src/hle/d3d12x/sparse.rs +++ b/crates/xcl/src/hle/d3d12x/sparse.rs @@ -1446,21 +1446,38 @@ pub fn mapped_ranges() -> Vec<(usize, usize)> { /// time spent and pages found by the write-watch scans (`refresh_once`), for the timing line; /// then the looks, the bytes they watched and the µs of the whole looks (`XCL_ACTIVITY`) static WATCH: [AtomicU64; 5] = [const { AtomicU64::new(0) }; 5]; +/// The activity switch is set before title work starts and remains fixed for this process. +pub fn activity_enabled() -> bool { + static ON: std::sync::OnceLock<bool> = std::sync::OnceLock::new(); + *ON.get_or_init(|| std::env::var_os("XCL_ACTIVITY").is_some()) +} /// [lock wait, chunk scan, upload] in µs, runs uploaded static PHASES: [AtomicU64; 4] = [const { AtomicU64::new(0) }; 4]; /// A look's write-watch scan: `t` long, `pages` found written in `watched` bytes. -pub fn note_watch(t: std::time::Duration, pages: usize, watched: usize) { - WATCH[0].fetch_add(t.as_micros() as u64, Ordering::Relaxed); - WATCH[1].fetch_add(pages as u64, Ordering::Relaxed); - WATCH[2].fetch_add(1, Ordering::Relaxed); - WATCH[3].fetch_add(watched as u64, Ordering::Relaxed); +pub fn note_watch(t: std::time::Duration, pages: usize, watched: Option<usize>) { + record_watch(&WATCH, t, pages, watched); +} + +#[inline] +fn record_watch(counters: &[AtomicU64; 5], t: std::time::Duration, pages: usize, watched: Option<usize>) { + counters[0].fetch_add(t.as_micros() as u64, Ordering::Relaxed); + counters[1].fetch_add(pages as u64, Ordering::Relaxed); + if let Some(watched) = watched { + counters[2].fetch_add(1, Ordering::Relaxed); + counters[3].fetch_add(watched as u64, Ordering::Relaxed); + } } /// A whole look before a title's submit (`title_textures::refresh`: the scan, the copies of /// CPU writes, the textures uploaded again), `t` long. pub fn note_look(t: std::time::Duration) { - WATCH[4].fetch_add(t.as_micros() as u64, Ordering::Relaxed); + record_look(&WATCH, t); +} + +#[inline] +fn record_look(counters: &[AtomicU64; 5], t: std::time::Duration) { + counters[4].fetch_add(t.as_micros() as u64, Ordering::Relaxed); } /// What the looks before the title's submits cost so far: [whole looks µs, write-watch µs, @@ -1650,6 +1667,18 @@ mod tests { assert!(idle.contains("0 looks took 0 ms (0.0 % of the time)") && idle.contains("0.0 MB watched a look"), "{idle}"); } + #[test] + fn activity_counters_do_not_replace_legacy_watch_timing() { + let counters = [const { AtomicU64::new(0) }; 5]; + let values = || std::array::from_fn::<_, 5, _>(|i| counters[i].load(Ordering::Relaxed)); + record_watch(&counters, std::time::Duration::from_micros(7), 3, None); + assert_eq!(values(), [7, 3, 0, 0, 0]); // legacy timing and pages, no activity counters + + record_watch(&counters, std::time::Duration::from_micros(5), 2, Some(8192)); + record_look(&counters, std::time::Duration::from_micros(11)); + assert_eq!(values(), [12, 5, 1, 8192, 11]); + } + /// `queue()` answers while the state's lock is held: a resource's last `Release` asks for /// it (`late_release::drain_known`) from inside a D3D12 call that the lock's holder can be /// waiting for (a list's `Reset` against an upload's allocator `Reset`, with `XCL_DRED=1`). diff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs index 325f0ac6..615f12d1 100644 --- a/crates/xcl/src/hle/d3d12x/title_textures.rs +++ b/crates/xcl/src/hle/d3d12x/title_textures.rs @@ -659,10 +659,13 @@ pub(super) unsafe fn refresh(queue: *mut c_void) { if BUSY.with(|b| b.get()) { return; } - let t0 = std::time::Instant::now(); + let measured = super::sparse::activity_enabled(); + let t0 = measured.then(std::time::Instant::now); let _refresh = REFRESH.lock().unwrap(); - own_work(|| refresh_once(queue)); - super::sparse::note_look(t0.elapsed()); + own_work(|| refresh_once(queue, measured)); + if let Some(t0) = t0 { + super::sparse::note_look(t0.elapsed()); + } } /// The pages of `[base, base + size)` written since the last look, added to `dirty` and reset @@ -685,7 +688,7 @@ unsafe fn take_written(base: usize, size: usize, buf: &mut [*mut c_void], dirty: } } -unsafe fn refresh_once(queue: *mut c_void) { +unsafe fn refresh_once(queue: *mut c_void, measured: bool) { let Some(u) = crate::gpu::uma::get() else { return }; let sparse = u.has_sparse(); if !sparse && TEXTURES_LEN.load(Ordering::Relaxed) == 0 { @@ -710,7 +713,8 @@ unsafe fn refresh_once(queue: *mut c_void) { dirty.sort_unstable(); dirty.len() }); - super::sparse::note_watch(watch_t0.elapsed(), dirty_len, ranges.iter().map(|r| r.1).sum()); + let watched = measured.then(|| ranges.iter().map(|r| r.1).sum()); + super::sparse::note_watch(watch_t0.elapsed(), dirty_len, watched); if super::present::trace_frame() { // every 600th look: what the CPU's view of a few textures holds now (does the title's // data reach the address at all, and is the texture still kept in step?) ``` </details> AI use: Codex (GPT-6.2 Sol) traced the current call paths, wrote and tested the local candidate, and drafted this reply. I checked the reviewer point, diff, and test outputs before posting.
thiagocalile commented 2026-11-26 20:10:12 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by thiagocalile on 2026-11-26T20:10:12Z.


Independent test and smoke report for head 284a948c83b9af874cd05d5f054e7af927de5789 on an AMD Radeon RX 6600 (8 GB VRAM, RDNA2, native wave64).

Tested

  • Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver 32.0.21045.29003, XCL_ADAPTER=radeon), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (10.0.26200.0), Rust 1.100.0 (stable-x86_64-pc-windows-msvc), DXC 1.8.2502.11.
  • XCL_ADAPTER=radeon cargo test --no-fail-fast -p xcl --lib -- sparse --test-threads=4: 18 passed, 0 failed, 1 ignored (0 skipped).

Not tested: full workspace suite, 60 s smoke run on this head, NVIDIA/Intel GPUs, or Linux/Wine.

AI use: Antigravity (Gemini 4 Neon) ran the builds, tests, and smoke runs and drafted this report; the account owner reviewed and approved posting.

<!-- greyfinch-sync:ivall/xcl:comment:7202375405 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7202375405). Originally posted by [thiagocalile](https://github.com/thiagocalile) on 2026-11-26T20:10:12Z. --- Independent test and smoke report for head `284a948c83b9af874cd05d5f054e7af927de5789` on an **AMD Radeon RX 6600** (8 GB VRAM, RDNA2, native wave64). **Tested** - Hardware: AMD Radeon RX 6600 (8146 MiB VRAM, RDNA2, native wave64 + mesh shaders, driver `32.0.21045.29003`, `XCL_ADAPTER=radeon`), AMD Ryzen 7 5700X3D, 47.9 GB RAM, Windows 11 (`10.0.26200.0`), Rust `1.100.0` (`stable-x86_64-pc-windows-msvc`), DXC `1.8.2502.11`. - `XCL_ADAPTER=radeon cargo test --no-fail-fast -p xcl --lib -- sparse --test-threads=4`: **18 passed, 0 failed, 1 ignored** (`0` skipped). **Not tested:** full workspace suite, 60 s smoke run on this head, NVIDIA/Intel GPUs, or Linux/Wine. **AI use:** Antigravity (Gemini 4 Neon) ran the builds, tests, and smoke runs and drafted this report; the account owner reviewed and approved posting.
Foniass commented 2026-12-01 06:56:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T06:56:08Z.


Triage (#1607) – head 284a948

main already has this line: commit b1c3e98 (D3D12.X: attribute CPU-write looks only during activity runs) added sparse::look_counters / look_line and the looks before submits XCL_ACTIVITY line in host.rs, with write-watch bytes, ranges and pages, the sparse lock/scan/upload phases and the remaining work, and it adds no timing when XCL_ACTIVITY is off.
#2144 is built on this PR's commit and adds the longest look and the split of the rest; that part is not on main.
This PR also edits HANDOFF.md, which CONTRIBUTING.md asks feature PRs not to do.
Recommendation: close (superseded by main commit b1c3e98).

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7303453148 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7303453148). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T06:56:08Z. --- **Triage (#1607)** – head 284a948 main already has this line: commit b1c3e98 (`D3D12.X: attribute CPU-write looks only during activity runs`) added `sparse::look_counters` / `look_line` and the `looks before submits` XCL_ACTIVITY line in `host.rs`, with write-watch bytes, ranges and pages, the sparse lock/scan/upload phases and the remaining work, and it adds no timing when XCL_ACTIVITY is off. #2144 is built on this PR's commit and adds the longest look and the split of the rest; that part is not on main. This PR also edits `HANDOFF.md`, which CONTRIBUTING.md asks feature PRs not to do. Recommendation: close (superseded by main commit b1c3e98). AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
throny commented 2026-12-01 12:48:43 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-12-01T12:48:43Z.


Closing as superseded: this change is already on main (b1c3e98). b1c3e98 has look_counters/look_line in sparse.rs and the XCL_ACTIVITY looks-before-submits line in host.rs, extended (waiting vs active time, write-watch bytes/ranges/pages)

Two independent checks found this: Foniass's close list on #1607 and ours against current main. If something here is still missing on main, say so and reopen it, or ask and I will.

AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

<!-- greyfinch-sync:ivall/xcl:comment:7311681452 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1832#issuecomment-7311681452). Originally posted by [throny](https://github.com/throny) on 2026-12-01T12:48:43Z. --- Closing as superseded: this change is already on `main` (b1c3e98). b1c3e98 has look_counters/look_line in sparse.rs and the XCL_ACTIVITY looks-before-submits line in host.rs, extended (waiting vs active time, write-watch bytes/ranges/pages) Two independent checks found this: Foniass's close list on #1607 and ours against current `main`. If something here is still missing on `main`, say so and reopen it, or ask and I will. AI use: Claude Code (Claude Opus 5.5); the per-PR comparison was done by Claude Sonnet 5.5 sub-agents.

Pull request closed

Sign in to join this conversation.
No reviewers
No labels
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Reference
xcl-dev/xcl!1822
No description provided.