D3D12.X: make the write-watch merge gap configurable #1619

Closed
MitchellBrovarnik wants to merge 1 commit from upstream-pr/1629 into main
MitchellBrovarnik commented 2026-11-24 18:24:42 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by MitchellBrovarnik on 2026-11-24T18:24:42Z.


Adds opt-in control of the gap used to merge write-watch ranges before GPU submissions. Keeps the 64 MiB default from #551; smaller gaps can avoid scanning unused address space on some fragmented layouts. Related to #582, but independent of the cold-page approach. This is a performance experiment, not a crash or rendering fix.

What is in it

  • title_textures.rs: read XCL_WRITE_WATCH_GAP_MIB once per process (1–64 MiB, default/fallback 64); preserve existing atomic write-watch scan/reset and upload logic. Unit tests cover bounds, range coverage and retention of writes in previously unwatched gaps.
  • e2e.rs and tests/testtitle: opt-in five-layout stress fixture with 2,048 GPU submissions and 14 updated-word/canary pairs checked per submission. README documents the option.
    Tested
  • Local working tree based on b7aa9f3, Windows 25H2 build 26200.9711, RTX 5080, driver 596.49, Ryzen 7 9800X3D, 64 GB RAM. Release workspace build succeeded. Full-suite counts and exact Rust version for the final revision pending.
  • cargo test --release --locked -p xcl --test e2e test_title_runs_and_game_folder_is_untouched -- --exact --nocapture, with XCL_TEST_FRAGMENTED_WATCH=1, XCL_TEST_FRAGMENTED_LAYOUT set to each layout below, and XCL_WRITE_WATCH_GAP_MIB alternated 64/8/8/64/64/8. All 30 memory fixtures passed (860,160 verified pairs); 29/30 overall e2e passes. One 8 MiB run failed the pre-existing audio timing check (68 ms vs ~100 ms); similar failure observed with 64 MiB in an earlier run. Cause not isolated. No assertions weakened.
  • Medians of three runs per setting. Write-watch times are cumulative log counters at 2,048 runtime submissions (include setup/earlier checks); elapsed time is measured inside the fixture. Baseline is the same patched binary with threshold 64, not a separate pristine main build.
    Layout Write-watch 64 / 8 (ms) Fixture elapsed 64 / 8 (ms)
    packed 136 / 135 738 / 746
    gap3 379 / 379 996 / 973
    gap9 1025 / 686 1682 / 1294
    gap15 999 / 468 1686 / 1184
    gap79 94 / 95 705 / 723

Write-watch time fell 33.1% and 53.2% for the 9 and 15 MiB gap layouts respectively. Packed and widely spaced layouts had small elapsed-time slowdowns; three repeats are insufficient to rule out small regressions. Results apply to these source-built fixtures only.

Regression run

main: pending required clean-commit smoke run on a supported title owned by the tester.

PR: pending same-title, same-duration clean-commit smoke run with the opt-in setting. Not merge-ready until both blocks and full-suite results are supplied.

Not tested

  • Final rebased revision, full workspace suite, AMD, Wine, broader workloads and qualifying real-title smoke comparison. No claim of a retail crash fix or a universal speedup.
    AI use
  • ChatGPT (GPT-6.2): assisted with research, implementation, benchmark fixtures, log analysis and PR drafting; Windows runs executed by the contributor.
<!-- greyfinch-sync:ivall/xcl:issue:5477948757 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1629). Originally posted by [MitchellBrovarnik](https://github.com/MitchellBrovarnik) on 2026-11-24T18:24:42Z. --- Adds opt-in control of the gap used to merge write-watch ranges before GPU submissions. Keeps the 64 MiB default from #551; smaller gaps can avoid scanning unused address space on some fragmented layouts. Related to #582, but independent of the cold-page approach. This is a performance experiment, not a crash or rendering fix. What is in it - title_textures.rs: read XCL_WRITE_WATCH_GAP_MIB once per process (1–64 MiB, default/fallback 64); preserve existing atomic write-watch scan/reset and upload logic. Unit tests cover bounds, range coverage and retention of writes in previously unwatched gaps. - e2e.rs and tests/testtitle: opt-in five-layout stress fixture with 2,048 GPU submissions and 14 updated-word/canary pairs checked per submission. README documents the option. Tested - Local working tree based on b7aa9f3, Windows 25H2 build 26200.9711, RTX 5080, driver 596.49, Ryzen 7 9800X3D, 64 GB RAM. Release workspace build succeeded. Full-suite counts and exact Rust version for the final revision pending. - cargo test --release --locked -p xcl --test e2e test_title_runs_and_game_folder_is_untouched -- --exact --nocapture, with XCL_TEST_FRAGMENTED_WATCH=1, XCL_TEST_FRAGMENTED_LAYOUT set to each layout below, and XCL_WRITE_WATCH_GAP_MIB alternated 64/8/8/64/64/8. All 30 memory fixtures passed (860,160 verified pairs); 29/30 overall e2e passes. One 8 MiB run failed the pre-existing audio timing check (68 ms vs ~100 ms); similar failure observed with 64 MiB in an earlier run. Cause not isolated. No assertions weakened. - Medians of three runs per setting. Write-watch times are cumulative log counters at 2,048 runtime submissions (include setup/earlier checks); elapsed time is measured inside the fixture. Baseline is the same patched binary with threshold 64, not a separate pristine main build. Layout Write-watch 64 / 8 (ms) Fixture elapsed 64 / 8 (ms) packed 136 / 135 738 / 746 gap3 379 / 379 996 / 973 gap9 1025 / 686 1682 / 1294 gap15 999 / 468 1686 / 1184 gap79 94 / 95 705 / 723 Write-watch time fell 33.1% and 53.2% for the 9 and 15 MiB gap layouts respectively. Packed and widely spaced layouts had small elapsed-time slowdowns; three repeats are insufficient to rule out small regressions. Results apply to these source-built fixtures only. Regression run main: pending required clean-commit smoke run on a supported title owned by the tester. PR: pending same-title, same-duration clean-commit smoke run with the opt-in setting. Not merge-ready until both blocks and full-suite results are supplied. Not tested - Final rebased revision, full workspace suite, AMD, Wine, broader workloads and qualifying real-title smoke comparison. No claim of a retail crash fix or a universal speedup. AI use - ChatGPT (GPT-6.2): assisted with research, implementation, benchmark fixtures, log analysis and PR drafting; Windows runs executed by the contributor.
upstream-sync closed this pull request 2026-11-24 19:06:57 +00:00
pickles976 commented 2026-11-24 19:07:29 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by pickles976 on 2026-11-24T18:28:44Z.


Approve — the two non-obvious parts are both right: ① OnceLock because the merged ranges are cached: re-reading env mid-run would let a changed gap silently contradict already-cached merged ranges (a knob that can lie to the cache is worse than no knob; the doc comment states the reason, which is what keeps it from being "optimized" into a lazy read later); ② invalid or out-of-range input falls back to the measured 64 MiB default and the log line prints requested-vs-applied — so a user setting 128 sees "64 MiB (requested \"128\")" instead of silent surprise. Range clamp 1–64 keeps it from being a way to turn merging off (gap=0 ⇒ pathological unmerged scan) — right for a tuning knob; if someone later wants "disable merging" as a diagnostic, that deserves its own explicit value, not a clamp edge. Cross-link worth recording: this is the sibling knob to XCL_COHERENT_MB — one tunes how much address space is watched, the other how much is resident; the fresh RDNA2 report (sparse-window updates 1000× at default coherent MB, fixed at 512) is exactly the fragmented-layout case this gap tuning targets, so the two knobs together give the cohort a clean 2×2 for scan-cost A/B. Nice to see a knob land with its measurement story attached.

<!-- greyfinch-sync:ivall/xcl:comment:7140701230 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1629#issuecomment-7140701230). Originally posted by [pickles976](https://github.com/pickles976) on 2026-11-24T18:28:44Z. --- Approve — the two non-obvious parts are both right: ① `OnceLock` **because the merged ranges are cached**: re-reading env mid-run would let a changed gap silently contradict already-cached merged ranges (a knob that can lie to the cache is worse than no knob; the doc comment states the reason, which is what keeps it from being "optimized" into a lazy read later); ② invalid or out-of-range input falls back to the measured 64 MiB default **and the log line prints requested-vs-applied** — so a user setting `128` sees "64 MiB (requested \\"128\\")" instead of silent surprise. Range clamp 1–64 keeps it from being a way to turn merging off (gap=0 ⇒ pathological unmerged scan) — right for a tuning knob; if someone later wants "disable merging" as a diagnostic, that deserves its own explicit value, not a clamp edge. Cross-link worth recording: this is the sibling knob to `XCL_COHERENT_MB` — one tunes how much address space is watched, the other how much is resident; the fresh RDNA2 report (sparse-window updates 1000× at default coherent MB, fixed at 512) is exactly the fragmented-layout case this gap tuning targets, so the two knobs together give the cohort a clean 2×2 for scan-cost A/B. Nice to see a knob land with its measurement story attached.
DavidM1911 commented 2026-11-24 21:09:40 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-24T20:46:42Z.


Verification on RTX 3060 Ti (Windows 11), branch merged with current main:

  • cargo test -p xcl --lib: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified main.)

Thanks!

<!-- greyfinch-sync:ivall/xcl:comment:7144042823 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1629#issuecomment-7144042823). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-24T20:46:42Z. --- Verification on RTX 3060 Ti (Windows 11), branch merged with current `main`: - `cargo test -p xcl --lib`: all passed, 0 failed, ~22 ignored. (Intermittent single-test flake under parallel scheduling; clean on single-threaded rerun — same flake seen on unmodified `main`.) Thanks!
jeroenhaentjens commented 2026-11-28 14:00:59 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by jeroenhaentjens on 2026-11-28T14:00:59Z.


Write-watch gap on a Quadro RTX 3000 at the PLAYER1 screen

On Windows with GTA VI 1.0.2.1, I ran the same release executable three times, changing only XCL_WRITE_WATCH_GAP_MIB between runs. The local build combines #2862, #1916, #1182, #2177 and the configurable gap from this PR. Executable SHA-256: 48328913A718C06823B7A5D92B174B70A510DA6159D78324CCCA324582F1BF3A.

Each run used the same Series X profile, warm shader cache and 16,667 µs host frame interval. All 93 selected pipelines were confirmed on the game device. I compared captures that pixel-matched the same still PLAYER1 screen and divided the change in the Present counter by the elapsed time between matching captures.

Gap (MiB), in run order Presents Seconds Presents/s
64 (default) 120 14.714 8.16
8 240 21.106 11.37
1 360 40.015 9.00

8 MiB had the highest menu present rate in this comparison, about 39% above the default. With one run per setting and different capture durations, repeatability and gameplay FPS remain open. The title still created 4K buffers at startup.

I also checked 64 and 8 MiB with four focused tests and ten GPU runs across five synthetic memory layouts. All 286,720 readback pairs matched both the updated value and the unchanged control. Which setting was faster depended on the synthetic layout.

OpenAI Codex assisted with the local integration, measurements and report.

<!-- greyfinch-sync:ivall/xcl:comment:7240351187 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/1629#issuecomment-7240351187). Originally posted by [jeroenhaentjens](https://github.com/jeroenhaentjens) on 2026-11-28T14:00:59Z. --- ### Write-watch gap on a Quadro RTX 3000 at the PLAYER1 screen On Windows with GTA VI 1.0.2.1, I ran the same release executable three times, changing only `XCL_WRITE_WATCH_GAP_MIB` between runs. The local build combines #2862, #1916, #1182, #2177 and the configurable gap from this PR. Executable SHA-256: `48328913A718C06823B7A5D92B174B70A510DA6159D78324CCCA324582F1BF3A`. Each run used the same Series X profile, warm shader cache and 16,667 µs host frame interval. All 93 selected pipelines were confirmed on the game device. I compared captures that pixel-matched the same still PLAYER1 screen and divided the change in the Present counter by the elapsed time between matching captures. | Gap (MiB), in run order | Presents | Seconds | Presents/s | |---:|---:|---:|---:| | 64 (default) | 120 | 14.714 | 8.16 | | 8 | 240 | 21.106 | 11.37 | | 1 | 360 | 40.015 | 9.00 | 8 MiB had the highest menu present rate in this comparison, about 39% above the default. With one run per setting and different capture durations, repeatability and gameplay FPS remain open. The title still created 4K buffers at startup. I also checked 64 and 8 MiB with four focused tests and ten GPU runs across five synthetic memory layouts. All 286,720 readback pairs matched both the updated value and the unchanged control. Which setting was faster depended on the synthetic layout. OpenAI Codex assisted with the local integration, measurements and report.

Pull request closed

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!1619
No description provided.