D3D12.X: the write-watch look scans 1.5 GiB before every submit while 4 pages are written (measurement and plan) #582

Open
opened 2026-11-26 04:26:22 +00:00 by github-bot · 18 comments
Owner

@⁠Kalmarv on GitHub · 2026-11-24 02:07 UTC · original

For HANDOFF's open item ("a write-watch scan of textures in the 4 GiB coherent window costs in proportion to their size at every submit; a page guard … was tried and reverted pending measurement past the menus") and @⁠srcamarda's numbers in https://github.com/ivall/xcl/pull/347#issuecomment-7119115064: where the look's time goes on main 508a0c7, and a plan. No code yet; @⁠ivall, a yes or no on the direction first, since it is the read-only idea again.

Measured on a retail title's first menus (30 presents and 120 looks a second, 30 s of them):

  • A look takes 0.83 ms, 10 % of wall time, and 99.7 % of that is inside GetWriteWatch: the range cache costs 0.2 µs, the sort 0.04 µs, no range was rebuilt.
  • It makes 69 calls over 1,641 MB: 879 MB of sparse tiles with video memory, 545 MB of kept-in-step textures in the coherent window and 199 MB in the title's graphics reservations (745 textures), 18 MB of gaps.
  • 4 pages a look come back written. Counted in 2 MiB blocks: 1.1 blocks a look, and 7 or 8 of the 844 blocks in any 2 s.
  • Nothing waits: a one-page GetWriteWatch on a page of our own took 1.5 µs (8 µs at most), so this phase has none of the stalls of #501.
  • No texture is marked GPU-written, so leaving those out of the ranges would save nothing.
  • A synthetic bench (no XCL code): a clean call costs 1.15 µs plus 0.45 ms per GiB of committed pages, the same with or without the reset flag, and no faster split over 2 to 8 threads. That gives 0.77 ms for the ranges above. So about 90 % of the look is pages nobody wrote.
  • #551 (fewer calls, wider gaps) is the other 10 % here: 19 calls over 2,218 MB instead of 69 over 1,641 MB, and 0.96 ms a look against 0.94 ms on main in matched runs, inside the spread between runs (main with only the counters added took 0.83). It should help where there are thousands of ranges; this phase has 69. The two changes do not overlap.

Plan

  1. A 64 KiB block of the watched ranges with no written page for N looks is made read-only and leaves the look. Its first write faults; a vectored handler sets an atomic bit, makes the block writable, and the next look scans it again. Measured: 3 µs for such a first write, 1 µs to protect a block; a bounded number of blocks cooled per look bounds the cost when everything is written. On these menus about 16 MiB would stay in the look: about 0.02 ms instead of 0.83.
  2. First PR: the sparse windows only (54 % of the bytes), off by default behind an environment variable, with the kernel's writes routed where lazy pages already route them (kernelx::lazy::ensure in the ReadFile hook, DirectStorage and cpu_writes), and the title's own commit, decommit and protect calls warming the block first. ReadFile into a read-only page fails with error 998 in the bench, as HANDOFF says; a call XCL does not route would fail loudly, not leave stale data.
  3. Then the textures in the reservations, and the coherent window only after a GPU test shows that the imported heap takes read-only pages.

Tested

  • RTX 5070 Ti (NVIDIA 610.74), Ryzen 9 9950X, Windows 11 26200, release builds, XCL_NETWORK=0, 60 s, no input, one run each: main 508a0c7; the same with local counters around refresh_once (not in any PR); 508a0c7 with #551 (712bbbe) merged. No crash or device removal in the three.
  • The synthetic numbers: a standalone program on the same PC, 1 GiB of write-watched memory, medians of 5 to 25.

Not tested

  • World loading and anything after the first menus: the runs take no input. The design itself: no code exists.
  • AMD GPUs and CPUs, Wine, a debug build.

🤖 Claude Fable 5.2

**@⁠Kalmarv** on GitHub · 2026-11-24 02:07 UTC · [original](https://github.com/xcl-dev/xcl/issues/582) For HANDOFF's open item ("a write-watch scan of textures in the 4 GiB coherent window costs in proportion to their size at every submit; a page guard … was tried and reverted pending measurement past the menus") and @⁠srcamarda's numbers in https://github.com/ivall/xcl/pull/347#issuecomment-7119115064: where the look's time goes on `main` `508a0c7`, and a plan. No code yet; @⁠ivall, a yes or no on the direction first, since it is the read-only idea again. **Measured** on a retail title's first menus (30 presents and 120 looks a second, 30 s of them): - A look takes 0.83 ms, 10 % of wall time, and 99.7 % of that is inside `GetWriteWatch`: the range cache costs 0.2 µs, the sort 0.04 µs, no range was rebuilt. - It makes 69 calls over 1,641 MB: 879 MB of sparse tiles with video memory, 545 MB of kept-in-step textures in the coherent window and 199 MB in the title's graphics reservations (745 textures), 18 MB of gaps. - 4 pages a look come back written. Counted in 2 MiB blocks: 1.1 blocks a look, and 7 or 8 of the 844 blocks in any 2 s. - Nothing waits: a one-page `GetWriteWatch` on a page of our own took 1.5 µs (8 µs at most), so this phase has none of the stalls of #501. - No texture is marked GPU-written, so leaving those out of the ranges would save nothing. - A synthetic bench (no XCL code): a clean call costs 1.15 µs plus 0.45 ms per GiB of committed pages, the same with or without the reset flag, and no faster split over 2 to 8 threads. That gives 0.77 ms for the ranges above. So about 90 % of the look is pages nobody wrote. - #551 (fewer calls, wider gaps) is the other 10 % here: 19 calls over 2,218 MB instead of 69 over 1,641 MB, and 0.96 ms a look against 0.94 ms on `main` in matched runs, inside the spread between runs (`main` with only the counters added took 0.83). It should help where there are thousands of ranges; this phase has 69. The two changes do not overlap. **Plan** 1. A 64 KiB block of the watched ranges with no written page for N looks is made read-only and leaves the look. Its first write faults; a vectored handler sets an atomic bit, makes the block writable, and the next look scans it again. Measured: 3 µs for such a first write, 1 µs to protect a block; a bounded number of blocks cooled per look bounds the cost when everything is written. On these menus about 16 MiB would stay in the look: about 0.02 ms instead of 0.83. 2. First PR: the sparse windows only (54 % of the bytes), off by default behind an environment variable, with the kernel's writes routed where lazy pages already route them (`kernelx::lazy::ensure` in the ReadFile hook, DirectStorage and `cpu_writes`), and the title's own commit, decommit and protect calls warming the block first. `ReadFile` into a read-only page fails with error 998 in the bench, as HANDOFF says; a call XCL does not route would fail loudly, not leave stale data. 3. Then the textures in the reservations, and the coherent window only after a GPU test shows that the imported heap takes read-only pages. **Tested** - RTX 5070 Ti (NVIDIA 610.74), Ryzen 9 9950X, Windows 11 26200, release builds, `XCL_NETWORK=0`, 60 s, no input, one run each: `main` `508a0c7`; the same with local counters around `refresh_once` (not in any PR); `508a0c7` with #551 (`712bbbe`) merged. No crash or device removal in the three. - The synthetic numbers: a standalone program on the same PC, 1 GiB of write-watched memory, medians of 5 to 25. **Not tested** - World loading and anything after the first menus: the runs take no input. The design itself: no code exists. - AMD GPUs and CPUs, Wine, a debug build. 🤖 Claude Fable 5.2
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:26:22 +00:00
Author
Owner

@⁠iggyvilla on GitHub · 2026-11-24 03:34 UTC · original

Past the first menus, on an 8 GB AMD card with the game on a hard drive, the look gets slower while the bytes it scans stay the same, and the time goes to VirtualQuery calls on the title's render thread. That is #501's mechanism through two other checks.

Measured

  • On 9ce2070 with local counters around refresh_once (not in any PR), after the account prompt: a look went from about 1 ms to 7–8 ms with the same 1.57 GB scanned every look. Once the title recovered it was 2.3 ms for the same 1.57 GB. So the extra time is not the byte count, and wider gaps (#551) or fewer bytes (the read-only plan above) would not remove it. The read-only plan still applies to the 2.3 ms that is left.
  • The slow phase does not last. One run went back to 24–28 fps after about 10 minutes, and it is shorter when the file cache is warm. While it lasts the GPU is 3–7 % busy (Task Manager 3D) and one title thread uses a full core.
  • That thread, sampled for 20 s at 24 fps (4,422 samples): 97.5 % in NtQueryVirtualMemory. With the symbols resolved:
    • 70.9 %: list_x::gpu_va (list_x.rs:1810) → gpu::shader::readable, from ia_set_vertex_buffers_x
    • 7.8 %: the same check, from ia_set_index_buffer_x
    • 18.5 %: timestamp → cpu_writes::writable (list_x.rs:1169), from Write64BitValueBottomOfPipeX with a timestamp flag into memory outside unified memory
  • At the same moment the submit thread spent 28.7 % in NtGetWriteWatch (refresh_once). We took no thread dumps of single waits the way #501 did, so the link between the two (the walks holding the address space while GetWriteWatch waits) is an inference from the timing.
  • readable asks resident_and_readable first. On a cold address space the pages are not resident yet, so every bind falls through to the VirtualQuery walk. gpu_va makes that check before it looks for the buffer's existing mirror, so a buffer that already has a mirror still pays for the walk at every bind.

#693 fixes the gpu_va part (look up the mirror first, keep readable for the first bind). Profiled at 125 s on dd2ae9a against #693: the render thread went from 92 % to 25 % of a core and the gpu_va walk was no longer sampled, but fps stayed at 10–11. With the render thread mostly waiting, the limit is now the submit thread, at 86–89 % of a core on both builds in title_textures::refresh and NtGetWriteWatch under ExecuteCommandLists. So for this issue the look's cost itself is what is left.

Tested

  • AMD Radeon RX 6650 XT 8 GB (driver 32.0.21045.29003), Ryzen 7 5700X, 32 GB, Windows 11 26H2 (26300), release builds, XCL_NETWORK=0, a retail title (game files on a hard drive), Enter pressed past the first menu (50–75 s).
  • main 508a0c7: 30 fps for the first ~55 s, then 12 fps at 80 s and 3.5 fps at 261 s. Another CPU-heavy job was running during that run.
  • 9ce2070 plus the local counters, machine quiet: the look numbers above. Profile with a stack sampler of our own, symbols from the build's PDB.

Not tested

  • NVIDIA, a game on an SSD, more than one profiled run per build, the timestamp path (#317), any change to the look.

AI use

  • Claude Code agents (Claude Opus 5.5) ran the measurements and wrote this comment. The numbers come from those runs.
**@⁠iggyvilla** on GitHub · 2026-11-24 03:34 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7121228737) Past the first menus, on an 8 GB AMD card with the game on a hard drive, the look gets slower while the bytes it scans stay the same, and the time goes to `VirtualQuery` calls on the title's render thread. That is #501's mechanism through two other checks. **Measured** - On `9ce2070` with local counters around `refresh_once` (not in any PR), after the account prompt: a look went from about 1 ms to 7–8 ms with **the same 1.57 GB scanned every look**. Once the title recovered it was 2.3 ms for the same 1.57 GB. So the extra time is not the byte count, and wider gaps (#551) or fewer bytes (the read-only plan above) would not remove it. The read-only plan still applies to the 2.3 ms that is left. - The slow phase does not last. One run went back to 24–28 fps after about 10 minutes, and it is shorter when the file cache is warm. While it lasts the GPU is 3–7 % busy (Task Manager 3D) and one title thread uses a full core. - That thread, sampled for 20 s at 24 fps (4,422 samples): **97.5 % in `NtQueryVirtualMemory`**. With the symbols resolved: - 70.9 %: `list_x::gpu_va` (`list_x.rs:1810`) → `gpu::shader::readable`, from `ia_set_vertex_buffers_x` - 7.8 %: the same check, from `ia_set_index_buffer_x` - 18.5 %: `timestamp` → `cpu_writes::writable` (`list_x.rs:1169`), from `Write64BitValueBottomOfPipeX` with a timestamp flag into memory outside unified memory - At the same moment the submit thread spent 28.7 % in `NtGetWriteWatch` (`refresh_once`). We took no thread dumps of single waits the way #501 did, so the link between the two (the walks holding the address space while `GetWriteWatch` waits) is an inference from the timing. - `readable` asks `resident_and_readable` first. On a cold address space the pages are not resident yet, so every bind falls through to the `VirtualQuery` walk. `gpu_va` makes that check before it looks for the buffer's existing mirror, so a buffer that already has a mirror still pays for the walk at every bind. #693 fixes the `gpu_va` part (look up the mirror first, keep `readable` for the first bind). Profiled at 125 s on `dd2ae9a` against #693: the render thread went from 92 % to 25 % of a core and the `gpu_va` walk was no longer sampled, but fps stayed at 10–11. With the render thread mostly waiting, the limit is now the submit thread, at 86–89 % of a core on both builds in `title_textures::refresh` and `NtGetWriteWatch` under `ExecuteCommandLists`. So for this issue the look's cost itself is what is left. **Tested** - AMD Radeon RX 6650 XT 8 GB (driver 32.0.21045.29003), Ryzen 7 5700X, 32 GB, Windows 11 26H2 (26300), release builds, `XCL_NETWORK=0`, a retail title (game files on a hard drive), Enter pressed past the first menu (50–75 s). - `main` `508a0c7`: 30 fps for the first ~55 s, then 12 fps at 80 s and 3.5 fps at 261 s. Another CPU-heavy job was running during that run. - `9ce2070` plus the local counters, machine quiet: the look numbers above. Profile with a stack sampler of our own, symbols from the build's PDB. **Not tested** - NVIDIA, a game on an SSD, more than one profiled run per build, the `timestamp` path (#317), any change to the look. **AI use** - Claude Code agents (Claude Opus 5.5) ran the measurements and wrote this comment. The numbers come from those runs.
Author
Owner

@⁠Kalmarv on GitHub · 2026-11-24 03:42 UTC · original

@⁠iggyvilla, thanks. This is the phase my runs never reached: they take no input.

#693 and #501 (read at f44cc79 and 81c43fe, nothing run)

  • They do not overlap, and neither covers the other. #501 answers two write checks, dstorage::writable and eh::is_writable, from the sparse windows' record, and only for an address inside a sparse window. #693 is in gpu_va, which returns early for any address inside unified memory, so its buffers are ones that record never holds.
  • Different files (list_x.rs against sparse.rs, dstorage.rs, eh.rs, kernelx.rs). #693 merges cleanly onto #501 merged onto main 63cdc25.
  • Two walks that neither removes, from reading main f4ce27c:
    • gpu::shader::readable asks the working set for at most 16 pages. A range over 64 KiB goes to the VirtualQuery walk even when every page is resident, so it is not only the cold address space. After #693 that is left at the first bind of a range and in sync_title_buffers, which calls readable at each draw for the part it reads.
    • cpu_writes::writable, your 18.5 % on the timestamp path, is one VirtualQuery with nothing before it.

Does the plan change? The direction stays; the order changes, and one detail.

  • Order. Your 7–8 ms against 2.3 ms for the same 1.57 GB is time the read-only blocks would not remove. The walks go first: #693, #501, then the two above. The plan is for what is left after them.
  • What is left is the open number. On the menus a look took 0.83 ms at 120 looks a second here, 10 % of a core. Your submit thread after #693 is at 86–89 % of a core in refresh and NtGetWriteWatch at 10–11 fps. Three counters at that point would say what it is made of: looks a second, bytes a look and milliseconds a look. If the time follows the bytes, the plan is the fix for that phase; if it follows the number of calls, #551 is; if neither, something else is in GetWriteWatch there and the plan should wait for it. Do you still have the build with the counters?
  • A correction to the issue text. "Nothing waits" holds for the first menus on a CPU with CLZERO, which is all I measured.
  • A detail from #501. A block the plan makes read-only is, to known_writable, a resident page without a writable protection: the check falls back to the walk, and the walk answers no. So the warm-up has to come before known_writable in dstorage::writable, and eh::is_writable (emulated CLZERO) has to be added to the places the plan routes; it lists DirectStorage, ReadFile and cpu_writes only.

Not tested

  • Everything above is from reading the two PRs and main. No run past the first menus exists on this PC yet.

🤖 Claude Fable 5.2

**@⁠Kalmarv** on GitHub · 2026-11-24 03:42 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7121344205) @⁠iggyvilla, thanks. This is the phase my runs never reached: they take no input. **#693 and #501** (read at `f44cc79` and `81c43fe`, nothing run) - They do not overlap, and neither covers the other. #501 answers two write checks, `dstorage::writable` and `eh::is_writable`, from the sparse windows' record, and only for an address inside a sparse window. #693 is in `gpu_va`, which returns early for any address inside unified memory, so its buffers are ones that record never holds. - Different files (`list_x.rs` against `sparse.rs`, `dstorage.rs`, `eh.rs`, `kernelx.rs`). #693 merges cleanly onto #501 merged onto `main` `63cdc25`. - Two walks that neither removes, from reading `main` `f4ce27c`: - `gpu::shader::readable` asks the working set for at most 16 pages. A range over 64 KiB goes to the `VirtualQuery` walk even when every page is resident, so it is not only the cold address space. After #693 that is left at the first bind of a range and in `sync_title_buffers`, which calls `readable` at each draw for the part it reads. - `cpu_writes::writable`, your 18.5 % on the timestamp path, is one `VirtualQuery` with nothing before it. **Does the plan change?** The direction stays; the order changes, and one detail. - **Order.** Your 7–8 ms against 2.3 ms for the same 1.57 GB is time the read-only blocks would not remove. The walks go first: #693, #501, then the two above. The plan is for what is left after them. - **What is left is the open number.** On the menus a look took 0.83 ms at 120 looks a second here, 10 % of a core. Your submit thread after #693 is at 86–89 % of a core in `refresh` and `NtGetWriteWatch` at 10–11 fps. Three counters at that point would say what it is made of: looks a second, bytes a look and milliseconds a look. If the time follows the bytes, the plan is the fix for that phase; if it follows the number of calls, #551 is; if neither, something else is in `GetWriteWatch` there and the plan should wait for it. Do you still have the build with the counters? - **A correction to the issue text.** "Nothing waits" holds for the first menus on a CPU with CLZERO, which is all I measured. - **A detail from #501.** A block the plan makes read-only is, to `known_writable`, a resident page without a writable protection: the check falls back to the walk, and the walk answers no. So the warm-up has to come before `known_writable` in `dstorage::writable`, and `eh::is_writable` (emulated CLZERO) has to be added to the places the plan routes; it lists DirectStorage, `ReadFile` and `cpu_writes` only. **Not tested** - Everything above is from reading the two PRs and `main`. No run past the first menus exists on this PC yet. 🤖 Claude Fable 5.2
Author
Owner

@⁠AlexLopezDevelop on GitHub · 2026-11-24 09:36 UTC · original

A data point where the look is the whole frame budget: RTX 2080 Ti + Intel i9-9900K (Coffee Lake), Windows 11, 32 GB, retail 1.0.2.1, #891 (8cada26) with XCL_PSO_WAIT_MS=50, first-run setup and into the world load, walked by hand. The title sits at 2-3.4 fps the whole run, with the window caption showing 0 running pipeline compiles, and the periodic timing lines are:

[ 44.793] sparse windows timing: write-watch   965 ms ( 305989 dirty pages), lock wait 2 ms, chunk scan 241 ms, upload 421 ms (39304 runs)
[ 77.914] sparse windows timing: write-watch  6278 ms ( 537785 dirty pages), lock wait 2 ms, chunk scan 248 ms, upload 484 ms (41571 runs)
[153.438] sparse windows timing: write-watch 18810 ms (1379493 dirty pages), lock wait 2 ms, chunk scan 302 ms, upload 675 ms (93597 runs)

sparse 7447 MB in the same run's counters. So on this machine GetWriteWatch grows with the dirty-page count far past the 0.83 ms a look measured above, and nothing else in the timing line comes close. For comparison, on the same PC another loader for this title that copies only changed title memory runs the same menus at about 30 fps.

Not measured: per-look time (only these aggregates), and the same run on main.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠AlexLopezDevelop** on GitHub · 2026-11-24 09:36 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7127653923) A data point where the look is the whole frame budget: **RTX 2080 Ti** + **Intel i9-9900K** (Coffee Lake), Windows 11, 32 GB, retail 1.0.2.1, #891 (`8cada26`) with `XCL_PSO_WAIT_MS=50`, first-run setup and into the world load, walked by hand. The title sits at **2-3.4 fps** the whole run, with the window caption showing `0 running` pipeline compiles, and the periodic timing lines are: ``` [ 44.793] sparse windows timing: write-watch 965 ms ( 305989 dirty pages), lock wait 2 ms, chunk scan 241 ms, upload 421 ms (39304 runs) [ 77.914] sparse windows timing: write-watch 6278 ms ( 537785 dirty pages), lock wait 2 ms, chunk scan 248 ms, upload 484 ms (41571 runs) [153.438] sparse windows timing: write-watch 18810 ms (1379493 dirty pages), lock wait 2 ms, chunk scan 302 ms, upload 675 ms (93597 runs) ``` `sparse 7447 MB` in the same run's counters. So on this machine `GetWriteWatch` grows with the dirty-page count far past the 0.83 ms a look measured above, and nothing else in the timing line comes close. For comparison, on the same PC another loader for this title that copies only changed title memory runs the same menus at about 30 fps. Not measured: per-look time (only these aggregates), and the same run on `main`. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠AlexLopezDevelop on GitHub · 2026-11-24 09:50 UTC · original

Follow-up to my numbers above, a longer run on the same machine (RTX 2080 Ti + i9-9900K), now #891 + #631 so neither the pipeline waits (#846) nor the BVH address (#585) stop it. The look keeps growing, and the title's watchdog fires anyway:

[ 81.925] sparse windows timing: write-watch  7291 ms ( 315467 dirty pages) … upload  322 ms
[145.177] sparse windows timing: write-watch 16372 ms ( 331457 dirty pages) … upload  434 ms
[244.285] sparse windows timing: write-watch 34010 ms ( 363478 dirty pages) … upload  628 ms
[509.122] sparse windows timing: write-watch 81110 ms (1849969 dirty pages) … upload 1151 ms
[633.791] unhandled exception 0xc0000005 in game_scarlett_master.exe+0x23cf683 (write at address 0x0)

Presents fell from 6.0 to 3-4 fps over the same span. Every pipeline bind was bounded at 50 ms (still being built after 50 ms … 513 so far), so on this machine the thread held long enough for the watchdog is most likely the one doing the look before its submit. Not proven: I have the aggregate timing lines, not a per-look time or the stack of the held thread.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠AlexLopezDevelop** on GitHub · 2026-11-24 09:50 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7127956775) Follow-up to my numbers above, a longer run on the same machine (RTX 2080 Ti + i9-9900K), now #891 + #631 so neither the pipeline waits (#846) nor the BVH address (#585) stop it. The look keeps growing, and the title's watchdog fires anyway: ``` [ 81.925] sparse windows timing: write-watch 7291 ms ( 315467 dirty pages) … upload 322 ms [145.177] sparse windows timing: write-watch 16372 ms ( 331457 dirty pages) … upload 434 ms [244.285] sparse windows timing: write-watch 34010 ms ( 363478 dirty pages) … upload 628 ms [509.122] sparse windows timing: write-watch 81110 ms (1849969 dirty pages) … upload 1151 ms [633.791] unhandled exception 0xc0000005 in game_scarlett_master.exe+0x23cf683 (write at address 0x0) ``` Presents fell from 6.0 to 3-4 fps over the same span. Every pipeline bind was bounded at 50 ms (`still being built after 50 ms … 513 so far`), so on this machine the thread held long enough for the watchdog is most likely the one doing the look before its submit. Not proven: I have the aggregate timing lines, not a per-look time or the stack of the held thread. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠AlexLopezDevelop on GitHub · 2026-11-24 10:01 UTC · original

The synthetic bench from the issue text, rerun on the machine from my two comments above (Intel i9-9900K, Coffee Lake, Windows 11, 32 GB): 1 GiB committed with MEM_WRITE_WATCH, K pages written before each look, the look done like take_written (16,384-entry buffer, resume after the last page reported), median of 15:

Pages written With WRITE_WATCH_FLAG_RESET Without
0 1.38 ms 1.33 ms
64 1.47 ms 1.44 ms
1,024 1.66 ms 1.40 ms
16,384 4.46 ms 1.44 ms
65,536 13.44 ms 1.89 ms
262,144 28.35 ms 1.86 ms

So on this CPU:

  • The clean part is about 3× the 0.45 ms per GiB measured above on the 9950X: about 1.4 ms per GiB, which over the 7.4 GB of sparse windows my runs report is about 10 ms a look before any page is written. That is the part step 1 of the plan removes, and it explains why this machine sits at 2-6 fps through the menus while the issue's machine loses 10 %.
  • The reset adds about 0.1 µs per written page (262,144 pages: +26.5 ms). During the world load my runs report 300,000 to 1,850,000 dirty pages per timing window, so that part grows with the load whatever the plan does; it is the title writing, not the scan.

@⁠ivall, if the direction in the issue text is a yes, I can write step 1-2 (sparse windows only, off by default behind an environment variable) and test it on this machine, where the gain is largest; unless the issue's author wants to. I will wait for a yes before writing it.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠AlexLopezDevelop** on GitHub · 2026-11-24 10:01 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7128201999) The synthetic bench from the issue text, rerun on the machine from my two comments above (Intel i9-9900K, Coffee Lake, Windows 11, 32 GB): 1 GiB committed with `MEM_WRITE_WATCH`, K pages written before each look, the look done like `take_written` (16,384-entry buffer, resume after the last page reported), median of 15: | Pages written | With `WRITE_WATCH_FLAG_RESET` | Without | |---|---|---| | 0 | 1.38 ms | 1.33 ms | | 64 | 1.47 ms | 1.44 ms | | 1,024 | 1.66 ms | 1.40 ms | | 16,384 | 4.46 ms | 1.44 ms | | 65,536 | 13.44 ms | 1.89 ms | | 262,144 | 28.35 ms | 1.86 ms | So on this CPU: - **The clean part is about 3× the 0.45 ms per GiB measured above on the 9950X**: about 1.4 ms per GiB, which over the 7.4 GB of sparse windows my runs report is about 10 ms a look before any page is written. That is the part step 1 of the plan removes, and it explains why this machine sits at 2-6 fps through the menus while the issue's machine loses 10 %. - **The reset adds about 0.1 µs per written page** (262,144 pages: +26.5 ms). During the world load my runs report 300,000 to 1,850,000 dirty pages per timing window, so that part grows with the load whatever the plan does; it is the title writing, not the scan. @⁠ivall, if the direction in the issue text is a yes, I can write step 1-2 (sparse windows only, off by default behind an environment variable) and test it on this machine, where the gain is largest; unless the issue's author wants to. I will wait for a yes before writing it. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠ivall on GitHub · 2026-11-24 10:06 UTC · original

Yes to the direction, in the order you set out: the VirtualQuery walks first (#693 and #551 are merged now, #501 needs a rebase onto #532's parked tiles), then step 1-2 of the plan - read-only blocks for the sparse windows only, off by default behind an environment variable, with the kernel's writes routed through kernelx::lazy::ensure as for lazy pages. @⁠AlexLopezDevelop, go ahead with it if @⁠Kalmarv does not want to - please say here who takes it, so it is written once. The PR should carry the look's numbers (ms per look, bytes per look) before and after on a CPU where the look dominates, plus a run on a fast CPU to show it costs nothing there.

**@⁠ivall** on GitHub · 2026-11-24 10:06 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7128327759) Yes to the direction, in the order you set out: the `VirtualQuery` walks first (#693 and #551 are merged now, #501 needs a rebase onto #532's parked tiles), then step 1-2 of the plan - read-only blocks for the sparse windows only, off by default behind an environment variable, with the kernel's writes routed through `kernelx::lazy::ensure` as for lazy pages. @⁠AlexLopezDevelop, go ahead with it if @⁠Kalmarv does not want to - please say here who takes it, so it is written once. The PR should carry the look's numbers (ms per look, bytes per look) before and after on a CPU where the look dominates, plus a run on a fast CPU to show it costs nothing there.
Author
Owner

@⁠AlexLopezDevelop on GitHub · 2026-11-24 10:21 UTC · original

Taking step 1-2 (read-only blocks for the sparse windows only, off by default behind an environment variable, the kernel's writes routed through kernelx::lazy::ensure as for lazy pages), unless @⁠Kalmarv says otherwise in the next hour. The PR will carry ms and bytes per look before and after on this i9-9900K, and I'll ask for a run on a fast CPU there.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠AlexLopezDevelop** on GitHub · 2026-11-24 10:21 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7128655486) Taking step 1-2 (read-only blocks for the sparse windows only, off by default behind an environment variable, the kernel's writes routed through `kernelx::lazy::ensure` as for lazy pages), unless @⁠Kalmarv says otherwise in the next hour. The PR will carry ms and bytes per look before and after on this i9-9900K, and I'll ask for a run on a fast CPU there. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠AlexLopezDevelop on GitHub · 2026-11-24 10:39 UTC · original

Step 1-2 is up as #1034 (off by default, XCL_SPARSE_COOL=1). On the i9-9900K the look goes from 1,780 to 951 MB and from 8.98 to 7.10 ms a look in 120 s of the first menus, with the cooling still ramping up. It needs a run on a fast CPU, as asked above: anyone with a Zen 4/5 or a recent Intel, a smoke.ps1 pair with XCL_SPARSE_COOL=1 on #1034 would settle whether it costs anything there.

AI-assisted (Claude Code, Claude Opus 5.5).

**@⁠AlexLopezDevelop** on GitHub · 2026-11-24 10:39 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7129065818) Step 1-2 is up as #1034 (off by default, `XCL_SPARSE_COOL=1`). On the i9-9900K the look goes from 1,780 to 951 MB and from 8.98 to 7.10 ms a look in 120 s of the first menus, with the cooling still ramping up. It needs a run on a fast CPU, as asked above: anyone with a Zen 4/5 or a recent Intel, a `smoke.ps1` pair with `XCL_SPARSE_COOL=1` on #1034 would settle whether it costs anything there. AI-assisted (Claude Code, Claude Opus 5.5).
Author
Owner

@⁠zorde23 on GitHub · 2026-11-24 13:49 UTC · original · edited 2026-11-24 13:57 UTC

cached_watch_ranges is computed again on nearly every submit while a title streams (up to 574 ms every 2 s on an RX 6750 XT, main 6efdabc). An AMD data point for #1034, which was measured on NVIDIA/Intel. Recomputing it in place, only adding new textures and tiles (full computation kept for removals), brought it to 19 recomputations and 5 ms peak per 2 s in a local test; happy to test #1034 on this card.

Written with Claude Code from runs on this machine.

**@⁠zorde23** on GitHub · 2026-11-24 13:49 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7133386449) · edited 2026-11-24 13:57 UTC `cached_watch_ranges` is computed again on nearly every submit while a title streams (up to 574 ms every 2 s on an RX 6750 XT, main 6efdabc). An AMD data point for #1034, which was measured on NVIDIA/Intel. Recomputing it in place, only adding new textures and tiles (full computation kept for removals), brought it to 19 recomputations and 5 ms peak per 2 s in a local test; happy to test #1034 on this card. Written with Claude Code from runs on this machine.
Author
Owner

@⁠Krashgamer on GitHub · 2026-11-24 21:25 UTC · original

The same cost on NVIDIA, and it is what holds the title's submissions during the world load here. @⁠zorde23, are you opening your in-place recomputation as a PR? If I don't hear back within an hour, I'll take it. I'll credit your approach and keep #1034's all_watch_ranges split in mind so the two merge cleanly.

Measured (RTX 3080 10 GB, i7-10700K, main 4178e88 + #640 + #742 + #1791 and others, XCL_DIRECT_DXIL=1, with a local timer around title_textures::refresh):

  • Every refresh over 50 ms rebuilt the watch ranges. 128 of them by 158 s, taking 50 to 899 ms each. They grew with the number of textures kept in step: 60–229 ms at 25–735 textures in the first seconds, 53–293 ms at 15–17k during the world load, 322 ms at 23.6k and 899 ms at 25k.
  • In thread dumps taken while the title presented nothing and submitted nothing for 2 s windows, its submission thread (+0x24821e3) was inside refresh_once → cached_watch_ranges (the flat_map over by_res, then freeing it) in both dumps, 6 s apart.

Plan: rebuild only what changed. Textures added since the last build add their ranges to the cached list; a removal or a sparse or reservation change still rebuilds it all, as today. One small PR in title_textures.rs, with a test that the incremental list equals a full rebuild after adds and removes.

AI use: Claude Code (Claude Opus 5.5).

**@⁠Krashgamer** on GitHub · 2026-11-24 21:25 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7144914476) The same cost on NVIDIA, and it is what holds the title's submissions during the world load here. @⁠zorde23, are you opening your in-place recomputation as a PR? If I don't hear back within an hour, I'll take it. I'll credit your approach and keep #1034's `all_watch_ranges` split in mind so the two merge cleanly. **Measured** (RTX 3080 10 GB, i7-10700K, `main` `4178e88` + #640 + #742 + #1791 and others, `XCL_DIRECT_DXIL=1`, with a local timer around `title_textures::refresh`): - Every `refresh` over 50 ms rebuilt the watch ranges. 128 of them by 158 s, taking 50 to 899 ms each. They grew with the number of textures kept in step: 60–229 ms at 25–735 textures in the first seconds, 53–293 ms at 15–17k during the world load, 322 ms at 23.6k and 899 ms at 25k. - In thread dumps taken while the title presented nothing and submitted nothing for 2 s windows, its submission thread (`+0x24821e3`) was inside `refresh_once` → `cached_watch_ranges` (the `flat_map` over `by_res`, then freeing it) in both dumps, 6 s apart. **Plan**: rebuild only what changed. Textures added since the last build add their ranges to the cached list; a removal or a sparse or reservation change still rebuilds it all, as today. One small PR in `title_textures.rs`, with a test that the incremental list equals a full rebuild after adds and removes. AI use: Claude Code (Claude Opus 5.5).
Author
Owner

@⁠Krashgamer on GitHub · 2026-11-24 21:35 UTC · original

Correction to my comment above: the range rebuild is not where the time goes. I'm withdrawing that claim. @⁠zorde23, your in-place recomputation stays yours if you want it, but on this machine it would save little.

I timed the parts of cached_watch_ranges on main c4d37be (64 commits after 4178e88) + #742 + #1791 + #1765 + #1055, without #1102: a rebuild takes 0–4 ms even at 15–17k textures. The slow refresh calls are still there (50 ms to 1.7 s, 64 of them by 135 s), and some of them rebuilt nothing. So the time is in the rest of refresh_once: the write-watch look, sparse::before_execute or the texture uploads. I'm timing those next and will post where it goes. If it's the uploads waiting on the CPU, that is #455's part, not mine.

**@⁠Krashgamer** on GitHub · 2026-11-24 21:35 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7145128611) Correction to my comment above: the range rebuild is not where the time goes. I'm withdrawing that claim. @⁠zorde23, your in-place recomputation stays yours if you want it, but on this machine it would save little. I timed the parts of `cached_watch_ranges` on `main` `c4d37be` (64 commits after `4178e88`) + #742 + #1791 + #1765 + #1055, without #1102: a rebuild takes 0–4 ms even at 15–17k textures. The slow `refresh` calls are still there (50 ms to 1.7 s, 64 of them by 135 s), and some of them rebuilt nothing. So the time is in the rest of `refresh_once`: the write-watch look, `sparse::before_execute` or the texture uploads. I'm timing those next and will post where it goes. If it's the uploads waiting on the CPU, that is #455's part, not mine.
Author
Owner

@⁠marquezinii on GitHub · 2026-11-24 21:35 UTC · original

For the before/after numbers asked above (ms per look, bytes per look): #1832 adds one line to XCL_ACTIVITY=1 every 2 s. It gives the looks of the last 2 s, their total time and share of the 2 s, the write-watch part with the MB watched per look and the pages found, the copies into sparse video memory, and the rest. Today's sparse windows timing line is cumulative and logged at power-of-two submit counts, so per-period figures had to be worked out by hand. It needs a smoke pair from someone with a title before it can be merged. @⁠AlexLopezDevelop, if you run #1034 on your i9-9900K again, this gives the per-2-s figures directly.

AI use: Claude Code (Claude Opus 5.5).

**@⁠marquezinii** on GitHub · 2026-11-24 21:35 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7145135779) For the before/after numbers asked above (ms per look, bytes per look): #1832 adds one line to `XCL_ACTIVITY=1` every 2 s. It gives the looks of the last 2 s, their total time and share of the 2 s, the write-watch part with the MB watched per look and the pages found, the copies into sparse video memory, and the rest. Today's `sparse windows timing` line is cumulative and logged at power-of-two submit counts, so per-period figures had to be worked out by hand. It needs a smoke pair from someone with a title before it can be merged. @⁠AlexLopezDevelop, if you run #1034 on your i9-9900K again, this gives the per-2-s figures directly. AI use: Claude Code (Claude Opus 5.5).
Author
Owner

@⁠milesah3ad on GitHub · 2026-11-24 23:19 UTC · original

Write-watch reset strategies on a fast CPU (Ryzen 7 9800X3D, Zen 5, Windows 11 26300): every way of resetting costs about the same per written page, threads don't help, and sibling threads make each reset 2.5–3× dearer. A synthetic bench, no game files: a region committed with MEM_WRITE_WATCH, K pages written before each look, looks like title_textures::take_written (16,384-entry buffer, resume).

4 GiB, scattered writes, median of 5 (ms per look):

strategy K=0 K=262,144 K=1,048,576 (663k unique)
GetWriteWatch(FLAG_RESET) (what XCL does) 2.1 15.9 29.0
no reset (the floor, not race-free) 2.1 4.5 6.6
ResetWriteWatch over the region, no look 0.5 15.2 24.8
look, then ResetWriteWatch per written 64 KiB block 2.3 47.8 77.3
FLAG_RESET split over 2 / 4 / 8 threads – 15.1 / 16.2 / 16.6 29.5 (4 thr)
  • The reset itself costs about 33–40 ns per written page here, against about 160 ns from @⁠AlexLopezDevelop's i9-9900K table. The API has no cheaper reset, and splitting it across threads gains nothing.
  • With busy sibling threads (1 GiB, K=65,536, threads of the same process spinning and touching their own memory): the reset part costs 44 ns per page with 0 busy, 84 ns with 4, 127 ns with 8, 115 ns with 15. That fits TLB shootdowns reaching the process's other cores. It is 2.5–3×, not the ~11 µs per dirty page that the game-run sparse windows timing lines work out to. So that gap is still unexplained: page faults on re-dirtied pages, VirtualQuery walks, or lock waits are left.
  • Since the cost is per written page, a design idea alongside #1034's cold blocks: hot blocks. A 64 KiB block that was written in each of N looks goes out of the look, gets no reset, and is uploaded every submit, which it already was. When it stops being written it comes back with one reset. That saves the reset only while a block stays hot, at no extra copy. Measuring it needs a title.

Not tested: any title, Intel / other AMD, how many pages a world-load look really resets. Bench source and raw output can be shared if useful.

AI use: Claude Code (Claude Opus 5.5) wrote and ran the bench on the machine above and wrote this. I checked the numbers against the output.

**@⁠milesah3ad** on GitHub · 2026-11-24 23:19 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7147273087) **Write-watch reset strategies on a fast CPU (Ryzen 7 9800X3D, Zen 5, Windows 11 26300): every way of resetting costs about the same per written page, threads don't help, and sibling threads make each reset 2.5–3× dearer.** A synthetic bench, no game files: a region committed with `MEM_WRITE_WATCH`, K pages written before each look, looks like `title_textures::take_written` (16,384-entry buffer, resume). **4 GiB, scattered writes, median of 5 (ms per look):** | strategy | K=0 | K=262,144 | K=1,048,576 (663k unique) | |---|---:|---:|---:| | `GetWriteWatch(FLAG_RESET)` (what XCL does) | 2.1 | 15.9 | 29.0 | | no reset (the floor, not race-free) | 2.1 | 4.5 | 6.6 | | `ResetWriteWatch` over the region, no look | 0.5 | 15.2 | 24.8 | | look, then `ResetWriteWatch` per written 64 KiB block | 2.3 | 47.8 | 77.3 | | `FLAG_RESET` split over 2 / 4 / 8 threads | – | 15.1 / 16.2 / 16.6 | 29.5 (4 thr) | - The reset itself costs about **33–40 ns per written page** here, against about 160 ns from @⁠AlexLopezDevelop's i9-9900K table. The API has no cheaper reset, and splitting it across threads gains nothing. - **With busy sibling threads** (1 GiB, K=65,536, threads of the same process spinning and touching their own memory): the reset part costs 44 ns per page with 0 busy, 84 ns with 4, 127 ns with 8, 115 ns with 15. That fits TLB shootdowns reaching the process's other cores. It is 2.5–3×, not the ~11 µs per dirty page that the game-run `sparse windows timing` lines work out to. So that gap is still unexplained: page faults on re-dirtied pages, `VirtualQuery` walks, or lock waits are left. - Since the cost is per *written* page, a design idea alongside #1034's cold blocks: **hot blocks**. A 64 KiB block that was written in each of N looks goes out of the look, gets no reset, and is uploaded every submit, which it already was. When it stops being written it comes back with one reset. That saves the reset only while a block stays hot, at no extra copy. Measuring it needs a title. **Not tested:** any title, Intel / other AMD, how many pages a world-load look really resets. Bench source and raw output can be shared if useful. AI use: Claude Code (Claude Opus 5.5) wrote and ran the bench on the machine above and wrote this. I checked the numbers against the output.
Author
Owner

@⁠brandostrong on GitHub · 2026-11-25 03:54 UTC · original

PR #2090 removes this look for the buffer half: with XCL_SPARSE_DIRECT=1 each sparse window is an
imported heap and a buffer the title places in one is that memory, so there are no mapped tiles to
scan and the look does not run at all.

Matched 180 s runs, same title, RTX 4090, warm caches, same profile copy, same driving:

tiled (main) XCL_SPARSE_DIRECT=1
write-watch look 7 096 ms cumulative at t = 41 s (24 667 ms at t = 130 s in a longer run) none
upload at the same point 240 ms none for buffers
sparse video-memory pools 7 445 MB 0

What still needs the look afterwards: textures the title places in sparse windows are still detiled PC
copies — that is why the windows stay write-watched and why only mapped_ranges() goes empty, not the
watch itself. #1034 and #1058 shrink the same look from the scan side; they are complementary to this,
not alternatives.

Claude Code, Claude Opus 5.5 — the numbers are from runs made here.

**@⁠brandostrong** on GitHub · 2026-11-25 03:54 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7152353822) PR #2090 removes this look for the buffer half: with `XCL_SPARSE_DIRECT=1` each sparse window is an imported heap and a buffer the title places in one *is* that memory, so there are no mapped tiles to scan and the look does not run at all. Matched 180 s runs, same title, RTX 4090, warm caches, same profile copy, same driving: | | tiled (`main`) | `XCL_SPARSE_DIRECT=1` | |---|---|---| | write-watch look | 7 096 ms cumulative at t = 41 s (24 667 ms at t = 130 s in a longer run) | none | | upload at the same point | 240 ms | none for buffers | | sparse video-memory pools | 7 445 MB | 0 | What still needs the look afterwards: textures the title places in sparse windows are still detiled PC copies — that is why the windows stay write-watched and why only `mapped_ranges()` goes empty, not the watch itself. #1034 and #1058 shrink the same look from the scan side; they are complementary to this, not alternatives. Claude Code, Claude Opus 5.5 — the numbers are from runs made here.
Author
Owner

@⁠KOLESNiii on GitHub · 2026-11-25 17:43 UTC · original

Another data point, from a slower CPU: a look costs 5–6 ms in menus, ~65 % of the submitting thread.

My title, main 3f4495a, release (scripts/smoke.ps1, 75 s): RTX 2070 SUPER (32.0.16.2140), Ryzen 5 3600XT, Windows 11 26300. These are the cumulative sparse windows timing lines, which time the whole look in title_textures::refresh_once:

submits at write-watch total dirty pages total
256 10.5 s 269 ms 135,426
512 35.9 s 954 ms 314,188
1,024 40.4 s 4,035 ms 328,067
2,048 49.0 s 9,582 ms 355,333
  • Submits 513–1,024: 3,081 ms of looks in 4.5 s of wall time, 6.0 ms a look.
  • Submits 1,025–2,048: 5,547 ms in 8.5 s, 5.4 ms a look, at ~27 written pages a look. The title is in its menus at 30 presents and ~120 submits a second.
  • In the same 1,024 submits, the chunk scan took 11 ms and the uploads 70 ms. The look is almost all of this phase.
  • While the title was loading, a look cost ~1 ms (submits 129–256: 142 ms). It grew five-fold by the menus, with 14.9 GB committed by the process and sparse pools at 896 MB.

That is 6–7× the 0.83 ms a look measured at the top of this issue, on a Zen 2 desktop CPU. I have not tried #1034 or #2090's XCL_SPARSE_DIRECT=1 on it yet.

Numbers taken from the run's xcl.log with Claude Code (Claude Opus 5.5).

**@⁠KOLESNiii** on GitHub · 2026-11-25 17:43 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7169919364) **Another data point, from a slower CPU: a look costs 5–6 ms in menus, ~65 % of the submitting thread.** My title, `main` 3f4495a, release (`scripts/smoke.ps1`, 75 s): RTX 2070 SUPER (32.0.16.2140), Ryzen 5 3600XT, Windows 11 26300. These are the cumulative `sparse windows timing` lines, which time the whole look in `title_textures::refresh_once`: | submits | at | write-watch total | dirty pages total | |---|---|---|---| | 256 | 10.5 s | 269 ms | 135,426 | | 512 | 35.9 s | 954 ms | 314,188 | | 1,024 | 40.4 s | 4,035 ms | 328,067 | | 2,048 | 49.0 s | 9,582 ms | 355,333 | - Submits 513–1,024: 3,081 ms of looks in 4.5 s of wall time, **6.0 ms a look**. - Submits 1,025–2,048: 5,547 ms in 8.5 s, **5.4 ms a look**, at ~27 written pages a look. The title is in its menus at 30 presents and ~120 submits a second. - In the same 1,024 submits, the chunk scan took 11 ms and the uploads 70 ms. The look is almost all of this phase. - While the title was loading, a look cost ~1 ms (submits 129–256: 142 ms). It grew five-fold by the menus, with 14.9 GB committed by the process and sparse pools at 896 MB. That is 6–7× the 0.83 ms a look measured at the top of this issue, on a Zen 2 desktop CPU. I have not tried #1034 or #2090's `XCL_SPARSE_DIRECT=1` on it yet. *Numbers taken from the run's `xcl.log` with Claude Code (Claude Opus 5.5).*
Author
Owner

@⁠milesah3ad on GitHub · 2026-11-26 10:49 UTC · original

Follow-up to my bench above, measured in the newer retail title of #505 this time: in the world, the submitting thread spends most of its time in title_textures::refresh_once, and above all in GetWriteWatch. Each written page costs about 2.9 µs there, against 33–40 ns in the bench.

Setup: RTX 5080 16 GB (621.24), Ryzen 7 9800X3D, 64 GB RAM, Windows 11, release build.

  • Tree: @⁠MacieGx's lab branch at 4ae4e70, run with the env from their #505 comment, except XCL_WS_MAX_MB. I added XCL_PSO_WAIT_MS=50 and XCL_NETWORK=0.
  • Input: XCL_PRESS_AT=25:A,30:A,35:A,40:A,62:A,64:A.
  • Before the runs: a full xcl shaders --precompile pass, all four stages, with --pipelines for cs and ms. The runs also start with the driver blobs from the runs before them.

Compiling is no longer what holds frames back. One 720 s run on the warm caches:

  • Waits for two-pass MS pipelines: 76, 1.8 s in all.
  • Gated graphics compiles: 8, 0.03 s in all.
  • Even so, presents per second go 23.4 (0–30 s) → 29.8 → 5.1 (60–90 s), then 0.7–1.3 from 90 s to 300 s. The world load starts at about 60 s.
  • That is the same rate as the ~1 present per second in the #505 comment linked above, on the same card.

Where the submitting thread is (XCL_THREAD_DUMP_AT, 12 dumps between 110 s and 172 s, symbols from the build's PDB). These are the 12 samples of the title thread that calls ExecuteCommandLists (QUEUE_SLOTS::f → queue_dispatch → q_execute_command_lists):

where samples
title_textures::refresh → refresh_once → take_written → GetWriteWatch 7
refresh_once, own code 2
refresh_once → texture::upload_batch → texture::layout 1
present_x → fence::wait 1
in the title, not in XCL 1

The cumulative sparse windows timing lines of the same run:

at write-watch dirty pages chunk scan upload
40.5 s 9,368 ms 3,704,342 2,822 ms 805 ms
127.0 s 34,581 ms 12,355,946 6,270 ms 3,433 ms
change over 86.6 s +25,213 ms (29 % of wall time) +8,651,604 +3,448 ms +2,628 ms
  • That is about 100,000 written pages a second, at ~2.9 µs a page for the look. The bench above measured 33–40 ns per page for the reset (2.5–3× more with busy sibling threads).
  • So in the title, almost all of the per-page cost is something the bench doesn't reproduce. The candidates from above are still faults on re-dirtied pages, or how many VADs and how much address space the look walks.

Switches that didn't change it (one run each):

  • XCL_PAGE_BUDGET_MB=4096 instead of 1024. Eviction still reached 20.6 GB by 85 s, against 21.0 GB with 1024. Presents per second were the same.
  • XCL_SHADOW_TILED off, so the whole-window shadow is no longer watched. Write-watch was 8,834 ms at 38.6 s, against 9,368 ms at 40.5 s with it on. So that watch isn't the cost. Without it, though, video memory reached 15.5 GB and the device was removed at 105 s.
  • XCL_UMA_SHADOW=0, so the coherent window stays in host memory. Presents fell at 60–90 s as before, and the title crashed at 96 s (a read fault at game_scarlett_master.exe+0x288bc4b).
  • Skipping CS_ScreenProbes_ActivateRays as well as the resolve programs: no change.

Also seen:

  • A crash on Series X. The same null-pointer write at game_scarlett_master.exe+0x23cf683 ended three Series X runs, at 291 s, 470 s and 487 s.
  • A crash on Series S. With XCL_DEVICE_TYPE=lockhart, 2 of 2 runs stopped at a title int3 at game_scarlett_master.exe+0xb18de7, about 3 s after the A press at 30 s.

What this suggests: making the look cheaper per written page, or taking it off the submitting thread, would matter more here than anything left on the compile side. One option is the "hot blocks" idea above: a block written in every look is uploaded without a reset. On this title, #2090's direct windows don't help: on NVIDIA they move the reads onto PCIe, as reported in its comments.

Not tested: AMD, another CPU, a profiler other than the thread dumps.

AI use: Claude Code (Claude Opus 5.5) ran the runs, read the logs, resolved the stacks and wrote this. Every number above is from the runs' xcl.log.

**@⁠milesah3ad** on GitHub · 2026-11-26 10:49 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7189891592) **Follow-up to my bench above, measured in the newer retail title of #505 this time: in the world, the submitting thread spends most of its time in `title_textures::refresh_once`, and above all in `GetWriteWatch`. Each written page costs about 2.9 µs there, against 33–40 ns in the bench.** **Setup:** RTX 5080 16 GB (621.24), Ryzen 7 9800X3D, 64 GB RAM, Windows 11, release build. - Tree: @⁠MacieGx's lab branch at `4ae4e70`, run with the env from their [#505 comment](https://git.gtahub.st/github/xcl-dev--xcl/issues/505), except `XCL_WS_MAX_MB`. I added `XCL_PSO_WAIT_MS=50` and `XCL_NETWORK=0`. - Input: `XCL_PRESS_AT=25:A,30:A,35:A,40:A,62:A,64:A`. - Before the runs: a full `xcl shaders --precompile` pass, all four stages, with `--pipelines` for cs and ms. The runs also start with the driver blobs from the runs before them. **Compiling is no longer what holds frames back.** One 720 s run on the warm caches: - Waits for two-pass MS pipelines: 76, 1.8 s in all. - Gated graphics compiles: 8, 0.03 s in all. - Even so, presents per second go 23.4 (0–30 s) → 29.8 → 5.1 (60–90 s), then 0.7–1.3 from 90 s to 300 s. The world load starts at about 60 s. - That is the same rate as the ~1 present per second in the #505 comment linked above, on the same card. **Where the submitting thread is** (`XCL_THREAD_DUMP_AT`, 12 dumps between 110 s and 172 s, symbols from the build's PDB). These are the 12 samples of the title thread that calls `ExecuteCommandLists` (`QUEUE_SLOTS::f` → `queue_dispatch` → `q_execute_command_lists`): | where | samples | |---|---:| | `title_textures::refresh` → `refresh_once` → `take_written` → `GetWriteWatch` | 7 | | `refresh_once`, own code | 2 | | `refresh_once` → `texture::upload_batch` → `texture::layout` | 1 | | `present_x` → `fence::wait` | 1 | | in the title, not in XCL | 1 | **The cumulative `sparse windows timing` lines of the same run:** | at | write-watch | dirty pages | chunk scan | upload | |---|---:|---:|---:|---:| | 40.5 s | 9,368 ms | 3,704,342 | 2,822 ms | 805 ms | | 127.0 s | 34,581 ms | 12,355,946 | 6,270 ms | 3,433 ms | | change over 86.6 s | **+25,213 ms (29 % of wall time)** | +8,651,604 | +3,448 ms | +2,628 ms | - That is about **100,000 written pages a second, at ~2.9 µs a page** for the look. The bench above measured 33–40 ns per page for the reset (2.5–3× more with busy sibling threads). - So in the title, almost all of the per-page cost is something the bench doesn't reproduce. The candidates from above are still faults on re-dirtied pages, or how many VADs and how much address space the look walks. **Switches that didn't change it** (one run each): - `XCL_PAGE_BUDGET_MB=4096` instead of 1024. Eviction still reached 20.6 GB by 85 s, against 21.0 GB with 1024. Presents per second were the same. - `XCL_SHADOW_TILED` off, so the whole-window shadow is no longer watched. Write-watch was 8,834 ms at 38.6 s, against 9,368 ms at 40.5 s with it on. So that watch isn't the cost. Without it, though, video memory reached 15.5 GB and the device was removed at 105 s. - `XCL_UMA_SHADOW=0`, so the coherent window stays in host memory. Presents fell at 60–90 s as before, and the title crashed at 96 s (a read fault at `game_scarlett_master.exe+0x288bc4b`). - Skipping `CS_ScreenProbes_ActivateRays` as well as the resolve programs: no change. **Also seen:** - **A crash on Series X.** The same null-pointer write at `game_scarlett_master.exe+0x23cf683` ended three Series X runs, at 291 s, 470 s and 487 s. - **A crash on Series S.** With `XCL_DEVICE_TYPE=lockhart`, 2 of 2 runs stopped at a title `int3` at `game_scarlett_master.exe+0xb18de7`, about 3 s after the A press at 30 s. **What this suggests:** making the look cheaper per written page, or taking it off the submitting thread, would matter more here than anything left on the compile side. One option is the "hot blocks" idea above: a block written in every look is uploaded without a reset. On this title, #2090's direct windows don't help: on NVIDIA they move the reads onto PCIe, as reported in its comments. **Not tested:** AMD, another CPU, a profiler other than the thread dumps. AI use: Claude Code (Claude Opus 5.5) ran the runs, read the logs, resolved the stacks and wrote this. Every number above is from the runs' `xcl.log`.
Author
Owner

@⁠milesah3ad on GitHub · 2026-11-26 11:11 UTC · original

Correction to my comment above: the look's cost in the title doesn't go with written pages. It goes with the address space walked, and that address space comes from the merging of watched ranges.

I counted it with a local probe in refresh_once, logging every 512 looks: number of ranges, MB watched, µs per look, dirty pages per look. Same tree, card and input as above.

WATCH_GAP in menus in the world (100–200 s) presents/s, 90–200 s
64 MiB (as is) 7–19 ranges, 5.2–6.0 GB, 2.2–3.8 ms/look 41–48 ranges, 22.8–23.7 GB, 11.3–13.1 ms/look, ~2,400 dirty/look 0.8–1.0
16 MiB (local switch) – ~155 ranges, 19.5–19.9 GB, 9.3–10.3 ms/look 0.1–0.9
4 MiB (local switch) – 570–650 ranges, 16.4–16.6 GB, 9.0–10.3 ms/look 0.1–1.5
  • That's about 0.5 ms per GB watched. The ~2.9 µs per written page I gave was just the time divided by the dirty pages.
  • Even at a 4 MiB gap the wanted ranges cover ~16 GB: the mapped sparse tiles plus the title textures, spread over the sparse windows and the 24 GB graphics reservation. A smaller gap only removes ~30 % of the walk.
  • The look is ~20–30 % of the submitting thread in the world: 34 s of write-watch over the last ~160 s of a 200 s run. That doesn't account for ~1 present per second on its own. The 12 thread samples above over-weighted it.
  • So narrowing what is watched helps less than not watching it on this thread at all: watching only tiles mapped since the last look, or a second thread that looks ahead. The GPU side still needs its own measurement here.

One probe run per gap size, 200 s each, so treat them as single measurements. AI use as above: Claude Code (Claude Opus 5.5) wrote the probe, ran the runs and wrote this; the numbers are from the runs' xcl.log.

**@⁠milesah3ad** on GitHub · 2026-11-26 11:11 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7190394225) **Correction to my comment above:** the look's cost in the title doesn't go with written pages. It goes with the address space walked, and that address space comes from the merging of watched ranges. I counted it with a local probe in `refresh_once`, logging every 512 looks: number of ranges, MB watched, µs per look, dirty pages per look. Same tree, card and input as above. | `WATCH_GAP` | in menus | in the world (100–200 s) | presents/s, 90–200 s | |---|---|---|---| | 64 MiB (as is) | 7–19 ranges, 5.2–6.0 GB, 2.2–3.8 ms/look | 41–48 ranges, **22.8–23.7 GB, 11.3–13.1 ms/look**, ~2,400 dirty/look | 0.8–1.0 | | 16 MiB (local switch) | – | ~155 ranges, 19.5–19.9 GB, 9.3–10.3 ms/look | 0.1–0.9 | | 4 MiB (local switch) | – | 570–650 ranges, 16.4–16.6 GB, 9.0–10.3 ms/look | 0.1–1.5 | - That's about 0.5 ms per GB watched. The ~2.9 µs per written page I gave was just the time divided by the dirty pages. - Even at a 4 MiB gap the wanted ranges cover ~16 GB: the mapped sparse tiles plus the title textures, spread over the sparse windows and the 24 GB graphics reservation. A smaller gap only removes ~30 % of the walk. - The look is ~20–30 % of the submitting thread in the world: 34 s of write-watch over the last ~160 s of a 200 s run. That doesn't account for ~1 present per second on its own. The 12 thread samples above over-weighted it. - So narrowing what is watched helps less than not watching it on this thread at all: watching only tiles mapped since the last look, or a second thread that looks ahead. The GPU side still needs its own measurement here. One probe run per gap size, 200 s each, so treat them as single measurements. AI use as above: Claude Code (Claude Opus 5.5) wrote the probe, ran the runs and wrote this; the numbers are from the runs' `xcl.log`.
Author
Owner

@⁠milesah3ad on GitHub · 2026-11-26 11:54 UTC · original

@⁠MacieGx's hot-block look (4c35f8fb, behind XCL_WATCH_HOT=1 since 240037e7) on the RTX 5080 16 GB: one pair of 200 s runs on lab 782fde74, same env, input and warm caches as my comments above.

XCL_WATCH_HOT off =1
write-watch, cumulative at the end 35,369 ms (12,475,864 dirty pages) 26,190 ms (12,085,258)
chunk scan / upload 6,058 / 3,543 ms 6,123 / 3,498 ms
presents/s, 90–200 s 0.5–1.3 0.7–1.2
nvidia-smi GPU / memory controller, in the world 55 % / 3 % 41 % / 3 %
exit 0x0, no removal 0x0, no removal
  • The look costs 26 % less. Presents per second don't move, which fits the 20–30 % share measured above.
  • Not tested here: the crash at 392 s of your run O10. Neither run reached 392 s; both were 200 s.

AI use: Claude Code (Claude Opus 5.5) ran the runs and wrote this; the numbers are from the runs' xcl.log and the nvidia-smi log.

**@⁠milesah3ad** on GitHub · 2026-11-26 11:54 UTC · [original](https://github.com/xcl-dev/xcl/issues/582#issuecomment-7191308396) **@⁠MacieGx's hot-block look (`4c35f8fb`, behind `XCL_WATCH_HOT=1` since `240037e7`) on the RTX 5080 16 GB:** one pair of 200 s runs on lab `782fde74`, same env, input and warm caches as my comments above. | | `XCL_WATCH_HOT` off | `=1` | |---|---|---| | write-watch, cumulative at the end | 35,369 ms (12,475,864 dirty pages) | **26,190 ms** (12,085,258) | | chunk scan / upload | 6,058 / 3,543 ms | 6,123 / 3,498 ms | | presents/s, 90–200 s | 0.5–1.3 | 0.7–1.2 | | `nvidia-smi` GPU / memory controller, in the world | 55 % / 3 % | 41 % / 3 % | | exit | 0x0, no removal | 0x0, no removal | - The look costs 26 % less. Presents per second don't move, which fits the 20–30 % share measured above. - Not tested here: the crash at 392 s of your run O10. Neither run reached 392 s; both were 200 s. AI use: Claude Code (Claude Opus 5.5) ran the runs and wrote this; the numbers are from the runs' `xcl.log` and the `nvidia-smi` log.
This discussion has been locked. Commenting is limited to contributors.
No description provided.