D3D12.X: Hash dirty chunks from the bytes staged for upload #3702

Merged
bmjask merged 2 commits from upstream-pr/3702 into main 2026-12-03 02:26:04 +00:00
bmjask commented 2026-12-02 15:38:27 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by bmjask on 2026-12-02T15:38:27Z.


What is in it

Load each complete dirty 64-byte chunk once during staging and use its words for both the upload and the submitted hash journal. Partial chunks retain their previous behavior. The initial dirty scan, GPU copy, and fence ownership remain in place.

Tested

  • Windows, Intel Core i9-12900K, RTX 4090, NVIDIA 610.88, Rust 1.100.0, release.
  • Targeted tests passed for partial and misaligned ranges, parallel staging, and guest writes after planning. The combined development checkout passed 214 focused tests with zero failures and two ignored before the individual changes were split onto main.
  • Separate hash and copy versus fused staging for a single span in ordinary CPU memory: 4 KiB, 180 → 126 ns; 64 KiB, 3.689 → 2.325 µs; 256 KiB, 14.199 → 9.490 µs. The fixture compares both destination bytes and journal entries. It does not measure write-combined memory or parallel-worker throughput. Reported values are medians of 31 paired samples with alternating order.
  • Reproduce with cargo test --release --locked -p xcl --lib bench_upload_ab_sparse -- --ignored --nocapture --test-threads=1.

Mapped D3D12 upload benchmark

Dirty span Separate hash and copy Fused staging CPU time saved
4 KiB 205 ns 126 ns 38.5%
64 KiB 4.763 µs 2.399 µs 49.6%
256 KiB 19.493 µs 9.568 µs 50.9%

The staged bytes and hash journal matched. This isolates one contiguous dirty span with warm source data and a reused allocation. Parallel jobs, dirty discovery, GPU copies, and fences are outside the timed region.

Release build on an i9-12900K and RTX 4090 (610.88). Each value is the median of five independent process medians, with 31 alternating timed batches of 128 operations per method and size in each run. XCL allocated a native D3D12 upload buffer. The device reported WRITE_COMBINE and Windows reported PAGE_READWRITE | PAGE_WRITECOMBINE (0x404). Both focused checks passed in each process on the combined development checkout. These are CPU staging times.

Reproduce with cargo test --release --locked -p xcl --lib bench_upload_ab_sparse_mapped -- --ignored --test-threads=1 --nocapture.

Regression run

Main

xcl-smoke v1
commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303
gpu: NVIDIA GeForce RTX 4090
title: upload-regression
seconds: 60
exit: 0x0
frames shown: 1449 (PresentX 1449)
presents per 2 s (last 3): 51 16 48
device removals: 0
crashes: 0
peak commit: 23474 MB

PR head

xcl-smoke v1
commit: 2fe4985512ffea690ff9b7b657e4b7736a403cce
gpu: NVIDIA GeForce RTX 4090
title: upload-regression
seconds: 60
exit: 0x0
frames shown: 1575 (PresentX 1575)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14909 MB

The journal records the hash of the same loaded words written to staging. This closes the interval in which a guest write between hashing and copying could previously leave a hash for different bytes. The tests cover writes after planning and verify staged bytes against the journal. Concurrent guest mutation during staging and AMD hardware remain untested.

Not tested

The full GPU workspace suite and a matched in-world frame-time comparison for this individual PR.

AI use

OpenAI Codex (GPT-6) implemented and reviewed the change, ran the focused tests and benchmark, and prepared this PR.

<!-- greyfinch-sync:ivall/xcl:issue:5609729947 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3702). Originally posted by [bmjask](https://github.com/bmjask) on 2026-12-02T15:38:27Z. --- **What is in it** Load each complete dirty 64-byte chunk once during staging and use its words for both the upload and the submitted hash journal. Partial chunks retain their previous behavior. The initial dirty scan, GPU copy, and fence ownership remain in place. **Tested** - Windows, Intel Core i9-12900K, RTX 4090, NVIDIA 610.88, Rust 1.100.0, release. - Targeted tests passed for partial and misaligned ranges, parallel staging, and guest writes after planning. The combined development checkout passed 214 focused tests with zero failures and two ignored before the individual changes were split onto main. - Separate hash and copy versus fused staging for a single span in ordinary CPU memory: 4 KiB, 180 → 126 ns; 64 KiB, 3.689 → 2.325 µs; 256 KiB, 14.199 → 9.490 µs. The fixture compares both destination bytes and journal entries. It does not measure write-combined memory or parallel-worker throughput. Reported values are medians of 31 paired samples with alternating order. - Reproduce with `cargo test --release --locked -p xcl --lib bench_upload_ab_sparse -- --ignored --nocapture --test-threads=1`. **Mapped D3D12 upload benchmark** | Dirty span | Separate hash and copy | Fused staging | CPU time saved | | --- | ---: | ---: | ---: | | 4 KiB | 205 ns | 126 ns | 38.5% | | 64 KiB | 4.763 µs | 2.399 µs | 49.6% | | 256 KiB | 19.493 µs | 9.568 µs | 50.9% | The staged bytes and hash journal matched. This isolates one contiguous dirty span with warm source data and a reused allocation. Parallel jobs, dirty discovery, GPU copies, and fences are outside the timed region. Release build on an i9-12900K and RTX 4090 (610.88). Each value is the median of five independent process medians, with 31 alternating timed batches of 128 operations per method and size in each run. XCL allocated a native D3D12 upload buffer. The device reported WRITE_COMBINE and Windows reported PAGE_READWRITE | PAGE_WRITECOMBINE (0x404). Both focused checks passed in each process on the combined development checkout. These are CPU staging times. Reproduce with `cargo test --release --locked -p xcl --lib bench_upload_ab_sparse_mapped -- --ignored --test-threads=1 --nocapture`. **Regression run** Main ``` xcl-smoke v1 commit: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 gpu: NVIDIA GeForce RTX 4090 title: upload-regression seconds: 60 exit: 0x0 frames shown: 1449 (PresentX 1449) presents per 2 s (last 3): 51 16 48 device removals: 0 crashes: 0 peak commit: 23474 MB ``` PR head ``` xcl-smoke v1 commit: 2fe4985512ffea690ff9b7b657e4b7736a403cce gpu: NVIDIA GeForce RTX 4090 title: upload-regression seconds: 60 exit: 0x0 frames shown: 1575 (PresentX 1575) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14909 MB ``` The journal records the hash of the same loaded words written to staging. This closes the interval in which a guest write between hashing and copying could previously leave a hash for different bytes. The tests cover writes after planning and verify staged bytes against the journal. Concurrent guest mutation during staging and AMD hardware remain untested. **Not tested** The full GPU workspace suite and a matched in-world frame-time comparison for this individual PR. **AI use** OpenAI Codex (GPT-6) implemented and reviewed the change, ran the focused tests and benchmark, and prepared this PR.
Foniass commented 2026-12-02 18:31:19 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T18:31:19Z.


merge-check
base: 5eaadb54c1
head: 77d276fa70
merge: clean
build: ok
tests: 2975 passed, 0 failed, 53 ignored; 28 skipped, the same as on main
review: 1 high, 3 medium (below)
performance: 60 s smoke run: 1422 → 1670 frames (117 % of main), peak commit 17184 → 16928 MB, no device removal, no crash
title run: not run
verdict: not yet: it is a draft, PR description is red, and 1 high finding (below): the default dirty-upload copy into write-combined memory is measured only into an ordinary buffer, with no smoke runs and no suite run of this head
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: On the default (and only) dirty-upload path, each full 64-byte chunk is now read once from the title's memory, and that one read is both written to the upload ring and hashed; main reads twice (hash first, then a separate memcpy: stage_copies/run_copies sparse.rs ~7499-7557, submit_upload ~4738). That also fixes a real race (finding 2). The suite and smoke run below are clean, but the speed-up was measured on the wrong kind of memory and the PR has no evidence of its own yet.

High

  1. The hot default path changed, measured only into ordinary memory. run_copies replaces one bulk copy_nonoverlapping per job with a 64-byte read/write loop into the write-combined upload heap (staging, ~4083), with no opt-out. The numbers come from a Vec target only, and there are no smoke blocks or suite run of this head (the PR description check fails). Measure into the real upload heap and add the smoke pair.

Medium

  1. The correctness gain is neither mentioned nor pinned by a test. On main, a CPU write sequence B→C→B between the hash and the memcpy left C on the GPU with H(B) stored, so the chunk was never sent again. The fused read closes that, but no test pins "stored hash = bytes uploaded" under a concurrent write (the edited test, ~10479, covers only a write after the copy). Say it in the description and add that test.
  2. A manual benchmark sits in mod tests as #[ignore]. bench_upload_ab_sparse (~10495) is a benchmark, not a test, and its equivalence asserts duplicate the new test. Move it to benches/ or drop it.
  3. Description incomplete. AI use gives no exact model, there is no what/why paragraph and no issue link, and "214 focused tests" came from a combined development checkout, not this head.
Checked and fine
  • Hashes are published only after Submitted (~4209), and the ring rolls back on NotSubmitted.
  • Partial prefix/suffix chunks are copied but not hashed, as on main, and the prefix comes from the window address.
  • hash_words(..from_le) equals chunk_hash.
  • The parallel journal split, assert!(journal.is_empty()) and set_len after the join are sound.
  • The upload heap is never read back.
  • The new test covers misaligned windows and the worker path.
How this was tested
  • Merged onto main 5eaadb54, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 5eaadb54 and on this merge; presents per 2 s at the end: 60 60 60.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7354726968 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3702#issuecomment-7354726968). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-02T18:31:19Z. --- merge-check base: 5eaadb54c14e0fc29597b2a1689d7dbd83491303 head: 77d276fa70866ed50b8c8c20446081a87fd90752 merge: clean build: ok tests: 2975 passed, 0 failed, 53 ignored; 28 skipped, the same as on main review: 1 high, 3 medium (below) performance: 60 s smoke run: 1422 → 1670 frames (117 % of main), peak commit 17184 → 16928 MB, no device removal, no crash title run: not run verdict: not yet: it is a draft, `PR description` is red, and 1 high finding (below): the default dirty-upload copy into write-combined memory is measured only into an ordinary buffer, with no smoke runs and no suite run of this head hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** On the default (and only) dirty-upload path, each full 64-byte chunk is now read once from the title's memory, and that one read is both written to the upload ring and hashed; main reads twice (hash first, then a separate `memcpy`: `stage_copies`/`run_copies` `sparse.rs` ~7499-7557, `submit_upload` ~4738). That also fixes a real race (finding 2). The suite and smoke run below are clean, but the speed-up was measured on the wrong kind of memory and the PR has no evidence of its own yet. #### High 1. **The hot default path changed, measured only into ordinary memory.** `run_copies` replaces one bulk `copy_nonoverlapping` per job with a 64-byte read/write loop into the write-combined upload heap (`staging`, ~4083), with no opt-out. The numbers come from a `Vec` target only, and there are no smoke blocks or suite run of this head (the `PR description` check fails). Measure into the real upload heap and add the smoke pair. #### Medium 2. **The correctness gain is neither mentioned nor pinned by a test.** On main, a CPU write sequence B→C→B between the hash and the `memcpy` left C on the GPU with H(B) stored, so the chunk was never sent again. The fused read closes that, but no test pins "stored hash = bytes uploaded" under a concurrent write (the edited test, ~10479, covers only a write after the copy). Say it in the description and add that test. 3. **A manual benchmark sits in `mod tests` as `#[ignore]`.** `bench_upload_ab_sparse` (~10495) is a benchmark, not a test, and its equivalence asserts duplicate the new test. Move it to `benches/` or drop it. 4. **Description incomplete.** AI use gives no exact model, there is no what/why paragraph and no issue link, and "214 focused tests" came from a combined development checkout, not this head. <details><summary>Checked and fine</summary> - Hashes are published only after `Submitted` (~4209), and the ring rolls back on `NotSubmitted`. - Partial prefix/suffix chunks are copied but not hashed, as on main, and the prefix comes from the window address. - `hash_words(..from_le)` equals `chunk_hash`. - The parallel journal split, `assert!(journal.is_empty())` and `set_len` after the join are sound. - The upload heap is never read back. - The new test covers misaligned windows and the worker path. </details> <details><summary>How this was tested</summary> - Merged onto main `5eaadb54`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `5eaadb54` and on this merge; presents per 2 s at the end: 60 60 60. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
capy-ai[bot] commented 2026-12-02 20:10:08 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by capy-ai[bot] on 2026-12-02T20:10:08Z.


Code review (head 2fe4985512, diff read only — not built or tested on Windows/GPU, not a merge-check)

No code or memory-safety bugs found; merges cleanly onto origin/main (5ad98adb). This looks like a strong win.

  • Implementation is sound and fixes a race on main: fusing each full 64-byte chunk load into [u64; 8] registers (stage_copies), writing unaligned 64-byte runs into the WC staging ring, and hashing words.map(u64::from_le) matches chunk_hash / read_chunk_words byte-for-byte while guaranteeing the journaled hash matches the exact bytes uploaded (closing the concurrent guest B -> C -> B mutation window between hashing and copy_nonoverlapping on main).
  • Parallel & unwind safety hold: UploadCopy::prefix avoids overflow on misaligned windows and sub-chunk spans, each worker piece gets a disjoint Mutex<&mut [MaybeUninit<HashUpdate>]>, assert!(journal.is_empty()) confirms full initialization before updates.set_len(old_len + chunks) after join, and hashes still publish only on SubmitResult::Submitted.
  • Remaining items (non-blocking):
    • #3701 and #3702 both add the identical with_upload_pair helper at crates/xcl/src/gpu/recomp/runner.rs:566 (the second to merge will need to drop its duplicate).
    • Minor repo hygiene: title/commit still lack a D3D12.X: / Memory: area prefix, AI use names OpenAI Codex without the exact model name, and the two #[ignore] timing tests sit in mod tests rather than crates/xcl/benches/.
  • Still needed for merge: full Windows workspace test suite, an AMD check (gpu:both), and a real title run past loading on head 2fe4985512.

AI use: Capy, Google Gemini 4 Neon (static code review only; not built or tested on Windows/GPU).

<!-- greyfinch-sync:ivall/xcl:comment:7357319184 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3702#issuecomment-7357319184). Originally posted by [capy-ai[bot]](https://github.com/apps/capy-ai) on 2026-12-02T20:10:08Z. --- Code review (head `2fe4985512`, diff read only — not built or tested on Windows/GPU, not a merge-check) No code or memory-safety bugs found; merges cleanly onto `origin/main` (`5ad98adb`). This looks like a strong win. - **Implementation is sound and fixes a race on `main`:** fusing each full 64-byte chunk load into `[u64; 8]` registers (`stage_copies`), writing unaligned 64-byte runs into the WC staging ring, and hashing `words.map(u64::from_le)` matches `chunk_hash` / `read_chunk_words` byte-for-byte while guaranteeing the journaled hash matches the exact bytes uploaded (closing the concurrent guest `B -> C -> B` mutation window between hashing and `copy_nonoverlapping` on `main`). - **Parallel & unwind safety hold:** `UploadCopy::prefix` avoids overflow on misaligned windows and sub-chunk spans, each worker piece gets a disjoint `Mutex<&mut [MaybeUninit<HashUpdate>]>`, `assert!(journal.is_empty())` confirms full initialization before `updates.set_len(old_len + chunks)` after join, and hashes still publish only on `SubmitResult::Submitted`. - **Remaining items (non-blocking):** - `#3701` and `#3702` both add the identical `with_upload_pair` helper at `crates/xcl/src/gpu/recomp/runner.rs:566` (the second to merge will need to drop its duplicate). - Minor repo hygiene: title/commit still lack a `D3D12.X:` / `Memory:` area prefix, `AI use` names `OpenAI Codex` without the exact model name, and the two `#[ignore]` timing tests sit in `mod tests` rather than `crates/xcl/benches/`. - **Still needed for merge:** full Windows workspace test suite, an AMD check (`gpu:both`), and a real title run past loading on head `2fe4985512`. AI use: Capy, Google Gemini 4 Neon (static code review only; not built or tested on Windows/GPU).
Kalmarv commented 2026-12-02 20:42:31 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T20:42:31Z.


merge-check
base: 5ad98adbc3 (current main)
head: 2fe4985512
merge: clean (8be3f02af; runner.rs auto-merged)
build: cargo check -p xcl --all-targets -> ok (39 lib / 19 lib-test warnings, same as main 5ad98adbc); git diff --check clean
tests: cargo test -p xcl --lib -- --test-threads=1 on the touched sparse tests (staging_copies_and_hashes_cover_only_the_requested_ranges, hash_plan_is_published_only_when_applied, only_changed_chunks_are_sent, batch_hash_plan_is_bounded_by_staging, prepared_dirty_batch_keeps_exact_hash_plan_and_rollback_point, ring_planner_handles_wrap_and_large_chunks) -> 6 passed, 0 failed. Full workspace suite and GPU tests not run here; Foniass's full suite on 77d276fa7 (this code without the bench commit) passed 2975/0.
review:

  • This fixes a stale-upload race on main; the description should say so.
    • On main, submit_upload hashes each full chunk from the title's memory first, then run_copies copies it into the ring.
    • If the CPU writes B, then C, then B again between the two, the GPU gets C while sent holds H(B).
    • On the next look, changed_chunks (sparse.rs:2947 on main) sees B == H(B) and never sends the chunk again, so the GPU keeps stale bytes.
    • With the fused read (stage_copies, sparse.rs:7498), the journal hash is always the hash of the exact words staged. A read torn by a concurrent write still leaves the page write-watched and the chunk different from its journal hash, so it goes up again.
    • staging_copies_and_hashes_cover_only_the_requested_ranges (:10569, misaligned windows and the pool path) already pins "journal = hashes of the staged bytes", so only the description is missing.
  • Write-combined path. The mapped benchmark answers the earlier concern that only ordinary RAM was measured: 38-51 % less staging time into a real UPLOAD heap (0x404). Each full chunk is one 64 B store.
    • Ring offsets are 64-aligned (RING_ALIGN, plan_ring_chunk), and dirty runs from changed_chunks start on chunk boundaries, so in practice prefix() == 0 and each store fills one WC line.
    • When a job's window start is not 64-aligned, every full chunk lands prefix bytes into a line and straddles two lines. The new test exercises exactly that (windows +3, +19). Is it reachable at runtime?
    • If yes, offsetting the ring start by window % 64 keeps the stores line-aligned. If not, a debug_assert! would document it.
  • Panic safety looks right. updates.set_len(old_len + chunks) (:7556) runs only after the worker-pool join, and the MaybeUninit slots are never read before then.
  • Shared helper with #3701. runner::with_upload_pair is byte-identical in both PRs, and a trial merge of the two heads is clean.
  • Minor: bench_upload_ab_sparse (ordinary RAM) is superseded by bench_upload_ab_sparse_mapped and could go.

performance: not run here; no GPU work in this check. The description's smoke pair can't be read as evidence: a hash/copy fusion doesn't move peak commit from 23,474 to 14,909 MB, and the main block (presents 51/16/48) is shared with #3701/#3703. Foniass's 5070 Ti pair on 77d276fa7 (the same code without the bench commit), 1,422 -> 1,670 frames, 0 removals, is the usable one.
verdict: safe to merge: correct by reading and its tests pass on current main; please add the B-C-B race fix to the description, since it changes what the default upload path guarantees.
hardware / tool and model: NVIDIA GeForce RTX 5070 Ti, driver 32.0.16.1074, AMD Ryzen 9 9950X, Windows 11 Pro 26200 / Claude Code (claude-opus-5-5)

<!-- greyfinch-sync:ivall/xcl:comment:7358183805 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3702#issuecomment-7358183805). Originally posted by [Kalmarv](https://github.com/Kalmarv) on 2026-12-02T20:42:31Z. --- merge-check base: 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd (current main) head: 2fe4985512ffea690ff9b7b657e4b7736a403cce merge: clean (8be3f02af; runner.rs auto-merged) build: cargo check -p xcl --all-targets -> ok (39 lib / 19 lib-test warnings, same as main 5ad98adbc); git diff --check clean tests: cargo test -p xcl --lib -- --test-threads=1 on the touched sparse tests (staging_copies_and_hashes_cover_only_the_requested_ranges, hash_plan_is_published_only_when_applied, only_changed_chunks_are_sent, batch_hash_plan_is_bounded_by_staging, prepared_dirty_batch_keeps_exact_hash_plan_and_rollback_point, ring_planner_handles_wrap_and_large_chunks) -> 6 passed, 0 failed. Full workspace suite and GPU tests not run here; Foniass's full suite on 77d276fa7 (this code without the bench commit) passed 2975/0. review: - **This fixes a stale-upload race on `main`; the description should say so.** - On `main`, `submit_upload` hashes each full chunk from the title's memory first, then `run_copies` copies it into the ring. - If the CPU writes B, then C, then B again between the two, the GPU gets C while `sent` holds H(B). - On the next look, `changed_chunks` (`sparse.rs:2947` on `main`) sees B == H(B) and never sends the chunk again, so the GPU keeps stale bytes. - With the fused read (`stage_copies`, `sparse.rs:7498`), the journal hash is always the hash of the exact words staged. A read torn by a concurrent write still leaves the page write-watched and the chunk different from its journal hash, so it goes up again. - `staging_copies_and_hashes_cover_only_the_requested_ranges` (`:10569`, misaligned windows and the pool path) already pins "journal = hashes of the staged bytes", so only the description is missing. - **Write-combined path.** The mapped benchmark answers the earlier concern that only ordinary RAM was measured: 38-51 % less staging time into a real `UPLOAD` heap (`0x404`). Each full chunk is one 64 B store. - Ring offsets are 64-aligned (`RING_ALIGN`, `plan_ring_chunk`), and dirty runs from `changed_chunks` start on chunk boundaries, so in practice `prefix() == 0` and each store fills one WC line. - When a job's window start is not 64-aligned, every full chunk lands `prefix` bytes into a line and straddles two lines. The new test exercises exactly that (windows `+3`, `+19`). Is it reachable at runtime? - If yes, offsetting the ring start by `window % 64` keeps the stores line-aligned. If not, a `debug_assert!` would document it. - **Panic safety looks right.** `updates.set_len(old_len + chunks)` (`:7556`) runs only after the worker-pool join, and the `MaybeUninit` slots are never read before then. - **Shared helper with #3701.** `runner::with_upload_pair` is byte-identical in both PRs, and a trial merge of the two heads is clean. - Minor: `bench_upload_ab_sparse` (ordinary RAM) is superseded by `bench_upload_ab_sparse_mapped` and could go. performance: not run here; no GPU work in this check. The description's smoke pair can't be read as evidence: a hash/copy fusion doesn't move peak commit from 23,474 to 14,909 MB, and the `main` block (presents 51/16/48) is shared with #3701/#3703. Foniass's 5070 Ti pair on `77d276fa7` (the same code without the bench commit), 1,422 -> 1,670 frames, 0 removals, is the usable one. verdict: safe to merge: correct by reading and its tests pass on current main; please add the B-C-B race fix to the description, since it changes what the default upload path guarantees. hardware / tool and model: NVIDIA GeForce RTX 5070 Ti, driver 32.0.16.1074, AMD Ryzen 9 9950X, Windows 11 Pro 26200 / Claude Code (claude-opus-5-5)
lucsoft commented 2026-12-02 20:43:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-02T20:43:32Z.


merge-check claim
head: 2fe4985512

<!-- greyfinch-sync:ivall/xcl:comment:7358212274 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3702#issuecomment-7358212274). Originally posted by [lucsoft](https://github.com/lucsoft) on 2026-12-02T20:43:32Z. --- merge-check claim head: 2fe4985512ffea690ff9b7b657e4b7736a403cce
lucsoft commented 2026-12-02 23:13:24 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-02T23:13:24Z.


merge-check
base: 5ad98adbc3
head: 2fe4985512
merge: clean (merge commit 63760ca2, auto-merge in runner.rs, git diff --check clean)
build: cargo build --release -p xcl && cargo test --workspace --release --no-run (x86_64-pc-windows-gnu) -> ok
tests: lib 2798 passed, 17 failed, 15 ignored, 31 died; integration 137 passed, 6 failed, 20 ignored, 1 exe died (main 5ad98adb: lib 2797 / 17 / 13 / 31, integration identical; +1 passed = staging_copies_and_hashes_cover_only_the_requested_ranges, +2 ignored = the manual benches). Under Wine, one test module per process with --test-threads=2, not 4. Skipped: 8 tests, the same set as on main (no dxc.exe, no D3D12 debug layer, heap windows opt-in, driver cache cannot be disabled, stale-blob probe refused, Close does not refuse an open pipeline-statistics query x2, SetPredication ignored for copies). failing: every failure also fails on main 5ad98adb in the same setup (suite-diff by test name: 0 only on this PR): 31 died = 29 split-wave/DXIL GPU tests that abort in dxil-spirv without #3707 (module::split 10, mask_exchange 5, lower_dxil 5, recomp 4, robustness 2, idioms 2, lower 1), hle::netoff 1, and the known serialize_root_signature hang (not run), 17 failed = Wine/RADV-specific (title_textures group 4, list_x 3, recomp 2, lower_dxil 2, and single ones in root_signature, driver_cache, descriptor_heap, device_x, round, fuzz); integration: gpu_compute_e2e died, e2e x2, frame_clock, gpu_two_pass_cache_e2e, pls_quota, tls_slot_zero fail on main too
title run: retail title, RX 7800 XT (RADV, Wine), 480 s run, past the loading screen into the in-engine intro cutscenes / prologue (world rendering from 123 s: first 2 s window with >= 1000 draws), 358 s there, no crash, no device removal, 0 amdgpu page faults or ring timeouts, 0.88 presents/s there (2617 frames in total). Run on this merge result + #3707 (912ff558) on top: main 5ad98adb alone aborts ~3 s in under vkd3d-proton (dxil-spirv, the helper functions #3707 inlines), so did this merge without it (exit 0x3 at ~3.3 s). main 5ad98adb + #3707 the same way: 359 s there, no crash, 0.59 presents/s, 2182 frames.
review: read the whole diff (+211/-61). Each full 64-byte chunk is now read once into [u64; 8], written to the ring and hashed from the same words; hash_words(words.map(u64::from_le)) equals chunk_hash of those bytes (read_chunk_words is from_le_bytes of the same unaligned words). This closes the window on main where the journal hashed one read of guest memory and the ring got a later read. prefix()/chunks() give the same full-chunk set as the old next_multiple_of/& !(CHUNK-1) loop (by window address; partial chunks still get no update). The parallel path splits the reserved journal by each piece's chunk count, the last piece is closed by k + 1 == len, stage_copies asserts its slice is used up, and set_len runs only after every slot was written (on unwind the old length stays). batch.updates stays within MAX_BATCH_HASH_UPDATES (= STAGING / CHUNK). with_upload_pair is #[cfg(test)]. Untested here: NVIDIA; the >= 512 KiB pool path ran only in the unit test, not separately measured in the title. No findings.
performance: one guest read per staged chunk instead of two (hash pass + copy pass), so less memory traffic by default; no new allocation (reserve on the existing Vec). Title run 0.88 presents/s vs 0.59 on the base (noise at this rate, not a measurement of the change).
verdict: safe to merge
hardware / tool and model: AMD Radeon RX 7800 XT (RADV NAVI32, Mesa 26.3.1), Ryzen 7 7800X3D, NixOS (Linux 7.3.5) with Wine staging 11.21 + vkd3d-proton 3.1 / Claude Code, claude-opus-5-5

<!-- greyfinch-sync:ivall/xcl:comment:7361719433 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3702#issuecomment-7361719433). Originally posted by [lucsoft](https://github.com/lucsoft) on 2026-12-02T23:13:24Z. --- merge-check base: 5ad98adbc360225ac8a57ad9661e16fe8df9d8dd head: 2fe4985512ffea690ff9b7b657e4b7736a403cce merge: clean (merge commit 63760ca2, auto-merge in runner.rs, git diff --check clean) build: cargo build --release -p xcl && cargo test --workspace --release --no-run (x86_64-pc-windows-gnu) -> ok tests: lib 2798 passed, 17 failed, 15 ignored, 31 died; integration 137 passed, 6 failed, 20 ignored, 1 exe died (main 5ad98adb: lib 2797 / 17 / 13 / 31, integration identical; +1 passed = staging_copies_and_hashes_cover_only_the_requested_ranges, +2 ignored = the manual benches). Under Wine, one test module per process with --test-threads=2, not 4. Skipped: 8 tests, the same set as on main (no dxc.exe, no D3D12 debug layer, heap windows opt-in, driver cache cannot be disabled, stale-blob probe refused, Close does not refuse an open pipeline-statistics query x2, SetPredication ignored for copies). failing: every failure also fails on main 5ad98adb in the same setup (suite-diff by test name: 0 only on this PR): 31 died = 29 split-wave/DXIL GPU tests that abort in dxil-spirv without #3707 (module::split 10, mask_exchange 5, lower_dxil 5, recomp 4, robustness 2, idioms 2, lower 1), hle::netoff 1, and the known serialize_root_signature hang (not run), 17 failed = Wine/RADV-specific (title_textures group 4, list_x 3, recomp 2, lower_dxil 2, and single ones in root_signature, driver_cache, descriptor_heap, device_x, round, fuzz); integration: gpu_compute_e2e died, e2e x2, frame_clock, gpu_two_pass_cache_e2e, pls_quota, tls_slot_zero fail on main too title run: retail title, RX 7800 XT (RADV, Wine), 480 s run, past the loading screen into the in-engine intro cutscenes / prologue (world rendering from 123 s: first 2 s window with >= 1000 draws), 358 s there, no crash, no device removal, 0 amdgpu page faults or ring timeouts, 0.88 presents/s there (2617 frames in total). Run on this merge result + #3707 (912ff558) on top: main 5ad98adb alone aborts ~3 s in under vkd3d-proton (dxil-spirv, the helper functions #3707 inlines), so did this merge without it (exit 0x3 at ~3.3 s). main 5ad98adb + #3707 the same way: 359 s there, no crash, 0.59 presents/s, 2182 frames. review: read the whole diff (+211/-61). Each full 64-byte chunk is now read once into [u64; 8], written to the ring and hashed from the same words; hash_words(words.map(u64::from_le)) equals chunk_hash of those bytes (read_chunk_words is from_le_bytes of the same unaligned words). This closes the window on main where the journal hashed one read of guest memory and the ring got a later read. prefix()/chunks() give the same full-chunk set as the old next_multiple_of/& !(CHUNK-1) loop (by window address; partial chunks still get no update). The parallel path splits the reserved journal by each piece's chunk count, the last piece is closed by k + 1 == len, stage_copies asserts its slice is used up, and set_len runs only after every slot was written (on unwind the old length stays). batch.updates stays within MAX_BATCH_HASH_UPDATES (= STAGING / CHUNK). with_upload_pair is #[cfg(test)]. Untested here: NVIDIA; the >= 512 KiB pool path ran only in the unit test, not separately measured in the title. No findings. performance: one guest read per staged chunk instead of two (hash pass + copy pass), so less memory traffic by default; no new allocation (reserve on the existing Vec). Title run 0.88 presents/s vs 0.59 on the base (noise at this rate, not a measurement of the change). verdict: safe to merge hardware / tool and model: AMD Radeon RX 7800 XT (RADV NAVI32, Mesa 26.3.1), Ryzen 7 7800X3D, NixOS (Linux 7.3.5) with Wine staging 11.21 + vkd3d-proton 3.1 / Claude Code, claude-opus-5-5
Foniass commented 2026-12-03 02:29:01 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-03T02:29:01Z.


merge-check
base: 078358a058
head: 2fe4985512
merge: clean
build: ok
tests: 3007 passed, 0 failed, 54 ignored; 28 skipped, the same as on main
review: 3 medium, 1 nit (below)
performance: 60 s smoke run: 1669 → 1683 frames (100 % of main), peak commit 17577 → 17846 MB, no device removal, no crash
title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 227 s there, 0 device removals, 0 crashes, 3 presents/s; run with XCL_SKIP_CS=95cc13288a27a96e (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590)
verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean
hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5


In short: On the dirty-upload path, each full 64-byte chunk is now read once from the title's memory, and that one copy is both written to the upload ring and hashed; main hashed first and then ran a separate memcpy. Since the earlier merge-check it has added smoke blocks and a benchmark into a real write-combined upload heap, and the description now names the race it closes. Nothing blocks; still open are a test of that race, the benchmarks left in mod tests, and the description.

Medium

  1. The race fix has no test that fails without it. The description now says the fused read closes the window between hash and copy (a write sequence B, C, B left C on the GPU with H(B) stored). No test shows it: staging_copies_and_hashes_cover_only_the_requested_ranges uses a static source, and cpu_write_after_planning_is_dirty_after_receipt_publication writes only after the copy. A deterministic race test is hard; at least assert in the existing test that each journal hash equals chunk_hash of the ring bytes at its offset, the property that matters.
  2. Manual benchmarks in mod tests. bench_upload_ab_sparse and the new bench_upload_ab_sparse_mapped (sparse.rs ~10495-10570) are #[ignore] benchmarks among the unit tests, and the RAM one is superseded by the mapped one. Drop the RAM one and move the mapped one to benches/ (earlier finding still open).
  3. Description and commit gaps. There is no what/why paragraph before What is in it and no issue link. The 214 focused tests ran on a combined checkout, not this head, and there are no full-suite counts. The first commit has no area prefix (use D3D12.X:).

Nit

  1. Smoke pair differs by more than the change. Main shows 1449 frames (presents 51 16 48, peak commit 23474 MB) and the PR 1575 frames (61 60 60, 14909 MB). The runs were at different points of loading, so the +9 % is not from this change; do not cite it as a gain.
Checked and fine
  • Earlier finding fixed: the staging cost is now measured into a native upload heap reported as write-combined (64 KiB: 4.763 to 2.399 µs), and both smoke blocks are in the PR
  • Earlier finding fixed (description part): the description now says the fused read closes the window between hash and copy
  • prefix() and chunks() give the same full chunks as main's next_multiple_of/mask loop, keyed by the window address; partial chunks are copied but not hashed, as on main
  • hash_words(words.map(u64::from_le)) equals chunk_hash, and the ring is written but never read back
  • The parallel split gives each piece exactly its jobs' journal slots, assert!(journal.is_empty()) checks it, and set_len runs only after the worker pool joins
  • Hashes are still published only after the submit (submit_upload, then submit_dirty_batch), as on main
How this was tested
  • Merged onto main 078358a0, then cargo build --workspace and cargo test --workspace --no-fail-fast -- --test-threads=4.
  • The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar).
  • scripts/smoke.ps1: 60 s of a retail title on main 078358a0 and on this merge; presents per 2 s at the end: 60 60 60.
  • Title run: the release build of this merge launched the retail title with XCL_RUN_SECONDS=300 and scripted A presses counted from the first frame (XCL_PRESS_BASE=frame, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run.

Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.

<!-- greyfinch-sync:ivall/xcl:comment:7365509315 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/3702#issuecomment-7365509315). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-03T02:29:01Z. --- merge-check base: 078358a058f7ba5d16690dba8dc4e55d2c88ae0a head: 2fe4985512ffea690ff9b7b657e4b7736a403cce merge: clean build: ok tests: 3007 passed, 0 failed, 54 ignored; 28 skipped, the same as on main review: 3 medium, 1 nit (below) performance: 60 s smoke run: 1669 → 1683 frames (100 % of main), peak commit 17577 → 17846 MB, no device removal, no crash title run: retail title on the RTX 5070 Ti (driver 621.14), into the world by scripted presses: 227 s there, 0 device removals, 0 crashes, 3 presents/s; run with `XCL_SKIP_CS=95cc13288a27a96e` (the NVIDIA hang at the end of loading, #3541) and NVIDIA's 2048 MB shader heap (#2590) verdict: safe to merge: no blocking finding (the points below are medium or nits), the suite passes and the smoke run is clean hardware / tool and model: RTX 5070 Ti (driver 621.14), Ryzen 7 7800X3D, Windows 11 26300 / Claude Code with Claude Opus 5.5 --- **In short:** On the dirty-upload path, each full 64-byte chunk is now read once from the title's memory, and that one copy is both written to the upload ring and hashed; main hashed first and then ran a separate memcpy. Since the earlier merge-check it has added smoke blocks and a benchmark into a real write-combined upload heap, and the description now names the race it closes. Nothing blocks; still open are a test of that race, the benchmarks left in mod tests, and the description. #### Medium 1. **The race fix has no test that fails without it.** The description now says the fused read closes the window between hash and copy (a write sequence B, C, B left C on the GPU with H(B) stored). No test shows it: staging_copies_and_hashes_cover_only_the_requested_ranges uses a static source, and cpu_write_after_planning_is_dirty_after_receipt_publication writes only after the copy. A deterministic race test is hard; at least assert in the existing test that each journal hash equals chunk_hash of the ring bytes at its offset, the property that matters. 2. **Manual benchmarks in mod tests.** bench_upload_ab_sparse and the new bench_upload_ab_sparse_mapped (sparse.rs ~10495-10570) are #[ignore] benchmarks among the unit tests, and the RAM one is superseded by the mapped one. Drop the RAM one and move the mapped one to benches/ (earlier finding still open). 3. **Description and commit gaps.** There is no what/why paragraph before What is in it and no issue link. The 214 focused tests ran on a combined checkout, not this head, and there are no full-suite counts. The first commit has no area prefix (use D3D12.X:). #### Nit 4. **Smoke pair differs by more than the change.** Main shows 1449 frames (presents 51 16 48, peak commit 23474 MB) and the PR 1575 frames (61 60 60, 14909 MB). The runs were at different points of loading, so the +9 % is not from this change; do not cite it as a gain. <details><summary>Checked and fine</summary> - Earlier finding fixed: the staging cost is now measured into a native upload heap reported as write-combined (64 KiB: 4.763 to 2.399 µs), and both smoke blocks are in the PR - Earlier finding fixed (description part): the description now says the fused read closes the window between hash and copy - prefix() and chunks() give the same full chunks as main's next_multiple_of/mask loop, keyed by the window address; partial chunks are copied but not hashed, as on main - hash_words(words.map(u64::from_le)) equals chunk_hash, and the ring is written but never read back - The parallel split gives each piece exactly its jobs' journal slots, assert!(journal.is_empty()) checks it, and set_len runs only after the worker pool joins - Hashes are still published only after the submit (submit_upload, then submit_dirty_batch), as on main </details> <details><summary>How this was tested</summary> - Merged onto main `078358a0`, then `cargo build --workspace` and `cargo test --workspace --no-fail-fast -- --test-threads=4`. - The skipped GPU tests are those this card can't run (no wave64 on NVIDIA, no D3D12 debug layer, and similar). - `scripts/smoke.ps1`: 60 s of a retail title on main `078358a0` and on this merge; presents per 2 s at the end: 60 60 60. - Title run: the release build of this merge launched the retail title with `XCL_RUN_SECONDS=300` and scripted A presses counted from the first frame (`XCL_PRESS_BASE=frame`, #3712) into the world from an existing save; time in the world is counted from the first in-world draw call to the end of the run. </details> <sub>Written by Claude Code (Claude Opus 5.5) and posted by Foniass without a human check of each point.</sub>
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!3702
No description provided.