Skip to content

DirectStorage: decode eligible file requests in parallel - #819

Merged
raylitebull merged 1 commit into
xcl-dev:mainfrom
ZekkJJ:codex/dstorage-parallel-decompression
Nov 24, 2026
Merged

raylitebull merged 1 commit into
xcl-dev:mainfrom
ZekkJJ:codex/dstorage-parallel-decompression

Conversation

@ZekkJJ

@ZekkJJ ZekkJJ commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Add an opt-in worker pool for file-backed, single-stage zlib DirectStorage requests with virtual destinations. The queue worker reads files and retires results in FIFO order. The pool is off by default.

What is in it

  • This head 1495e6df204a0836a7a4515fd16437cbe9ed7000 is based on c160d86ef2efe3a07e4dfb473e4fa72eafb413c0. Its entire patch matches the previously validated 59e9f3f85fd8292bd7bb4517a52a586489bea8bc byte-for-byte.
  • XCL_DSTORAGE_PARALLEL_DECOMPRESS=1 enables four workers and a shared 32 MiB staging budget by default. The runtime changes and 647 lines of deterministic tests are kept together to verify ordered retirement, cancellation, and the memory bound.

Tested

  • On this head, locked release builds for main and candidate, the debug workspace build, and 29 focused DirectStorage tests passed.
  • Windows 11 build 26200, Ryzen 7 8845HS, RTX 4060 Laptop GPU (NVIDIA 616.56), Rust 1.98.1 MSVC. cargo test --locked --workspace --no-fail-fast -- --test-threads=4 --nocapture reported 870 passed, 0 failed, and 42 ignored. The log also reported 3 feature or adapter skips (gpu, gpu, heap_window_out_of_memory_falls_back_to_the_switch_form).
  • Synthetic results on 59e9f3f85fd8292bd7bb4517a52a586489bea8bc, five alternating pairs per workload. Enabled versus disabled was 2.19× median (2.02–2.34×) for 64 KiB zlib and 1.020× (0.978–1.058×) for 1 MiB uncompressed. Disabled versus its tested main measured 1.006× (0.980–1.062×) and 0.995× (0.944–1.038×), respectively.
  • The earlier instrumented prototype measured 2.09× (1.81–2.34×) for 64 KiB zlib, with four concurrent decodes and zero budget waits. The 1 MiB uncompressed control was 1.01× (0.88–1.26×). The earlier slowdown did not reproduce in that replay.

Regression run

Pending on the current head. Please run independent scripts/smoke.ps1 90-second tests on one retail title with three clean builds or configurations.

  1. Main c160d86ef2efe3a07e4dfb473e4fa72eafb413c0, pool off.
  2. Exact PR head 1495e6df204a0836a7a4515fd16437cbe9ed7000, pool off.
  3. The same exact PR head with XCL_DSTORAGE_PARALLEL_DECOMPRESS=1, four workers and a 32 MiB staging budget.

Use the same adapter, console profile, offline/no-input conditions and equivalent initial caches across runs. Leave XCL_DIRECT_DXIL unset to use upstream's default. Keep host memory safeguards active and attach the official smoke blocks for the three cases.

Historical retail run on main 9e3831e1f570d3646e53ab753b19ec07eb8f1485 and candidate 59e9f3f85fd8292bd7bb4517a52a586489bea8bc. All three completed 90 seconds with zero crashes and zero device removals on Series X with a fresh 512 MiB coherent UMA window, RTX 4060 Laptop GPU, and DXC 1.8.2502.11.

Historical case Frames Peak commit
Main 1,578 15,859 MiB
Candidate, disabled 1,382 17,220 MiB
Candidate, enabled 1,478 16,863 MiB

Both historical candidate runs passed local acceptance. The disabled run's 12.4% frame deficit widened late as it processed more streaming requests than main. The cause remains unresolved after one ABC sequence.

Not tested

Retail execution and performance on the current head, exact simultaneous retail decoder job count, retail staging waits, and validation on AMD.

AI use

OpenAI Codex (GPT-6, exact serving variant unavailable) implemented the earlier rebase and tests, verified the unchanged patch on the new base, built and tested the current candidate, verified the historical evidence, and drafted this description.

@ZekkJJ
ZekkJJ marked this pull request as ready for review November 24, 2026 06:02
@ryosen0

ryosen0 commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Windows cross-check of 7f1ecc4 (RTX 3060 Ti 8 GB, Ryzen 7 9800X3D, driver 32.0.16.1742, Windows 11, release build) — the Regression run gap, on the retail title this repo smokes:

Head, default (pool off):

xcl-smoke v1
commit: 7f1ecc4fe3a642f8eeb9c3da367c3ee729d5c8de
gpu: NVIDIA GeForce RTX 3060 Ti
title: ScarlettGame
seconds: 90
exit: 0x0
frames shown: 2423 (PresentX 2423)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14472 MB

Head, XCL_DSTORAGE_PARALLEL_DECOMPRESS=1 (pool on, defaults: 4 workers / 32 MiB):

xcl-smoke v1
commit: 7f1ecc4fe3a642f8eeb9c3da367c3ee729d5c8de
gpu: NVIDIA GeForce RTX 3060 Ti
title: ScarlettGame
seconds: 90
exit: 0x0
frames shown: 2451 (PresentX 2451)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14472 MB

The title's boot traffic is exactly the eligible shape (file source, zlib, virtual 64 KiB destinations — thousands of requests in the first seconds), both runs clean, frame counts within noise, peak commit identical. So the opt-in path survives a real retail boot on a second host.

Tests on this head: cargo test --release -p xcl --lib hle::dstorage -- --test-threads=1 → 23 passed / 0 failed; ... --lib parallel -- --test-threads=1 → 10 passed / 0 failed (the dedicated pool contract tests).

Two honest limits: (1) this 90 s window ends before the title's BCPack phase, so it says nothing about the refusal path interactions; (2) pipeline_metrics() has no runtime consumer in this diff, so I could not verify from the log how many decodes actually ran in parallel on the retail workload — the synthetic benchmark carries that claim, not this run. A one-line periodic log of the pool metrics under the existing activity line would close that gap cheaply, if you want it in this PR or a follow-up.

The main-side pair for Regression run still needs a block from current main (beaa245) per the checks; the head blocks above are yours to paste.

AI use: GPT-6.2 Astra (API model selector) in DSH built the head, ran both smokes and the tests, and drafted this comment; the human contributor reviewed the numbers before posting.

@mastrr9

mastrr9 commented Nov 24, 2026

Copy link
Copy Markdown

Clean-room build, audit, and native hardware test run on NVIDIA RTX 5080 (Windows 11 Pro 25H2 26200.9974, driver 617.42 / 32.0.16.1742, rustc 1.100.0, DXC Windows SDK 10.0.26100.0).

  • Commit tested: 7f1ecc4fe3a642f8eeb9c3da367c3ee729d5c8de
  • Build (cargo build --workspace): clean (only the pre-existing fetch_update deprecation warning).
  • Tests (cargo test --workspace -- --test-threads=4): 714 passed; 0 failed; 41 ignored (SKIPPED: only the 2 hardware no wave64 tests).
  • PR-specific tests: All 10 new hle::dstorage::parallel_tests::* tests passed cleanly (budget_retires_ready_error_and_payload_without_worker_notification, cancellation_of_started_or_prepared_work_keeps_existing_results, failed_worker_task_reports_error_and_preserves_the_next_result, parallel_decode_reports_corruption_and_zero_pads_the_next_request, parallel_out_of_order_completion_retires_fifo, queue_close_waits_for_started_preparation, request_larger_than_staging_budget_uses_sequential_fallback, staging_stays_charged_until_the_other_queue_finishes_retirement, submitted_batch_retires_without_notifications_or_followup_submits, tight_budget_makes_progress_after_immediate_file_failure).
  • Audit: Clean — retirement stays strictly FIFO and drains before non-eligible entries, status entries, and fences; worker panics are caught with E_ABORT fallback; staging budget accounting is RAII-paired via Reservation::drop with close wakeups under the mutex; oversized requests fall back to the sequential path; opt-in via XCL_DSTORAGE_PARALLEL_DECOMPRESS.

(Clean-room hardware check only; no retail title or smoke.ps1 run. Assisted-by: Antigravity / Claude Sonnet 5.5 + Gemini 4 Neon)

@MesshM

MesshM commented Nov 24, 2026

Copy link
Copy Markdown

Test run of 7f1ecc4fe3a642f8eeb9c3da367c3ee729d5c8de on AMD RDNA4. I merged it onto current main beaa245 locally (clean merge) and tested that tree.

Tested

  • AMD Radeon RX 9060 XT 16 GB (RDNA4, VRS supported), driver 32.0.32029.2010; Ryzen 7 5700X, 64 GB RAM, Windows 11 Pro build 26200, Rust 1.100.0 stable-x86_64-pc-windows-msvc, debug
  • cargo build --workspace + cargo test --workspace -- --test-threads=4 on the merge: 723 passed, 0 failed, 41 ignored, exit code 0; xcl lib tests 682 passed; 0 SKIPPED.

Review: Opt-in (XCL_DSTORAGE_PARALLEL_DECOMPRESS=1); with it unset nothing changes, and the suite passes that way. At 1399 lines I reviewed the structure only; the parallel path itself was exercised only by its own tests.

Not tested: no retail title or regression run (I have no unpacked game), release build.

Run and review by Claude Code (Claude Opus 5.5) on this machine.

@iggyvilla

Copy link
Copy Markdown
Contributor

Review of 7f1ecc4, read only (nothing built or run by me).

The copy into the title's buffer in retire_one can fault the process. retire_one checks writable(task.req.destination, n) (hle/dstorage.rs:1641) and then does a plain copy_nonoverlapping into the destination (:1647). start checks writable too (:1527), but that check runs before the file read and the inflate, and the copy comes after both, behind FIFO retirement. If the title decommits the destination in that time, the copy is an access violation in the XCL process, where the old path would return E_ACCESS_VIOLATION for the request. That is the window #705 closes in execute by writing with write_own (NtWriteVirtualMemory) instead of a direct copy. The sequential execute path on main still has the same direct copy (:1333), so this PR does not add a new kind of fault, but it adds a second site with a much longer window, and #705's test (a SOURCE_MEMORY_BIT request) does not reach this path, which the parallel path excludes (:1690).

Whichever of the two lands second should send the retirement copy through write_own (and treat a false return as E_ACCESS_VIOLATION). A test with a file-backed request whose destination is decommitted while the worker decodes would cover it. #819 and #705 also conflict textually in dstorage.rs, so this will have to be resolved in the rebase anyway.

Smaller: set_profiling_enabled, set_retirement_profiling_enabled, take_retirement_timings, timing_breakdown, reset_timing_breakdown and pipeline_metrics are never called from the PR tree, so the Instant::now() branches that depend on them never run, and XCL_DSTORAGE_MEASURE is not in the README. Removing them (or wiring the metrics into the existing activity log line, as the Windows cross-check above suggests) would also take the diff nearer the size guide.

AI use: read with Claude Code, Claude Sonnet 5.5, checked against the PR head and main; the findings are mine and I checked each line reference.

@SlopTart

Copy link
Copy Markdown

Linux / AMD RDNA3 datapoint.

Merged state: head 7f1ecc4 onto main 1ec4c98, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 718 passed, 7 failed, 41 ignored. Failures = the known Wine-lane set from my #42 rows - zero flakes in this lane. parallel DirectStorage decode tests green (718 passed, zero flakes).

Not tested: retail titles (none here), Windows, RDNA4.
Counts only, no game data.

Machine: RX 7900 XT (RADV NAVI31), Mesa 26.2.5, kernel 7.2 (Arch), Proton Experimental (wine-11.0), patched vkd3d-proton v3.1, Rust cross x86_64-pc-windows-gnu, XCL_NETWORK=0, release profile, --test-threads=4. My Linux rows: #42 / #718.

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

@Creaa

Creaa commented Nov 24, 2026 •

Copy link
Copy Markdown

RTX 4070 startup performance

Tested on an RTX 4070 (617.14), Core i7-13700F, Windows build 26300, and Rust 1.100.0. Built the exact base and PR revisions using cargo build --locked --release -p xcl. Ran scripts/smoke.ps1 -Game <game-folder> -Seconds 45 -Xcl <release-exe> offline against the same title (package RockstarGamesInc.28872443D20A7), with a fresh XCL title-data directory for each run. A baseline warm-up preceded the measured runs. The PR trials ran in off/on/on/off order, with XCL_DSTORAGE_PARALLEL_DECOMPRESS set to 0 or 1.

Build First PresentX (s) DirectStorage requests in first two activity samples (~4 s) Frames shown in 45 s
Base e50836b 2.895 4,836 349
PR 7f1ecc4, off 2.927 / 2.892 5,012 / 5,102 266 / 322
PR 7f1ecc4, on 2.413 / 2.355 8,186 / 8,218 335 / 332

The flag brought the first PresentX forward by 0.51-0.54 s across two pairs. All measured runs exited normally with zero crashes and zero device removals. PresentX timestamps measure presentation calls. Intro visibility, menu, gameplay, and the automated suite were not checked in this run.

Regression run

Base

xcl-smoke v1
commit: e50836bdf6f5c026f281d545ed86fb2f07ba6e6a
gpu: NVIDIA GeForce RTX 4070
seconds: 45
exit: 0x0
frames shown: 349 (PresentX 349)
presents per 2 s (last 3): 24 23 21
device removals: 0
crashes: 0
peak commit: 15916 MB

PR, flag off

xcl-smoke v1
commit: 7f1ecc4fe3a642f8eeb9c3da367c3ee729d5c8de
gpu: NVIDIA GeForce RTX 4070
seconds: 45
exit: 0x0
frames shown: 266 (PresentX 266)
presents per 2 s (last 3): 17 17 17
device removals: 0
crashes: 0
peak commit: 15949 MB

PR, flag on

xcl-smoke v1
commit: 7f1ecc4fe3a642f8eeb9c3da367c3ee729d5c8de
gpu: NVIDIA GeForce RTX 4070
seconds: 45
exit: 0x0
frames shown: 335 (PresentX 335)
presents per 2 s (last 3): 21 20 20
device removals: 0
crashes: 0
peak commit: 15898 MB

AI use

Codex (GPT-6) built both revisions, ran the smoke trials, extracted the metrics, and drafted this report.

Keep the worker pool opt-in and bound its staging allocations. Retire submitted work in queue order, including batches without a status marker and preparation failures under budget pressure.
@ZekkJJ
ZekkJJ marked this pull request as draft November 24, 2026 18:50
@ZekkJJ
ZekkJJ force-pushed the codex/dstorage-parallel-decompression branch from 7f1ecc4 to 1495e6d Compare November 24, 2026 18:50
@ZekkJJ
ZekkJJ marked this pull request as ready for review November 24, 2026 18:55
@gbuyssens

Copy link
Copy Markdown
Contributor

Test report for 1495e6d (on top of main c160d86), as asked.

Tested

  • RTX 3060 (driver 32.0.16.2101), i5-9600K, 32 GB, Windows 11 Pro 26300, Rust 1.98.0 MSVC.

  • cargo test --workspace --no-fail-fast -- --test-threads=4 (debug):

    • PR 1495e6d: 870 passed, 0 failed, 42 ignored
    • main c160d86: 858 passed, 0 failed, 42 ignored
    • SKIPPED on both: gpu_geometry_wave32_prefix_count_over_a_mask (no wave64), gpu_wave32_program_in_wave64_hardware (no wave64), heap_window_out_of_memory_falls_back_to_the_switch_form (no heap windows)
  • scripts/smoke.ps1 -Seconds 90, retail title (RockstarGamesInc package, zlib file requests of 64 KiB), release builds, 11 runs back to back on an idle machine, interleaved, after one warm-up run of main:

    run frames peak commit DirectStorage requests in 90 s time to the first load's last request (9766)
    main 1 1727 23437 MB 58670 18 s
    main 2 2117 23374 MB 54373 18 s
    main 3 2375 16392 MB 22877 16 s
    PR, pool off 1 2373 14717 MB 10556 16 s
    PR, pool off 2 2246 14599 MB 9766 52 s (slow start, first PresentX at 9.1 s)
    PR, pool off 3 2175 14518 MB 9766 86 s (slow start, first PresentX at 9.3 s)
    PR, pool on 1 2181 17913 MB 31341 44 s (slow start, first PresentX at 9.2 s)
    PR, pool on 2 2385 16373 MB 22864 16 s
    PR, pool on 3 1783 25814 MB 77190 16 s
    PR, pool on 4 2361 14608 MB 9766 18 s

    0 crashes and 0 device removals in every run.

What this shows

  • This title has two start-up modes in every build: a fast one (first PresentX at about 4 s, first load done at 16–18 s) and a slow one (first PresentX at about 9 s, first load done after 44–86 s). It also sometimes sits at a stable screen after request 9766 for the rest of the run. That happened on main (the warm-up run), with the pool off and with the pool on. Frames and peak commit follow how far the title got in 90 s (the runs at 23–26 GB went furthest), not the build.
  • In the fast mode the first load finishes at 16–18 s with the pool on, with it off and on main. On this title I see no measurable speedup and no regression from the pool. The furthest-progressed run (77190 requests) was a pool run, but one run is not a trend.
  • In my earlier runs on 7f1ecc4 I suspected the pool of making the title stall more often. These runs show the same stall with the pool off and on main, so I withdraw that.

The default-path block, for the regression check (main 1 and PR pool off 1, back to back):

main:

xcl-smoke v1
commit: c160d86ef2efe3a07e4dfb473e4fa72eafb413c0
gpu: NVIDIA GeForce RTX 3060
title: MyDump
seconds: 90
exit: 0x0
frames shown: 1727 (PresentX 1727)
presents per 2 s (last 3): 0 0 0
device removals: 0
crashes: 0
peak commit: 23437 MB

PR:

xcl-smoke v1
commit: 1495e6df204a0836a7a4515fd16437cbe9ed7000
gpu: NVIDIA GeForce RTX 3060
title: MyDump
seconds: 90
exit: 0x0
frames shown: 2373 (PresentX 2373)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14717 MB

Review of the changes since 7f1ecc4

  • The retire_one fault from iggyvilla's review is fixed: the copy now goes through write_destination (NtWriteVirtualMemory on the current process, parallel.rs:484), so a destination decommitted after the check returns a status instead of faulting.
  • Entry::Refused and the refused-cancel handling from main are kept (dstorage.rs:1140, 1414).
  • The unused profiling and metrics code is gone, and the pool is in its own parallel.rs.
  • The diff is still 1271 lines (+528 in parallel.rs, +647 in tests), over the ~800 at which CONTRIBUTING asks for a reason not to split.

Not tested

  • The pool's synthetic throughput benchmark, AMD / Intel, cold disk cache (all runs had the package in the file cache), and titles with larger requests than 64 KiB.

AI use

  • Claude Code (Claude Opus 5.5) ran the builds, test suites and smoke runs, read the diff, and drafted this report.

@raylitebull
raylitebull merged commit b9b6ea6 into xcl-dev:main Nov 24, 2026
1 of 4 checks passed
bmjask added a commit to bmjask/xcl that referenced this pull request Nov 24, 2026
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
wondercrash added a commit to wondercrash/xcl that referenced this pull request Nov 24, 2026
…xcl-dev#819)

Conflicts:
- real.rs driver-compile gate: upstream's XCL_HUGE_PSO_BYTES / _CONCURRENCY,
  Slots::most() and GIANT lane (4 MiB) taken; integ's HUGE lane is the same
  4 MiB lane (big_compile_lane now names compile_slots' lanes).
  BIG_DRIVER_COMPILE -> huge_pso_bytes() (also in warm).
  Compute PSO: integ's lane / slotless / pso_async hooks kept, then the
  driver call through driver_compile_identified (gated by its caller) for
  upstream's log lines and driver-only time; the cold retry gated as upstream.
  Graphics: integ's dxil_known, then upstream's gated driver_compile.
  pso_async::build_is_wanted is no longer test-only (upstream's gates use it).
  The two tests that take both real lanes hold BOTH_LANES (opposite orders).
- shaders.rs: runtime_windows() with integ's --used; both sides' helpers and
  tests kept.
- pso.rs: compute_shape and console_hlsl both kept.
- README: both sides' lines kept.

Assisted-by: omp (Claude Opus 5.5)
@Gevroska

Copy link
Copy Markdown

I confirmed that GTA VI uses the parallel DirectStorage decode pool during world loading on Windows with an RTX 3080. I ran the same locally instrumented release (1d027e5c plus diagnostic counters) for 850 seconds twice, first with the pool off, then with it on.

With the pool enabled, the counters continued to rise after I pressed Confirm. By the last counter update, 49,578 requests had matched the pool criteria, 49,576 had been admitted, and all 49,576 admitted requests had decoded and retired successfully. Both runs passed the first-run form and still showed a black screen at the final capture, about 838 seconds after launch. Neither reached a controllable scene or reported a GPU removal.

Across all DirectStorage paths, I counted 1 failure in 87,923 requests with the pool off and 1,871 in 87,816 with it on. All three sampled warnings carried 0x89240009, which several request checks can return. Those totals don’t identify the failing stage. With one run per setting and a shared driver cache, I can confirm pool activity but can’t attribute the failure difference or a performance effect to the pool.

I used Codex with GPT-6.2 Sol (high) to adapt the counters and run the tests. A separate GPT-6.2 Sol agent independently checked the saved counters and captures. GPT-6.1 Terra (medium) checked for overlap with existing upstream reports.

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.

10 participants