Skip to content

DirectStorage: reuse small sequential file input buffers - #2530

Open
razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:directstorage/reuse-small-file-input-staging
Open

razormontana wants to merge 1 commit into
xcl-dev:mainfrom
razormontana:directstorage/reuse-small-file-input-staging

Conversation

@razormontana

Copy link
Copy Markdown
Contributor

Part of #1833. The default DirectStorage worker allocates and zeroes an input buffer for every file request. A worker now retains up to 64 KiB of initialized input storage and reuses it across requests. Larger reads use a temporary buffer.

What is in it

  • crates/xcl/src/hle/dstorage.rs keeps a worker-local buffer and passes the exact bytes of each successful read to the existing decode and delivery paths. The opt-in decompression pool uses its existing staging budget.
  • crates/xcl/src/hle/dstorage/parallel_tests.rs checks allocation reuse at the high-water size, reads beyond the cache size, and FIFO status and destination bytes after a short read.

Tested

  • Windows 11 Pro 22631, Intel Core i7-10700K, NVIDIA GeForce RTX 3070 (32.0.16.1742), Rust 1.100.0 MSVC, Windows SDK DXC. Clean head 73643dae7e179eb0dfc2c27d3503aff7e2351f34.
  • cargo test --offline --locked -j 2 -p xcl --lib hle::dstorage:: -- --test-threads=1 --nocapture passed 34 tests with zero failures, ignored tests, or skips both with default settings and with XCL_DSTORAGE_PARALLEL_DECOMPRESS=1. With the new tests and the old allocation path, the high-water assertion failed and the short-read compatibility case passed.
  • An optimized standalone Windows probe used four alternating synthetic request sizes from 4 to 48 KiB and 16,384 cached file reads. The original input strategy made 16,384 allocations or reallocations, compared with 4 with reuse. Across five alternating pairs, median elapsed time was 91.216 ms before and 65.439 ms with reuse.
  • cargo build --offline --locked --workspace and cargo build --offline --locked --release --workspace succeeded. The debug cargo test --offline --locked --workspace --no-fail-fast -- --test-threads=4 --show-output run with XCL_ADAPTER=3070 reported 1,426 passed, 0 failed and 46 ignored across 37 targets. The pass count includes 26 SKIPPED notices (21 native-wave64 checks, 3 unsupported per-lane forms, 1 reserved cube with mips and 1 heap-window check).

Regression run

Both clean release builds ran scripts/smoke.ps1 -Game <folder> -Seconds 60 on the same retail title in the Series S profile on the RTX 3070. They used XCL_DIRECT_DXIL=1, networking off and identical starting copies of XCL's warmed cache. NVIDIA's driver cache settings were left at their defaults.

Main

xcl-smoke v1
commit: 6d12f58a229bc73889878a448c64dc3af25eeba0
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 651 (PresentX 651)
presents per 2 s (last 3): 8 0 15
device removals: 0
crashes: 0
peak commit: 14469 MB

Candidate

xcl-smoke v1
commit: 73643dae7e179eb0dfc2c27d3503aff7e2351f34
gpu: NVIDIA GeForce RTX 3070
title: 3c290c16
seconds: 60
exit: 0x0
frames shown: 670 (PresentX 670)
presents per 2 s (last 3): 1 13 19
device removals: 0
crashes: 0
peak commit: 14690 MB

Not tested

  • Retail world-load timing and file input under Wine. The workspace GPU suite ran on NVIDIA. AMD and Intel GPU coverage is pending.

AI use

  • OpenAI Codex (GPT-6.2 Sol) investigated the allocation path, wrote the change and tests, ran the focused validation and probe, independently reviewed the diff and evidence, and drafted this description. The lead agent ran the workspace suite and retail smoke using OpenAI Codex (GPT-6.2).

Sequential file requests repeatedly allocate and zero the input buffer. Keep up to 64 KiB per worker and expose only the exact bytes of a successful read. A synthetic read-loop probe counted 16,384 allocation calls without reuse and four with reuse.

Part of xcl-dev#1833.

Assisted-by: Codex (GPT-6 family, exact variant unavailable)
@razormontana
razormontana marked this pull request as ready for review November 25, 2026 22:01
@DavidM1911

Copy link
Copy Markdown
Contributor

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

Thanks!

@xpatfussy69x

Copy link
Copy Markdown

Test run on exact head 73643da (73643dae7e179eb0dfc2c27d3503aff7e2351f34, on its base 6d12f58), clean tree.

Tested

  • NVIDIA GeForce RTX 3060 12 GB (driver 32.0.16.2124, 32-lane waves only), AMD Ryzen 5 7500F, Windows 11, Rust 1.100.0; debug build for the tests, release for the smoke runs
  • cargo test --workspace -- --test-threads=4: 1426 passed, 0 failed, 46 ignored
  • SKIPPED (25): 21 × no wave64; 1 × no heap windows; 3 × per-lane form refused V_MUL_F16 / V_PK_MUL_F16 / V_CVT_F16_F32 (on main too)
  • cargo test -p xcl --lib sequential: 4 passed, 0 failed
  • This PR's new tests in the workspace run:
    • sequential_file_input_reuses_its_high_water_allocation: ok
    • an_oversized_sequential_file_input_does_not_grow_the_cache: ok
    • sequential_short_read_preserves_destination_and_the_next_request_completes: ok

Regression run (60 s, default settings, a retail title)

main:

xcl-smoke v1
commit: e1d84b7d9153f86a97d2ec5d209d196046fc0bea
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1091 (PresentX 1091)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14814 MB

this PR:

xcl-smoke v1
commit: 73643dae7e179eb0dfc2c27d3503aff7e2351f34
gpu: NVIDIA GeForce RTX 3060
title: c3f791f3
seconds: 60
exit: 0x0
frames shown: 1138 (PresentX 1138)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14792 MB

No crash or device removal; frames 104 % of main's, peak commit 100 %.

Not tested

  • Whether the title reads through DirectStorage file input in a way this changes is not shown by the run; load time was not measured: a regression check only
  • The PR merged into current main (tested on its own base; it merges into e1d84b7 without conflicts)
  • AMD / native wave64

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and both smoke runs on the machine above and wrote this report.

@SlopTart

Copy link
Copy Markdown

Tested: current PR head merged onto current origin/main (clean), Linux (Arch, kernel 7.2.15), Mesa 26.2.5 RADV, Radeon RX 7900 XT (NAVI31), cargo target x86_64-pc-windows-gnu run under wine-11.0 (Proton), rustc 1.94.0, vkd3d-proton 3.1 with the XCL patch, official MS DXC (binaries 2026-09-29).

gpu_ suite (cold cache): 165 passed / 3 failed, no crashes. The three are the known baseline on this lane (seed-1003 fuzz, mad/mac contraction, promoted-UAV-clear driver gap, PR #2490); none caused by this PR.

Targeted run of the DirectStorage sequential/reuse tests: 6 passed, so the reused buffer path is covered on the Wine lane too.
Not tested: retail titles (no title data on this lane, counts only).

AI use: Hermes agent (local Qwen-class) ran both machines and drafted this; I checked it before posting.

@emirduran707

Copy link
Copy Markdown
Contributor

Independent AMD RDNA4 (native wave64) verification of exact PR head 73643dae7e179eb0dfc2c27d3503aff7e2351f34 on Windows 11 Pro 26300 (AMD Radeon RX 9060 XT 16 GB, driver 32.0.31044.16, Ryzen 5 5600, Rust 1.100.0 MSVC, DXC 1.9.2602.17).

Tested

  • cargo build --workspace (debug): passed (0 errors).
  • cargo test --workspace --no-fail-fast -- --test-threads=4: 1424 passed, 2 failed, 46 ignored (8 SKIPPED: 6 per-lane DXIL forms refused by host adapter/driver, 1 heap_window_out_of_memory_falls_back_to_the_switch_form no heap windows, 1 pso_measurement_compiles_an_exact_synthetic_record Windows Developer Mode off).
    • All 3 new tests passed:
      • hle::dstorage::parallel::tests::an_oversized_sequential_file_input_does_not_grow_the_cache
      • hle::dstorage::parallel::tests::sequential_file_input_reuses_its_high_water_allocation
      • hle::dstorage::parallel::tests::sequential_short_read_preserves_destination_and_the_next_request_completes
    • The 2 failures (gpu::dxil::fuzz_tests::fuzz_validate_and_gpu_1 and fuzz_validate_and_gpu_3) are pre-existing on unmodified main on this RX 9060 XT / driver 32.0.31044.16.
  • cargo build --release -p xcl + 60 s retail-title smoke test (scripts/smoke.ps1, offline):
xcl-smoke v1
commit: 73643dae7e179eb0dfc2c27d3503aff7e2351f34
gpu: AMD Radeon RX 9060 XT
title: 21222967
seconds: 60
exit: 0x0
frames shown: 1600 (PresentX 1600)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 18513 MB

(Compare against main 08db8020 on this machine: 1553 frames, 13966 MB peak, 0 device removals, 0 crashes.)

Not tested

  • NVIDIA / Intel GPUs, Linux / Wine.

AI use

  • Verification run and report prepared with Antigravity (Gemini 4 Neon); all build, test, and smoke results are from live runs on this machine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants