D3D12.X: XCL_LOOK_AHEAD takes written pages between submits by default #3436
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3436"
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?
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T16:26:51Z.
XCL_LOOK_AHEAD(a thread that takes the hot blocks' written pages between submits,a004fe7b) is now on by default at 2 ms.XCL_LOOK_AHEAD=0turns it off, andXCL_WATCH_HOT=0still turns it off too. Fixes #3435.Why: on a retail game (main
d8bd9a38, RTX 2070 SUPER) the looks for written pages before each submit took a mean of 8.8 % of wall time in menus and 14–16 % in 300–600 s runs, peaking at 65 % in one 2 s window. A look's cost grows with the pages it takes: each is a page-table entry changed and flushed on every core (~0.5 µs), and the game's world had ~8,000 pages a look, ~5 ms on the submitting thread. Look-ahead takes them on its own thread. The next submit drains what it found (AHEAD) into its dirty pages with its own look, so what is uploaded, and when, stays as it was.XCL_LOOK_SKIPstays opt-in. Unlike look-ahead, it changes what a submit sees: a CPU write between a list's close and its submit waits for the next look.Measurement: no gain. The A/B run (A default, C
XCL_LOOK_AHEAD=2, B withXCL_LOOK_SKIP=1added; 300 s each, same exe, retail game) is in the comment below: C raised the look work on the submitting thread from 115 to 137 ms per 2 s, and frames stayed within noise. As this description said it would, the PR stops here.What is in it
crates/xcl/src/hle/d3d12x/title_textures.rs:look_ahead()defaults to 2 ms;look_ahead_msis the pure parser (unset or not a number → 2,0→ off);AHEADinto a submit's dirty pages becomestake_ahead, with no behaviour change;look_ahead_is_on_at_two_ms_unless_turned_off, pluspages_found_ahead_are_kept_for_the_next_submitnow checks that every page found ahead reaches the next submit's dirty pages, once.README.md: one line forXCL_LOOK_AHEAD.Tested
cargo test -p xcl --lib title_textures::tests::: 66 passed, 0 failed, 1 ignored.Regression run
scripts/smoke.ps1on mainbc2cbb72and on this head.Not tested
XCL_PREPARE=0on both sides.REFRESHlock still serialises the submits, and look-ahead does not change that.AI use
🤖 Generated with Claude Code
Imported from ivall/xcl. Originally posted by andrewDoing on 2026-11-29T17:00:01Z.
I ran a synthetic Windows write-watch comparison on
0ef9307a, Ryzen 7 5700X3D, Windows 11 26300.10075, Rust 1.100.0, debug. The fixture used one 32 MiBMEM_WRITE_WATCHallocation and the production look-ahead thread,take_ahead,take_hot, and the foreground sort/dedup. Each trial wrote 8,192 distinct pages and rewrote 128 before collecting the dirty set. I ranXCL_LOOK_AHEAD=0and the unset 2 ms default in fresh processes in ABBA order, with 96 measured trials per process for each gap. Every trial found all 8,192 expected dirty addresses. Both PR tests passed, and all eight probe processes passed with zero skips.Times are in microseconds. Ranges span the two fresh processes for each row. Foreground time starts before acquiring
ONE_LOOKand ends after sorting and deduplicating the dirty pages.With the pause, the default left 128 pages for the foreground scan (median and p95), down from 8,192. Sorting and deduplication absorbed much of the scan-time gain. Median time from the first write through the end of the foreground stage, with the deliberate pause subtracted, was 5.18–5.43 ms off and 5.38–5.56 ms with the default across the two workloads. In the retail comparison, tracking the full look through the sort and the
ONE_LOOKwait would help show how much of the scan saving reaches the submitting thread. Retail measurement planThis measured the CPU write-watch stage only. GPU work, retail frames and release performance remain unmeasured here. Codex with GPT-6.2 Sol wrote and ran the test-only fixture and prepared the report.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T17:14:57Z.
Results request: does look-ahead at 2 ms help a real title?
Thanks @andrewDoing for the synthetic run. It shows that no page is lost. Its gain can't carry over to a game: it was a debug build (sorting is slow there, the scan is kernel time and is not), and a one-thread process in one 32 MiB allocation pays about 0.03 µs a page for the scan, where a retail game pays about 0.5 µs (the reset flushes every core the title's threads run on). The data this PR needs comes from a retail title in a release build, with look-ahead off and on.
Background: on main
d8bd9a38the looks for written pages before each submit took a mean of 8.8 % of wall time in menus and 14–16 % in 300–600 s runs (RTX 2070 SUPER, retail game). A run of our own is queued and will be posted here too.What is compared: one build of this PR's head,
0ef9307a.XCL_LOOK_AHEAD=0(off, as on main) againstXCL_LOOK_AHEADunset (the new default, 2 ms). Use the same exe for both sides so that the shader caches are shared.Build
Release only, not debug. Note your
rustc --version.Warm-up (not measured): one run with startup preparation on, so that the shaders your title uses are compiled and cached:
Measured runs: the same title and the same 300 s each, four runs in this order: off, on, off, on. Close other programs, and don't touch the game (the press is scripted).
In each "on" log, check for the line
XCL_LOOK_AHEAD: a thread takes the written pages every 2 ms. Check that the "off" logs don't have it.What to paste back
xcl-smokeblocks, as printed.How it will be read
lookin the submit-cost lines) andms a lookshould drop with look-ahead on.found aheadshows how much of the work the thread took off the submit.Most needed: AMD RDNA2/3/4 (the maintainer measures on RDNA4), and CPUs with more cores than ours (the per-page cost grows with the cores a title runs on). NVIDIA results are welcome too.
Our environment: NVIDIA GeForce RTX 2070 SUPER, driver 621.40, AMD Ryzen 5 3600XT, 32 GB, Windows 11 Home build 26300, rustc 1.100.1.
Written by Claude Code (Claude Opus 5.5).
Imported from ivall/xcl. Originally posted by Aniseto on 2026-11-29T18:17:51Z.
Ran the texture-look-ahead test group at
0ef9307aon an NVIDIA Blackwell desktop part, with a control run onmain.System
Results
0ef9307a,XCL_ADAPTER=NVIDIA cargo test -p xcl --lib title_textures::tests:: -- --test-threads=1: 62 passed, 4 failed, 1 ignored (exit 101).main0fe06eb0, same command: 62 passed, 4 failed, 1 ignored (exit 101).What this adds
The four failures are the same on both trees:
placed_title_textures_share_vram_and_preserve_pixelsand the threestream_recheck_*tests. This run adds no new failure relative tomainand is the first datapoint from an RTX 5070 Ti in the thread. The PR's own unit tests for the 2 ms default are inside the 62 passes. No title run was made, so the requested A/B on presented frames is still open.Not tested
A retail title, the FPS/look-share A/B, a paired smoke run, the full workspace suite, AMD and Intel GPUs, native wave64 hosts, Wine, release profile, game data.
AI-assisted (OpenCode), model: DeepSeek V4.1 Flash Free - ran the commands above on this machine and wrote this report; no game data was used.
Imported from ivall/xcl. Originally posted by KOLESNiii on 2026-11-29T19:11:07Z.
Result: no gain. This PR stops here. As its description says, it was waiting on the A/B run, and turning look-ahead on by default did not reduce the look work on the submitting thread.
Same exe (4465c886, look-ahead switchable) for every arm, warm default cache,
XCL_PREPARE=0 XCL_ACTIVITY=1 XCL_LOOK_STATS=2 XCL_PRESS_AT=25:A, 300 s each, one run per arm, RTX 2070 SUPER 8 GB (driver 621.40), Ryzen 5 3600XT, retail game. The look numbers are the means of thelooks before submits (2 s)windows from t ≥ 30 s (133–135 windows per arm):XCL_LOOK_AHEAD=2(this PR's default)XCL_LOOK_AHEAD=2 XCL_LOOK_SKIP=1XCL_LOOK_AHEAD: a thread takes the written pages every 2 msat 2.98 s. The submit thread's look work still went up, not down.So there is no case for this default. The switch stays opt-in on
mainas before. I won't push more to this branch or ask for more runs.Claude Code (Claude Opus 5.5) wrote this comment from the run logs; the A/B run was set up and run by another Claude Code (Claude Opus 5.5) session on this machine.
Pull request closed