DirectStorage: Reuse queue worker scratch for DirectStorage memory inputs #3703
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3703"
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 bmjask on 2026-12-02T15:38:30Z.
What is in it
Sequential workers reuse initialized source storage for memory requests up to 64 KiB. Once the buffer is large enough, the next request avoids allocation and zero-fill. Both payload copies remain so overlapping addresses retain snapshot semantics and a failed read cannot publish stale scratch.
Tested
cargo test --release --locked -p xcl --lib bench_upload_ab_memory_request -- --ignored --nocapture --test-threads=1.Regression run
Main
PR head
The worker passes only the current source length from its reusable scratch to the decoder. The reuse tests exercise raw requests. A short compressed input following a longer request remains untested. The failed-read test covers preservation of the destination; that behavior also existed on main.
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.
Imported from ivall/xcl. Originally posted by Foniass on 2026-12-02T18:25:57Z.
merge-check
base:
5eaadb54c1head:
7660d1b3f8merge: 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 → 1675 frames (117 % of main), peak commit 17184 → 16980 MB, no device removal, no crash
title run: not run
verdict: not yet: it is a draft,
PR descriptionis red, and 1 high finding (below): a default-path change with no smoke runs or suite counts. No code bug foundhardware / 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 sequential worker, every memory-source DirectStorage request of 64 KiB or less now reads into the worker's reused
input_scratch(the file-input scratch already on main from73643dae7, now shared asMAX_CACHED_INPUT) instead of a newvec![0; n]. No code bug found, and the suite and smoke run below are clean. What blocks it is missing evidence: it is a draft, with no smoke runs or suite counts of its own.High
dstorage.rs~963-992,run~1246). The smoke runs are "pending", there are no suite counts, and the gain (about 0.1-1 µs per request) comes from a microbenchmark. This is why thePR descriptioncheck fails. Add both smoke blocks and the suite counts from a run of this head.Medium
src). The code is correct by construction (&mut cached[..source_len]~970), but the new test (~1752) uses only uncompressed 96/31/16-byte requests. Add a compressed request that follows a longer one.cpu_range/readablefail before any delivery, on main as here. Make the failure happen after the scratch was filled, or drop the claim.DirectStorage:prefix.Checked and fine
execute, and it is per worker, so no two requests share it at once.parallel_tests.rschange is a constant rename only.How this was tested
5eaadb54, thencargo build --workspaceandcargo test --workspace --no-fail-fast -- --test-threads=4.scripts/smoke.ps1: 60 s of a retail title on main5eaadb54and 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.
Imported from ivall/xcl. Originally posted by capy-ai[bot] on 2026-12-02T20:10:08Z.
Code review (head
7660d1b3f8, 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).input_scratchfrom file-source to memory-source requests keeps ownership per-worker, preserves overlapping guestsrc/dstsnapshot semantics, fills the full&mut [u8]slice or returnsErrbefore decode/delivery across all three source paths, handlessource_len == 0without calling0.next_power_of_two(), and caps retained memory atMAX_CACHED_INPUT.input_scratchafter a larger request, and the failed-read check (src = 1) already fails before delivery onmain.DirectStorage:prefix,AI usenamesOpenAI Codexwithout the exact model name, andbench_upload_ab_memory_requestsits inmod testsas#[ignore]rather thancrates/xcl/benches/.7660d1b3f8.AI use: Capy, Google Gemini 4 Neon (static code review only; not built or tested on Windows/GPU).
Imported from ivall/xcl. Originally posted by Kalmarv on 2026-12-02T20:42:32Z.
merge-check
base:
5ad98adbc3(current main)head:
7660d1b3f8merge: clean (d1580a931)
build: cargo check -p xcl --all-targets -> ok (39 lib / 19 lib-test warnings, same as main
5ad98adbc); git diff --check cleantests: cargo test -p xcl --lib -- --test-threads=1 hle::dstorage:: -> 42 passed, 0 failed, 1 ignored (the manual bench). Full workspace suite and GPU tests not run here; Foniass's full suite on this same head passed 2975/0.
review:
execute.&mut cached[..source_len](dstorage.rs:965) is fully overwritten by each of the three source kinds (fileread_exact_at,read_physical_pages, the guest-memory copy), or the request fails before decode or delivery. So no stale tail is ever seen by zlib or the copy.vec, and the opt-in parallel pool still passesNone.E_FILE_HANDLEfor file requests is still raised after the destination checks, as before. Memory requests never touch it.maintoo (Foniass).src. A 64 KiB request followed by a short zlib memory request, checking the decoded bytes, would pin[..source_len].performance: not run here; no GPU work in this check. The description's smoke pair (1,449 -> 1,314 frames, presents 18/26/9) shares a disturbed
mainblock with #3701/#3702. Foniass's 5070 Ti pair on this head, 1,422 -> 1,675 frames, 0 removals, is the usable one.verdict: safe to merge: no bug found and the dstorage tests pass on current main; a compressed-after-longer memory request test would pin the one case it could break.
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)
Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-02T20:43:34Z.
merge-check claim
head:
7660d1b3f8Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-02T23:13:22Z.
merge-check
base:
5ad98adbc3head:
7660d1b3f8merge: clean (merge commit f19823a9, 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, 14 ignored, 31 died; integration 137 passed, 6 failed, 20 ignored, 1 exe died (main
5ad98adb: lib 2797 / 17 / 13 / 31, integration identical; +1 passed = sequential_memory_input_reuses_scratch_and_snapshots_overlapping_bytes, +1 ignored = the manual bench). 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 main5ad98adbin 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 tootitle 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), 357 s there, no crash, no device removal, 0 amdgpu page faults or ring timeouts, 0.72 presents/s there (2326 frames in total). Run on this merge result + #3707 (
912ff558) on top: main5ad98adbalone 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). main5ad98adb+ #3707 the same way: 359 s there, no crash, 0.59 presents/s, 2182 frames.review: read the whole diff (+91/-45). Memory-source requests up to 64 KiB now read into the sequential worker's reused scratch instead of a fresh Vec; larger ones and non-sequential callers still allocate. The source is still snapshotted before decode/delivery (overlapping src/dst stays correct), a failed physical-page or cpu_range/readable check returns before anything is written, only cached[..source_len] is exposed, and source_len 0 does not grow the buffer. The file-handle error (E_FILE_HANDLE) is still raised before any read. Later stages only borrow src (zlib, BCPack, write), so no former Cow::Owned move turns into a copy. No findings.
performance: one allocation + zero-fill less per small memory request on the sequential worker, at most 64 KiB kept per worker (unchanged cap). Not measured separately; title run 0.72 presents/s vs 0.59 on the base (noise at this rate).
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
Imported from ivall/xcl. Originally posted by lucsoft on 2026-12-03T15:06:57Z.
@Foniass could you take another look at your
not yeton #3703? It is the only thing keepingchecks-disagreeon, and its blocking reasons look resolved on the same head7660d1b3f879ebdc9f454c114c93312a6b98849e:PR descriptionred: it is green now (Build and test and triage are green too).xcl-smoke v1blocks (main5eaadb54and this head). Full-suite counts on this head are in your check (2975 passed, 0 failed) and in mine (no new failures against main5ad98adb, RX 7800 XT under Wine, plus a 357 s title run).Still open, but medium and not blocking: no test of a compressed request after a longer one (your point 2), and the failed-read test also passes on main (point 3). On the size of the gain: the author's microbenchmark gives the same result on a Ryzen 7 7800X3D under Wine. Over 5 repeats, the median fresh → reused times are 4 KiB 2.91 → 2.72 µs, 16 KiB 4.40 → 4.02 µs and 64 KiB 7.31 → 6.29 µs. That is real but very small per request.
If you agree, a new
merge-checkwithverdict: safe to mergeon this head replaces the old one. The bot counts only each account's latest check.Written by Claude Code (claude-opus-5-5) and posted by lucsoft.