D3D12.X: coalesce contiguous WriteProcessMemory runs in write_changed_pages #3237

Merged
Lakanya merged 1 commit from upstream-pr/3237 into main 2026-11-29 12:20:27 +00:00
Lakanya commented 2026-11-28 23:40:11 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Lakanya on 2026-11-28T23:40:11Z.


title_textures::publish_download() holds the global TEXTURES mutex while write_changed_pages() writes reverse-tiled GPU texture readbacks back into title memory. Previously, write_changed_pages() called VirtualQuery + WriteProcessMemory(GetCurrentProcess(), ...) once per 4 KiB page. On Windows, each WriteProcessMemory triggers NtFlushInstructionCache across CPU cores; on multi-megabyte GPU-written textures (e.g. an 8.92 MB texture = 2,178 pages), this held TEXTURES for 24+ seconds and stalled CreatePlacedResourceX, ExecuteCommandLists, CopyTextureRegion, and memory_report::snapshot.

This PR coalesces contiguous changed 4 KiB pages into runs and issues one VirtualQuery per VM region and one WriteProcessMemory per contiguous changed run, while continuing to skip unchanged pages (preserving MEM_WRITE_WATCH cleanliness) and failing closed on read-only, PAGE_GUARD, or unmapped pages.

What is in it

  • crates/xcl/src/hle/d3d12x/title_textures.rs: add changed_page_runs(), update write_changed_pages() to coalesce contiguous changed 4 KiB pages per VM region into a single WriteProcessMemory call, and add unit tests changed_page_runs_coalesces_contiguous_and_skips_unchanged and write_changed_pages_coalesces_writes_and_respects_vm_protections.

Tested

  • Hardware: NVIDIA GeForce RTX 5070 Laptop GPU (8 GB, driver 617.71), Windows 11 Pro 26300, rustc 1.100.0 (0ef1bc386 2026-11-09), debug & release.
  • New unit tests (cargo test -p xcl --lib -- write_changed_pages changed_page_runs --nocapture): 2 passed, 0 failed, 0 ignored.
  • cargo test --workspace --release --no-fail-fast -j 6 -- --test-threads=4: 135 passed, 4 failed, 20 ignored across integration/crate test binaries (27 SKIPPED GPU tests: wave64 / unsupported f16-f32 per-lane variants / heap windows); xcl --lib exited early (0x80004005) on an unrelated in-process stop_title test (tracked in #3187) and 4 gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_* failed; after cargo build --workspace --release -j 6, cargo test -p xcl --release --test e2e -- --test-threads=4: 4 passed, 1 failed (e2e).
  • Live retail title (in-world 3D entry, same hardware, XCL_ACTIVITY=1, XCL_LOOK_STATS=2): 8.92 MB GPU-written texture publish dropped from 24,023 ms (TEXTURES.lock() hold, 0 3D presents) to 14–30 ms (1 WriteProcessMemory call, 0 TEXTURES.lock() holds >= 200 ms, 10 3D presents in 12 s).

Regression run
Both runs used XCL_PREPARE=0, XCL_DEVICE_TYPE=lockhart, XCL_TEXTURE_LEVEL_PAGES=1, XCL_SMALL_TEXTURES=1.

xcl-smoke v1
commit: 227d2cb388f103268dac7635ea720eb3e5352d4e
gpu: NVIDIA GeForce RTX 5070 Laptop GPU
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1600 (PresentX 1600)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 12746 MB
xcl-smoke v1
commit: b11fe096e2dcb554b47044c6baa33d9e1931f30e
gpu: NVIDIA GeForce RTX 5070 Laptop GPU
title: 2c508222
seconds: 60
exit: 0x0
frames shown: 1608 (PresentX 1608)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 12493 MB

Not tested

  • AMD or Intel GPUs, wave64 hardware, and Linux/Wine.
  • The 60 s smoke runs cover startup through the menu; the 8.92 MB write_changed_pages speedup was measured separately on a 210 s in-world run on the same title.

AI use

  • Antigravity (Gemini 4 Neon) profiled the TEXTURES.lock() stall, implemented changed_page_runs() and coalesced write_changed_pages(), wrote and ran the unit tests and paired smoke runs, and drafted this description.
<!-- greyfinch-sync:ivall/xcl:issue:5545706142 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3237). Originally posted by [Lakanya](https://github.com/Lakanya) on 2026-11-28T23:40:11Z. --- `title_textures::publish_download()` holds the global `TEXTURES` mutex while `write_changed_pages()` writes reverse-tiled GPU texture readbacks back into title memory. Previously, `write_changed_pages()` called `VirtualQuery` + `WriteProcessMemory(GetCurrentProcess(), ...)` once per 4 KiB page. On Windows, each `WriteProcessMemory` triggers `NtFlushInstructionCache` across CPU cores; on multi-megabyte GPU-written textures (e.g. an 8.92 MB texture = 2,178 pages), this held `TEXTURES` for 24+ seconds and stalled `CreatePlacedResourceX`, `ExecuteCommandLists`, `CopyTextureRegion`, and `memory_report::snapshot`. This PR coalesces contiguous changed 4 KiB pages into runs and issues one `VirtualQuery` per VM region and one `WriteProcessMemory` per contiguous changed run, while continuing to skip unchanged pages (preserving `MEM_WRITE_WATCH` cleanliness) and failing closed on read-only, `PAGE_GUARD`, or unmapped pages. **What is in it** - `crates/xcl/src/hle/d3d12x/title_textures.rs`: add `changed_page_runs()`, update `write_changed_pages()` to coalesce contiguous changed 4 KiB pages per VM region into a single `WriteProcessMemory` call, and add unit tests `changed_page_runs_coalesces_contiguous_and_skips_unchanged` and `write_changed_pages_coalesces_writes_and_respects_vm_protections`. **Tested** - Hardware: NVIDIA GeForce RTX 5070 Laptop GPU (8 GB, driver `617.71`), Windows 11 Pro 26300, `rustc 1.100.0 (0ef1bc386 2026-11-09)`, debug & release. - New unit tests (`cargo test -p xcl --lib -- write_changed_pages changed_page_runs --nocapture`): 2 passed, 0 failed, 0 ignored. - `cargo test --workspace --release --no-fail-fast -j 6 -- --test-threads=4`: 135 passed, 4 failed, 20 ignored across integration/crate test binaries (27 `SKIPPED` GPU tests: wave64 / unsupported f16-f32 per-lane variants / heap windows); `xcl --lib` exited early (`0x80004005`) on an unrelated in-process `stop_title` test (tracked in #3187) and 4 `gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_*` failed; after `cargo build --workspace --release -j 6`, `cargo test -p xcl --release --test e2e -- --test-threads=4`: 4 passed, 1 failed (`e2e`). - Live retail title (in-world 3D entry, same hardware, `XCL_ACTIVITY=1`, `XCL_LOOK_STATS=2`): 8.92 MB GPU-written texture publish dropped from `24,023 ms` (`TEXTURES.lock()` hold, `0` 3D presents) to `14–30 ms` (`1` `WriteProcessMemory` call, `0` `TEXTURES.lock()` holds `>= 200 ms`, `10` 3D presents in 12 s). **Regression run** Both runs used `XCL_PREPARE=0`, `XCL_DEVICE_TYPE=lockhart`, `XCL_TEXTURE_LEVEL_PAGES=1`, `XCL_SMALL_TEXTURES=1`. ``` xcl-smoke v1 commit: 227d2cb388f103268dac7635ea720eb3e5352d4e gpu: NVIDIA GeForce RTX 5070 Laptop GPU title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1600 (PresentX 1600) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 12746 MB ``` ``` xcl-smoke v1 commit: b11fe096e2dcb554b47044c6baa33d9e1931f30e gpu: NVIDIA GeForce RTX 5070 Laptop GPU title: 2c508222 seconds: 60 exit: 0x0 frames shown: 1608 (PresentX 1608) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 12493 MB ``` **Not tested** - AMD or Intel GPUs, wave64 hardware, and Linux/Wine. - The 60 s smoke runs cover startup through the menu; the 8.92 MB `write_changed_pages` speedup was measured separately on a 210 s in-world run on the same title. **AI use** - Antigravity (Gemini 4 Neon) profiled the `TEXTURES.lock()` stall, implemented `changed_page_runs()` and coalesced `write_changed_pages()`, wrote and ran the unit tests and paired smoke runs, and drafted this description.
Kalmarv commented 2026-11-29 01:14:35 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-11-29T01:14:35Z.


merge-check
base: fa204595a4
head: b11fe096e2
merge: clean (trial merge 984566ad2ed772872ac77a01ad323921064809a3, local, not pushed; git diff --check clean)
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> 2610 passed, 0 failed, 49 ignored; SKIPPED: 26 (21 no wave64 on this 32-lane GPU, 3 per-lane f16/f32 forms refused (#1426 semantics), 2 no heap windows); failing: none. Both new tests ran and passed: changed_page_runs_coalesces_contiguous_and_skips_unchanged and write_changed_pages_coalesces_writes_and_respects_vm_protections (write-watch shows the unchanged page isn't dirtied; read-only and guard pages fail closed and the guard stays armed).
review: none blocking; whole diff read (title_textures.rs only). changed_page_runs uses the same 4 KiB page slicing as before, unaligned start included, and merges adjacent changed slices. write_changed_pages keeps the same acceptance test (committed, writable, not guard), now applied once per VirtualQuery region instead of once per page. All pages of one region share state and protection, so at query time this is equivalent, and writes are split at region ends. On failure it still returns false after the earlier runs are written, as before. One note, not a blocker: region_end is reused across runs too, so a page whose protection the title changes after the first query (made read-only or guarded) isn't seen until the next region. WriteProcessMemory can write through read-only protection, which is why the per-page check existed. The window is the duration of one write_changed_pages call (it was one page before, so it was never race-free), and a concurrent unmap still makes WriteProcessMemory fail.
performance: fewer WriteProcessMemory calls while TEXTURES is held when a GPU-written texture download publishes many contiguous changed pages; no other change. Not measured: nothing counts texture downloads, so I can't show this title reached the path. Title run (release build of the merge, scratch/fast-world.py fast profile, 30 s in world; same cache snapshot and harness as a main fa204595 run): main exit 0, 0 crashes, 0 removals, world entry 90.6 s, peak commit 28,620 MB, 70 WARN lines. This merge: exit 0, 0 crashes, 0 removals, world entry 102.1 s, peak commit 29,091 MB (+1.6 %), 79 WARN lines; failed_pipelines 0, no translation errors. The only new WARN kind is the system-wide "running out of commit" (this process held 28,938 MB; another suite and build were running on the machine at the time). Both runs show 0 fps in the world because the cache doesn't match the translator identity; timings on this shared machine are noise.
verdict: safe to merge
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74, wave32 only), AMD Ryzen 9 9950X, Windows 11 build 26200; rustc 1.99.0, debug test profile, release build for the title run, DXC 1.9.2609 via XCL_DXC_DIR. Claude Code, Claude Opus 5.5: merge, build, suite, title run and full-diff review; this report.

<!-- greyfinch-sync:ivall/xcl:comment:7248654643 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3237#issuecomment-7248654643). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-11-29T01:14:35Z. --- merge-check base: fa204595a488c60c6c5f905244f0172072c9c2a9 head: b11fe096e2dcb554b47044c6baa33d9e1931f30e merge: clean (trial merge 984566ad2ed772872ac77a01ad323921064809a3, local, not pushed; `git diff --check` clean) build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 (XCL_DXC_DIR = DXC 1.9.2609) -> 2610 passed, 0 failed, 49 ignored; SKIPPED: 26 (21 no wave64 on this 32-lane GPU, 3 per-lane f16/f32 forms refused (#1426 semantics), 2 no heap windows); failing: none. Both new tests ran and passed: `changed_page_runs_coalesces_contiguous_and_skips_unchanged` and `write_changed_pages_coalesces_writes_and_respects_vm_protections` (write-watch shows the unchanged page isn't dirtied; read-only and guard pages fail closed and the guard stays armed). review: none blocking; whole diff read (`title_textures.rs` only). `changed_page_runs` uses the same 4 KiB page slicing as before, unaligned start included, and merges adjacent changed slices. `write_changed_pages` keeps the same acceptance test (committed, writable, not guard), now applied once per `VirtualQuery` region instead of once per page. All pages of one region share state and protection, so at query time this is equivalent, and writes are split at region ends. On failure it still returns false after the earlier runs are written, as before. One note, not a blocker: `region_end` is reused across runs too, so a page whose protection the title changes after the first query (made read-only or guarded) isn't seen until the next region. `WriteProcessMemory` can write through read-only protection, which is why the per-page check existed. The window is the duration of one `write_changed_pages` call (it was one page before, so it was never race-free), and a concurrent unmap still makes `WriteProcessMemory` fail. performance: fewer `WriteProcessMemory` calls while `TEXTURES` is held when a GPU-written texture download publishes many contiguous changed pages; no other change. Not measured: nothing counts texture downloads, so I can't show this title reached the path. Title run (release build of the merge, scratch/fast-world.py fast profile, 30 s in world; same cache snapshot and harness as a main fa204595 run): main exit 0, 0 crashes, 0 removals, world entry 90.6 s, peak commit 28,620 MB, 70 WARN lines. This merge: exit 0, 0 crashes, 0 removals, world entry 102.1 s, peak commit 29,091 MB (+1.6 %), 79 WARN lines; `failed_pipelines` 0, no translation errors. The only new WARN kind is the system-wide "running out of commit" (this process held 28,938 MB; another suite and build were running on the machine at the time). Both runs show 0 fps in the world because the cache doesn't match the translator identity; timings on this shared machine are noise. verdict: safe to merge hardware / tool and model: NVIDIA GeForce RTX 5070 Ti 16 GB (driver 610.74, wave32 only), AMD Ryzen 9 9950X, Windows 11 build 26200; rustc 1.99.0, debug test profile, release build for the title run, DXC 1.9.2609 via XCL_DXC_DIR. Claude Code, Claude Opus 5.5: merge, build, suite, title run and full-diff review; this report.
andrewDoing commented 2026-11-29 01:33:52 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T01:33:52Z.


Measured the syscall reduction on Windows (Ryzen 7 5700X3D) at b11fe096. I compiled the parent and PR versions of the production loops with counting wrappers forwarding to the real VirtualQuery and WriteProcessMemory on an owned 16 MiB allocation. Each changed page differed by one byte. All ten runs read back the entire expected allocation.

Changed-page layout VirtualQuery, parent → PR WriteProcessMemory, parent → PR Bytes written on either
Identical buffers 0 → 0 0 → 0 0
All 4,096 pages 4,096 → 1 4,096 → 1 16 MiB
Alternating pages 2,048 → 1 2,048 → 2,048 8 MiB
Eight consecutive pages plus one isolated page per 32 1,152 → 1 1,152 → 256 4.5 MiB
Two changed pages separated by an unchanged read-only page 2 → 2 2 → 2 8 KiB

This quantifies where the optimization helps. Even when alternating changes prevent write coalescing, the region cache eliminates 2,047 queries. Payload remains page-granular in every case. The read-only gap was left untouched. These counts measure the publishing helper only. No title run or wall-time inference.

Tooling: OpenAI Codex generated and ran the synthetic harness and drafted this report.

<!-- greyfinch-sync:ivall/xcl:comment:7248865836 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3237#issuecomment-7248865836). Originally posted by [andrewDoing](https://github.com/andrewDoing) on 2026-11-29T01:33:52Z. --- Measured the syscall reduction on Windows (Ryzen 7 5700X3D) at b11fe096. I compiled the parent and PR versions of the production loops with counting wrappers forwarding to the real VirtualQuery and WriteProcessMemory on an owned 16 MiB allocation. Each changed page differed by one byte. All ten runs read back the entire expected allocation. | Changed-page layout | VirtualQuery, parent → PR | WriteProcessMemory, parent → PR | Bytes written on either | |---|---:|---:|---:| | Identical buffers | 0 → 0 | 0 → 0 | 0 | | All 4,096 pages | 4,096 → 1 | 4,096 → 1 | 16 MiB | | Alternating pages | 2,048 → 1 | 2,048 → 2,048 | 8 MiB | | Eight consecutive pages plus one isolated page per 32 | 1,152 → 1 | 1,152 → 256 | 4.5 MiB | | Two changed pages separated by an unchanged read-only page | 2 → 2 | 2 → 2 | 8 KiB | This quantifies where the optimization helps. Even when alternating changes prevent write coalescing, the region cache eliminates 2,047 queries. Payload remains page-granular in every case. The read-only gap was left untouched. These counts measure the publishing helper only. No title run or wall-time inference. Tooling: OpenAI Codex generated and ran the synthetic harness and drafted this report.
CharlyRien commented 2026-11-29 01:49:39 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by CharlyRien on 2026-11-29T01:49:39Z.


A test of this PR in the world of the retail title. On our setup it removes a freeze we had traced to this very loop before the PR was opened.

Setup

  • RTX 3090 24 GB (Resizable BAR off), driver 616.56, Ryzen 9 5950X, 32 GB RAM, Windows 11 22631, Rust 1.100.0, release.
  • Base: main fa204595, plus #3214 (cherry-picked), plus four local commits of ours that are not related to this PR: our thread sampler and its reader (#3232, off unless XCL_THREAD_SAMPLE is set), and two lab switches (XCL_TEX_KEY_PAD, XCL_TRIM_VIEWS) that are off in both runs.
  • C3: that base, without this PR.
  • C3f: the same tree plus this PR's head b11fe096 (cherry-picked, 9c725b13) and one sampler commit (the sampler writes each sample to its file at once).
  • Same shader cache (prepared once for these identities, no preparation in either run), same translator identities, same scripted A presses.
  • Same env in both: XCL_HUGE_PSO_CONCURRENCY=8, XCL_HUGE_PSO_WANTED_CONCURRENCY=8, XCL_PSO_WAIT_MS=5000, XCL_ACTIVITY=1, XCL_NETWORK=0. C3f also had XCL_THREAD_SAMPLE on from 220 to 370 s, to see the freeze if it came back.
  • One run each.

Measured

C3 (without) C3f (with this PR)
Longest "placed textures in" (activity line, 2 s, all threads) 113,248 ms (5 calls) 2,635 ms (1,593 calls)
Stable world reached at 487.5 s 372.1 s
Presents/s in the world (first ~180 s) 2.36 2.64
Device removals / unhandled exceptions 0 / 0 0 / 0
  • Before that, on main 7db2f391 + #3214 and the same local commits, without this PR, the same title froze in all four runs (C1, C1c, C1e, C1f).
    • In C1 and C1c, "2 placed textures" took 51,784 ms and 287,378 ms.
    • In those runs the title's own watchdog ended the game about 30 s after the last present.

Read (a thread dump taken during C1f's freeze, at 294 s, symbolized with xcl.exe's PDB)

  • xcl-fences: in title_textures::write_changed_pages < complete_fence_downloads < poll_fence_downloads (the code calls it with TEXTURES held, as the description says).
  • A title thread: in Mutex::lock_contended < title_textures::register < device_x::create_placed_resource_x.
  • The submitting thread: in Mutex::lock_contended < title_textures::refresh_parts < refresh_for < prepare_title_submission < q_execute_command_lists.

Deduced

  • That is the cause the description gives. While the per-page VirtualQuery + WriteProcessMemory loop held TEXTURES, placement and submission waited on it.
  • With this PR the longest 2 s total of placement time fell from 113 s to 2.6 s on this title, and the world came about 115 s earlier in this pair.
  • One run each, so the pace difference (2.36 against 2.64) is not a measure of the PR; the freeze is gone in this run.

Not tested / caveats

  • The 3D scene of the world is black on this base (only the UI shows), in both runs. That is unrelated to this PR, so these runs show nothing about image correctness.
  • No scripts/smoke.ps1 pair: these are 550–670 s title runs through our own harness.
  • The sampler was on in C3f only, from 220 to 370 s. It made 19,418 stops, 132.5 µs each on average and 141 ms at the longest, and used 6.3 ms per 250 ms sample. That is a difference between the two runs.
  • AMD and Intel GPUs; other titles.

AI use

  • Claude Code with Claude Opus 5.5 built both trees, ran the title runs, read the logs and the thread dump, and wrote this report. The person running these tests asked for it.
<!-- greyfinch-sync:ivall/xcl:comment:7249038849 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3237#issuecomment-7249038849). Originally posted by [CharlyRien](https://github.com/CharlyRien) on 2026-11-29T01:49:39Z. --- A test of this PR in the world of the retail title. On our setup it removes a freeze we had traced to this very loop before the PR was opened. **Setup** - RTX 3090 24 GB (Resizable BAR off), driver 616.56, Ryzen 9 5950X, 32 GB RAM, Windows 11 22631, Rust 1.100.0, release. - Base: `main` `fa204595`, plus #3214 (cherry-picked), plus four local commits of ours that are not related to this PR: our thread sampler and its reader (#3232, off unless `XCL_THREAD_SAMPLE` is set), and two lab switches (`XCL_TEX_KEY_PAD`, `XCL_TRIM_VIEWS`) that are off in both runs. - **C3**: that base, without this PR. - **C3f**: the same tree plus this PR's head `b11fe096` (cherry-picked, `9c725b13`) and one sampler commit (the sampler writes each sample to its file at once). - Same shader cache (prepared once for these identities, no preparation in either run), same translator identities, same scripted A presses. - Same env in both: `XCL_HUGE_PSO_CONCURRENCY=8`, `XCL_HUGE_PSO_WANTED_CONCURRENCY=8`, `XCL_PSO_WAIT_MS=5000`, `XCL_ACTIVITY=1`, `XCL_NETWORK=0`. C3f also had `XCL_THREAD_SAMPLE` on from 220 to 370 s, to see the freeze if it came back. - One run each. **Measured** | | C3 (without) | C3f (with this PR) | |---|---:|---:| | Longest "placed textures in" (activity line, 2 s, all threads) | 113,248 ms (5 calls) | 2,635 ms (1,593 calls) | | Stable world reached at | 487.5 s | 372.1 s | | Presents/s in the world (first ~180 s) | 2.36 | 2.64 | | Device removals / unhandled exceptions | 0 / 0 | 0 / 0 | - Before that, on `main` `7db2f391` + #3214 and the same local commits, without this PR, the same title froze in all four runs (C1, C1c, C1e, C1f). - In C1 and C1c, "2 placed textures" took 51,784 ms and 287,378 ms. - In those runs the title's own watchdog ended the game about 30 s after the last present. **Read** (a thread dump taken during C1f's freeze, at 294 s, symbolized with xcl.exe's PDB) - `xcl-fences`: in `title_textures::write_changed_pages` < `complete_fence_downloads` < `poll_fence_downloads` (the code calls it with `TEXTURES` held, as the description says). - A title thread: in `Mutex::lock_contended` < `title_textures::register` < `device_x::create_placed_resource_x`. - The submitting thread: in `Mutex::lock_contended` < `title_textures::refresh_parts` < `refresh_for` < `prepare_title_submission` < `q_execute_command_lists`. **Deduced** - That is the cause the description gives. While the per-page `VirtualQuery` + `WriteProcessMemory` loop held `TEXTURES`, placement and submission waited on it. - With this PR the longest 2 s total of placement time fell from 113 s to 2.6 s on this title, and the world came about 115 s earlier in this pair. - One run each, so the pace difference (2.36 against 2.64) is not a measure of the PR; the freeze is gone in this run. **Not tested / caveats** - The 3D scene of the world is black on this base (only the UI shows), in both runs. That is unrelated to this PR, so these runs show nothing about image correctness. - No `scripts/smoke.ps1` pair: these are 550–670 s title runs through our own harness. - The sampler was on in C3f only, from 220 to 370 s. It made 19,418 stops, 132.5 µs each on average and 141 ms at the longest, and used 6.3 ms per 250 ms sample. That is a difference between the two runs. - AMD and Intel GPUs; other titles. **AI use** - Claude Code with Claude Opus 5.5 built both trees, ran the title runs, read the logs and the thread dump, and wrote this report. The person running these tests asked for it.
throny commented 2026-11-29 08:41:46 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-29T08:41:46Z.


merge-check claim
head: b11fe096e2

<!-- greyfinch-sync:ivall/xcl:comment:7253271613 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3237#issuecomment-7253271613). Originally posted by [throny](https://github.com/throny) on 2026-11-29T08:41:46Z. --- merge-check claim head: b11fe096e2dcb554b47044c6baa33d9e1931f30e
throny commented 2026-11-29 09:01:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by throny on 2026-11-29T09:01:03Z.


merge-check
base: d8bd9a38
head: b11fe096e2
merge: clean
build: cargo build --workspace -> ok
tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2620 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at d8bd9a38: 2618 passed, 0 failed, 49 ignored.
review: no blocking finding. Neighbouring changed pages are merged into runs: one region query per memory region and one write per run inside a region, instead of one of each per page. It still writes only changed pages, still fails closed on read-only, guard and uncommitted pages, and splits a write at region boundaries. Note: the region information is now kept across runs, so a protection change after the query is noticed later than before. The run-building function has its own test; the write test also passes on the old code (a regression guard, fine for a performance change).
performance: not measured here.
verdict: safe to merge
hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).

<!-- greyfinch-sync:ivall/xcl:comment:7253479580 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3237#issuecomment-7253479580). Originally posted by [throny](https://github.com/throny) on 2026-11-29T09:01:03Z. --- merge-check base: d8bd9a38 head: b11fe096e2dcb554b47044c6baa33d9e1931f30e merge: clean build: cargo build --workspace -> ok tests: cargo test --workspace --no-fail-fast -- --test-threads=4 -> 2620 passed, 0 failed, 49 ignored (27 SKIPPED lines). Base alone at d8bd9a38: 2618 passed, 0 failed, 49 ignored. review: no blocking finding. Neighbouring changed pages are merged into runs: one region query per memory region and one write per run inside a region, instead of one of each per page. It still writes only changed pages, still fails closed on read-only, guard and uncommitted pages, and splits a write at region boundaries. Note: the region information is now kept across runs, so a protection change after the query is noticed later than before. The run-building function has its own test; the write test also passes on the old code (a regression guard, fine for a performance change). performance: not measured here. verdict: safe to merge hardware / tool and model: RTX 4080 16 GB (621.40), i9-12900K, Windows 11 26300, Rust 1.100.0, debug. Claude Code; merge, build and suite run by Claude Fable 5.2, diff review by Claude Opus 5.5 (every hunk read; nothing run on the GPU beyond the suite).
crosettiremi commented 2026-11-29 19:02:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by crosettiremi on 2026-11-29T19:02:55Z.


An AMD data point for the stall this fixes, from the retail title on a Radeon RX 7900 XT 20 GB (driver 32.0.32029.2010), base fa204595 and d8bd9a38. I have not run this PR's head; our tree got its own change to the same loop the night this was open.

Before: after the first world submit, the copy-back of GPU-written textures took 7 to 15 ms per 4 KiB page here (two virtual-memory queries per page, under the texture lock), about 100 s for 28 to 56 MiB. The title's next queue Signal waited behind it, and in one run the title's own hang watchdog ended the process. After (one write per contiguous run, publication outside the lock): 49 MB in 7.9 ms in the same phase.

One thing our runs add: with the write batched, the remaining cost in this path was the lock, not the writes. If the per-page queries still run under the global texture lock on main after this PR, a second thread's Signal can still wait for the whole batch. I have not checked main after the merge for that.

AI use: Claude Code (Claude Fable 5.2) read the logs and wrote this.

<!-- greyfinch-sync:ivall/xcl:comment:7260964652 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3237#issuecomment-7260964652). Originally posted by [crosettiremi](https://github.com/crosettiremi) on 2026-11-29T19:02:55Z. --- An AMD data point for the stall this fixes, from the retail title on a Radeon RX 7900 XT 20 GB (driver 32.0.32029.2010), base `fa204595` and `d8bd9a38`. I have **not** run this PR's head; our tree got its own change to the same loop the night this was open. Before: after the first world submit, the copy-back of GPU-written textures took 7 to 15 ms per 4 KiB page here (two virtual-memory queries per page, under the texture lock), about 100 s for 28 to 56 MiB. The title's next queue `Signal` waited behind it, and in one run the title's own hang watchdog ended the process. After (one write per contiguous run, publication outside the lock): 49 MB in 7.9 ms in the same phase. One thing our runs add: with the write batched, the remaining cost in this path was the lock, not the writes. If the per-page queries still run under the global texture lock on `main` after this PR, a second thread's `Signal` can still wait for the whole batch. I have not checked `main` after the merge for that. AI use: Claude Code (Claude Fable 5.2) read the logs and wrote this.
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!3237
No description provided.