Repository navigation
D3D12.X: tighten write-watch merge gap to 4 MiB and add opt-in cold-chunk tiering - #2891
Saksukella wants to merge 2 commits into
Conversation
…chunks to frame boundaries
|
I found a correctness gap on exact head 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, 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@@ -4229,6 +4229,26 @@ mod tests {
+ #[test]
+ fn cold_watch_does_not_defer_a_required_same_frame_look() {
+ let chunk = (0x3000_0000, WATCH_CHUNK);
+ let mut tiers = WatchTierState::new();
+ for frame in 0..COLD_THRESHOLD as u64 {
+ tiers.scan_chunks(&[chunk], frame, true, 1, |_, _| false);
+ }
+ assert!(tiers.is_cold(chunk));
+
+ // A CPU write after a completed execution must be visible to a second
+ // execution of that list, even if no Present advanced the frame count.
+ let frame = COLD_THRESHOLD as u64 - 1;
+ let mut looked = false;
+ tiers.scan_chunks(&[chunk], frame, true, 1, |_, _| {
+ looked = true;
+ true
+ });
+ assert!(looked, "a required look must not defer a CPU write until Present");
+ }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. |
|
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 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 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 diffdiff --git a/crates/xcl/src/hle/d3d12x/title_textures.rs b/crates/xcl/src/hle/d3d12x/title_textures.rs
index edb1e1e7..53655ef2 100644
--- a/crates/xcl/src/hle/d3d12x/title_textures.rs
+++ b/crates/xcl/src/hle/d3d12x/title_textures.rs
@@ -4315,6 +4315,32 @@ mod tests {
}
let base_ms = base_dur.as_secs_f64() * 1000.0;
+ // Isolate the 4 MiB gap from temperature tiering: scan every chunk
+ // on every non-skipped look, as the opt-out path would do.
+ dirty.clear();
+ for &(b, s) in ®ions {
+ take_written(b, s, &mut buf, &mut dirty, &mut page);
+ }
+ let mut gap_only_tiers = WatchTierState::new();
+ let mut gap_only_dur = std::time::Duration::ZERO;
+ for frame in 0..FRAMES {
+ for sub in 0..SUBMITS_PER_FRAME {
+ dirty_hot_pages(500 + frame * SUBMITS_PER_FRAME + sub);
+ if sub == 4 {
+ continue;
+ }
+ dirty.clear();
+ let t0 = std::time::Instant::now();
+ gap_only_tiers.scan_chunks(&fix_a_chunks, frame, false, 1, |b, s| {
+ let before = dirty.len();
+ take_written(b, s, &mut buf, &mut dirty, &mut page);
+ dirty.len() > before
+ });
+ gap_only_dur += t0.elapsed();
+ }
+ }
+ let gap_only_ms = gap_only_dur.as_secs_f64() * 1000.0;
// Drain any residual writes before Fix A measurement.
dirty.clear();
for &(b, s) in ®ions {
@@ -4415,6 +4441,12 @@ mod tests {
base_ms / total_submits,
base_ms / base_looks as f64,
);
+ println!(
+ " 4 MiB gap, tier=OFF : {:.2} ms total | {:.3} ms/submit | {:.3} ms/look",
+ gap_only_ms,
+ gap_only_ms / total_submits,
+ gap_only_ms / base_looks as f64,
+ );
println!(
" Fix A (4 MiB gap, stride=1) : {:.2} ms total | {:.3} ms/submit | {:.3} ms/look | speedup: {:.2}x",
fix_s1_ms,AI use: Codex (GPT-6.2 Sol) added and ran the measurement and drafted this report. |
…re messages) Upstream xcl-dev#2890 (c6c14a1, single-commit on upstream/main 8b957be): title_under_the_debug_layer prints the last TAIL=40 lines of xcl.log in its three assertion messages and tolerates a missing log file (unwrap_or_default), so a title that never finishes still shows why. Verbatim port of the whole fix (1 file, +24/-4): the TAIL const + tail() helper after the PathBuf import and the three rewritten asserts. Applies cleanly; the only context offset is the linux-only debug_layer_skip_line helper above the hunk. Windows-only siblings xcl-dev#2888 (perf-compare ps1 stack), xcl-dev#2889 (tiling_parity.rs host-driver test, no cfg(windows) gate), xcl-dev#2891 (title_textures.rs write-watch tiering on the 71b8e6e dev-stack) stay out per the step-139 sync entry.
…SKIP, probe past xcl-dev#2891)
|
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. |
|
Tested: Clean Not tested: Cold-source modification and resubmit before Present, full suite, retail smoke and performance. AI use: T3 Code / Codex ( |
|
On head I extended the existing
Each row was a fresh process using the same debug test binary, AI use: OpenAI Codex with GPT-6.2 Astra adapted the fixture, ran the paired checks, and prepared this report. |
|
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 In three fresh synthetic processes on the same test fixture, unset/default and 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. |
|
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
Not tested: a title run (I am not running the title right now); 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. |
|
RX 7800 XT,
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 AI use: Claude Code (Claude Sonnet 5.5) ran the runs and wrote this. |
|
For the timing question in the latest report: head 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. |
|
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
For reference, the plain 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. |
|
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:
|
Tightens
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