D3D12.X: tighten write-watch merge gap to 4 MiB and add opt-in cold-chunk tiering #2891
No reviewers
Labels
No labels
accessibility
bug
documentation
duplicate
enhancement
goal:world-load
good first issue
help wanted
invalid
keep-open
off-goal
question
stale
test-only
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/xcl-dev--xcl!2891
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2891"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@Saksukella on GitHub · 2026-11-26 21:51 UTC · original
Saksukella:perf/write-watch-hot-cold-tiering→amd-dev· +691 −23 · 1 files · 2 commits · openTightens
title_texturesMEM_WRITE_WATCHrange coalescing (WATCH_GAP) from 64 MiB to 4 MiB so sparse texture allocations no longer over-bridge huge unrelated address gaps, and adds an opt-in 16 MiB hot/cold chunk tiering mode (XCL_WRITE_WATCH_TIER=1) that moves clean cold chunks to frame boundaries while keeping default same-frame freshness identical toamd-dev.Summary of changes (
crates/xcl/src/hle/d3d12x/title_textures.rs)WATCH_GAP = 4 << 20):WATCH_GAPfrom 64 MiB to 4 MiB without skipping any watched range on any submit, reducingGetWriteWatchscan footprint (~2.28x faster in the 1.5 GiB resident microbenchmark) with zero stale-read risk.XCL_WRITE_WATCH_TIERis off (the default),cached_watch_ranges()skips 16 MiB chunk splitting so there is zero extra syscall overhead.XCL_WRITE_WATCH_TIER=1, default0;XCL_WRITE_WATCH_COLD_STRIDE, default1):SKIP_LOOK: Cell<bool>withLOOK_HINT: Cell<LookHint>(DirectFull,Skip,Normal,ForceFull) so even whenXCL_WRITE_WATCH_TIER=1is enabled, repeated closed-list resubmits (*submitted == true), untracked lists,XCL_LOOK_SKIP=0, and directrefresh()calls withoutdecide_look()(KickoffX) force a full cold sweep on the current submit.Tested
cargo test -p xcl --lib title_textures -- --test-threads=1):39 passed; 0 failedacross all write-watch, tiering, resubmit hint, and D3D12 GPU upload tests (title_bytes_are_used_in_place_when_all_are_readableis a pre-existing unrelated failure onamd-devbase).same_frame_cold_write_updates_before_present_by_default(verifies same-frame cold-page mutations beforePresentare caught immediately both in default mode and intier=1withforce_cold=true).decide_look_forces_full_sweep_on_resubmitted_list_and_direct_refresh(verifiesDirectFull,Skip,Normal, andForceFulltransitions).MEM_WRITE_WATCHmicrobenchmark (cargo test -p xcl --lib bench_write_watch_hot_cold_tiering -- --ignored --nocapture, 20 frames x 5 submits = 100 submits / 80 looks, 0 missed dirty pages):64 MiBgap,tier=OFF):47.89 ms(0.479 ms/submit,1.00x)4 MiBgap,tier=OFF):20.98 ms(0.210 ms/submit,2.28x)XCL_WRITE_WATCH_TIER=1,stride=1):8.19 ms(0.082 ms/submit,5.85x)XCL_WRITE_WATCH_TIER=1,stride=4):3.74 ms(0.037 ms/submit,12.82x)Not tested
b570a92e.XCL_WRITE_WATCH_TIER=1andXCL_WRITE_WATCH_COLD_STRIDE > 1.Regression run
Baseline (
main,b49be183):This PR (
b570a92e, default settings):AI use
@thehollowedone on GitHub · 2026-11-26 22:27 UTC · original
I found a correctness gap on exact head
0246ae436afd1397a0672ca5ee6a4b7eabaca847. After a watched texture's chunk cools, a CPU write to its existing source can be deferred until a shown frame advances. That is not necessarily the next GPU execution: a title can submit the same closed list again before Present, anddecide_lookexplicitly requests a fresh look on that resubmission.scan_chunksstill skips the cold chunk becausepresent::presents()has not changed; with no other dirty pages or pending uploads,refresh_oncereturns before updating the texture. Repeated submits before the first shown frame could keep using the old pixels. This is a source-level execution path; I did not confirm pixel output in a retail run.I added a test-only schedule that cools one chunk over 16 clean looks, then asks for another look in the same frame after a simulated CPU write. On the unchanged PR logic,
cargo test -p xcl --lib cold_watch_does_not_defer_a_required_same_frame_look -- --test-threads=1 --nocapturefails as expected: 0 passed, 1 failed, 0 ignored, 0 skipped (a required look must not defer a CPU write until Present). The PR's existinghot_cold_tieringfilter passed 3/0/0/0, andwatch_gap_4mib_does_not_overbridge_64mib_holepassed 1/0/0/0. These are local Windows CPU tests on a Ryzen 7 9800X3D / RTX 3080 Ti machine; they do not exercise the GPU upload/readback path.The 4 MiB merge-gap change is independently useful. For the default behavior, I suggest keeping cold-chunk skipping opt-in until it can detect the first write before any dependent submit (or otherwise prove the submitted lists do not read that range). A GPU regression should upload an existing texture, fence its first sampling, CPU-write its source, then resubmit and read back before Present. The benchmark here checks that the write is eventually seen at the following frame, which is weaker than that ordering requirement.
Failing test-only diff
AI use: Codex (GPT-6.2 Sol) traced the execution path, wrote and ran the local test, and drafted this report. Codex (GPT-6.2 Astra) independently checked the source-level schedule. No game files or diagnostics were used.
@thehollowedone on GitHub · 2026-11-26 22:32 UTC · original
Follow-up to my same-head correctness report: I measured the 4 MiB merge gap alone, with Hot/Cold tiering disabled, using this PR's existing resident
MEM_WRITE_WATCHfixture at0246ae436afd1397a0672ca5ee6a4b7eabaca847.The fixture's 1.5 GiB arenas and 20 frames × 5 submits give 80 non-skipped looks, with 200 hot pages written per submit. Four separate Windows test-process runs: the 64 MiB gap scanned 1,104 MiB/look and took 42.47–43.10 ms total; the 4 MiB gap scanned 384 MiB/look and took 19.28–22.59 ms total, a 1.90–2.20× reduction in this synthetic scan time. Each run returned 1 passed, 0 failed, 0 ignored, 0 skipped for
cargo test -p xcl --lib bench_write_watch_hot_cold_tiering -- --test-threads=1 --nocapture. The comparison includes the PR's chunk iteration withtier_on=false, so every chunk is still scanned on each non-skipped look. It does not measure a title run, GPU output, or end-to-end FPS.This supports retaining the independently useful gap change while the cold-tier ordering case is resolved. Hardware: Windows 11 build 26300, Ryzen 7 9800X3D; the RTX 3080 Ti was present but this fixture did not use it. Synthetic memory only.
Test-only measurement diff
AI use: Codex (GPT-6.2 Sol) added and ran the measurement and drafted this report.
@Gevroska on GitHub · 2026-11-27 00:30 UTC · original
I checked the existing write-watch timing counters in three Windows GTA VI runs. Between sparse submits 4,096 and 8,192, the stock collection stage accumulated 7.641 s over 34.133 s in the first run, 7.932 s over 34.133 s in the second, and 36.766 s over 46.047 s in the third. I used the difference between consecutive cumulative samples in each run. The timer includes range and buffer preparation, dirty-page collection, and sorting.
All three intervals ended before I confirmed loading. The last timing samples preceded the end of the first verified loading interval by 35, 65, and 78 seconds respectively. This puts substantial collection cost in the menu phase. The saved counters leave the cost during the later loading stall unknown. I did not run a base-versus-PR comparison, so these numbers do not measure the speedup from #2891.
I used Codex GPT-6.2 Sol to analyze the saved counters and a separate GPT-6.2 Sol agent to verify the timings against the loading events. Codex GPT-6.2 Astra wrote this comment.
@JJAutoCompare on GitHub · 2026-11-27 00:56 UTC · original
Tested: Clean
0246ae436afd1397a0672ca5ee6a4b7eabaca847, Windows 11 build 26200.9974, Ryzen 7 3800X, Intel Arc A770 driver 32.0.101.9175, Rust 1.100.0 MSVC debug. Builtcargo test --locked -j 2 -p xcl --lib --no-runand ranhle::d3d12x::title_textures::tests::gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changes --exact --test-threads=1 --nocapturewith tiering enabled, cold stride 1, andXCL_ADAPTER=A770. One passed, zero failed, ignored or skipped. The hot-source R8 readback matched the CPU writes, the later physical mapping and the restored CPU view after unmapping.Not tested: Cold-source modification and resubmit before Present, full suite, retail smoke and performance.
AI use: T3 Code / Codex (
gpt-6.2-sol) ran and reran the checks and wrote this report.@andrewDoing on GitHub · 2026-11-27 02:27 UTC · original
On head
0246ae436afd1397a0672ca5ee6a4b7eabaca847, I confirmed the earlier same-frame scheduling finding with a native RTX 5070 texture readback. With the default write-watch tier enabled, all 4,096 texels retained their old value after the CPU modified a cold source and the same closed command list was resubmitted before Present. Earlier scheduling testI extended the existing
gpu_mirror_upload_follows_cpu_writes_and_later_mapping_changestest in an isolated checkout. The test registered a synthetic 64 × 64 R8 texture backed by write-watched CPU memory and verified two hot uploads. It then closed a real empty direct command list and resubmitted it 18 times, calling the production look decision and refresh functions and waiting for a GPU readback after each submit. The test confirmed the source chunk was cold. I changed all source bytes from0x9Ato0xC7, confirmed the resubmitted list required a look, and read the texture back after its fence. The shown-frame counter stayed at zero throughout.0x9A)0xC7)XCL_WRITE_WATCH_TIER=1XCL_WRITE_WATCH_TIER=0Each row was a fresh process using the same debug test binary,
XCL_LOOK_SKIP=1, andXCL_COLD_WATCH_STRIDE=1. Neither run skipped. This exercises native GPU texture visibility through the production refresh helpers with a test-controlled submission schedule. No retail title, frame timing, or post-Present recovery was tested.AI use: OpenAI Codex with GPT-6.2 Astra adapted the fixture, ran the paired checks, and prepared this report.
@andrewDoing on GitHub · 2026-11-27 02:33 UTC · original
Follow-up to my stale-read report: a local containment candidate makes cold write-watch tiering opt-in and leaves the 4 MiB merge-gap optimization enabled. Ordinary writes to an already registered cold texture have no separate notification before
GetWriteWatch, and required looks also occur on paths beyond repeated-list tracking, including directKickoffXrefreshes.In three fresh synthetic processes on the same test fixture, unset/default and
XCL_WRITE_WATCH_TIER=0each updated all 4,096 texels before Present and passed the existing mapping/restoration checks. Explicit=1retained all 4,096 stale texels and failed the expected-content assertion. Thus this contains the problem by default; it does not repair the experimental tier. The explicit-tier negative run must not be counted as a passing suite.The setting is read once per process, matching existing initialization. Retail performance and GTA VI were not measured. AI use: OpenAI Codex with GPT-6.2 Astra implemented, tested and independently reviewed the local containment; Codex coordinated and prepared this follow-up.
@vibryxcx on GitHub · 2026-11-27 03:39 UTC · original
Full lib suite on AMD for this head (the reports above ran single tests and the benchmark). No new failure; the 4 new tiering / gap tests pass. This does not touch the cold-chunk ordering gap that @thehollowedone reported: no test here covers a resubmit before Present.
Tested: AMD Radeon RX 6800 (RDNA2, driver 32.0.21045.5002), Windows 11 Pro 26200, Rust 1.100.0, debug. Head
0246ae43on its baseamd-devbf7c82ee. Command:cargo test -p xcl --lib -- --test-threads=1, skipping tests that hang or abort only inside the fullamd-devrun (listed in #42).bf7c82eerun the same way: the 11 failures are all ones the base has. The base's 12th,gpu_uploads_on_the_title_queue_run_before_its_later_work_and_are_released, passed here, and it is the known flaky one on this card (#2842).bench_write_watch_hot_cold_tiering,hot_cold_tiering_promotes_on_dirty_and_catches_cold_writes_at_frame_boundary,hot_cold_tiering_starts_new_ranges_hotandwatch_gap_4mib_does_not_overbridge_64mib_holepass. So do the existing write-watch tests (write_watched_memory_lives_beside_views_in_one_placeholder,gpu_visible_fallback_memory_is_write_watched).Not tested: a title run (I am not running the title right now);
cold_watch_does_not_defer_a_required_same_frame_lookfrom the comment above (not in this head).AI use: Claude Code (Claude Opus 5.5) ran the suite through a local test runner, compared it with the base and wrote this comment.
@oni-swr on GitHub · 2026-11-27 03:41 UTC · original
RX 7800 XT,
amd-devbf7c82eeagainst the same plus #2891 head0246ae43(merged locally, clean): write-watch time per submit, menu and loading phase only.XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PREPARE=0 XCL_GFX_PSO_WAIT_MS=200, scripted A presses every 8 s from 16 s, 300 s runs, nothing else running. Two runs per arm, interleaved base, head, base, head.Write-watch time per submit fell by about 45 % (2.25 to 1.20 ms) and the whole submit by about 8 %. Dirty pages found, commit (about 19 GB) and presents per window were the same in both arms. No device removal, no crash in any of the four.
This measures the default build of the PR, so the merge gap and the cold tier are not separated (no toggle on this head). I did not look at output (no readback), so I cannot confirm or rule out the stale-texture finding from @thehollowedone and @andrewDoing above; that bug is a correctness reason to hold the cold tier regardless of this timing.
Not tested: the world, the cold-tier resubmit case, a full
cargo testrun (only the 4 tiering/gap tests passed on CPU), NVIDIA, other AMD parts.AI use: Claude Code (Claude Sonnet 5.5) ran the runs and wrote this.
@andrewDoing on GitHub · 2026-11-27 03:47 UTC · original
For the timing question in the latest report: head
0246ae436afd1397a0672ca5ee6a4b7eabaca847does have a tier switch.XCL_WRITE_WATCH_TIER=0disables cold-chunk tiering, while the 4 MiBWATCH_GAPchange remains active.XCL_WRITE_WATCH_TIER=1enables tiering (also the current default when unset). The setting is read once per process.If the same warmed workload can be repeated, a base / head-with-0 / head-with-1 comparison could separate the merge-gap contribution from the incremental tiering contribution. My earlier synthetic same-frame cold-write readback found stale texels with tiering enabled, so please keep that correctness limitation in view; it did not measure the retail run or explain its timing.
AI use: OpenAI Codex with GPT-6.2 Astra checked the switch and source; Codex coordinated and prepared this follow-up.
@oni-swr on GitHub · 2026-11-27 05:59 UTC · original
Split of the #2891 write-watch gain on an RX 7800 XT: the cold tier, not the 4 MiB gap (answering @andrewDoing's switch above).
Same machine, head
0246ae43merged onamd-devbf7c82ee(RX 7800 XT, driver 32.0.31035.1003, Windows 11 build 26200, Ryzen 7 5700X3D, release), same warm cache copy and profile per run,XCL_NETWORK=0 XCL_ACTIVITY=1 XCL_PREPARE=0 XCL_GFX_PSO_WAIT_MS=200, scripted A presses, 150 s runs, order tier 1, tier 0, tier 1, tier 0. Windows with presents before the title stalled (41-43 windows of 2 s, about 7,300-7,500 submits per run). Menu and loading phase only; the title did not reach the world.XCL_WRITE_WATCH_TIERFor reference, the plain
amd-devbase in my earlier comment was 2.28 and 2.23 ms per submit. So on this card the 4 MiB gap alone did not change write-watch time (2.4 against 2.25, within the run-to-run spread I see), and the whole saving, about 1.1 ms per submit (45 %), comes with the cold tier on. That is the part with the same-frame stale-write finding from @thehollowedone and @andrewDoing. If the tier becomes opt-in as proposed, the gain on RDNA3 in this phase goes with it.Not tested: the world, output correctness (no readback), the cold-write resubmit case, other cards. Two runs per arm.
AI use: Claude Code (Claude Sonnet 5.5) ran the runs and wrote this.
D3D12.X: tighten write-watch merge gap to 4 MiB and tier cold 16 MiB chunks to frame boundariesto D3D12.X: tighten write-watch merge gap to 4 MiB and add opt-in cold-chunk tiering@Saksukella on GitHub · 2026-11-27 06:51 UTC · original
Thanks @thehollowedone, @andrewDoing, and @oni-swr for the detailed testing, A/B splits, and readback repros!
Pushed \570a92e\ addressing the same-frame cold-write + closed-list resubmit / \KickoffX\ edge case:
View command line instructions
Manual merge helper
Use this merge commit message when completing the merge manually.
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.