DirectStorage: XCL_DSTORAGE_IO_CONCURRENCY caps concurrent disk reads for HDDs #902

Open
auswhalen999-debug wants to merge 2 commits from upstream-pr/908 into main
auswhalen999-debug commented 2026-11-24 08:02:55 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by auswhalen999-debug on 2026-11-24T08:02:55Z.


Console titles can drive 16+ concurrent DirectStorage file queues at once. On mechanical HDDs, issuing that many simultaneous seek_read calls thrashes the read heads and stalls asset streaming.

This adds an opt-in XCL_DSTORAGE_IO_CONCURRENCY=N setting (e.g. 2 for mechanical HDDs, clamped to 1..=64). When unset or 0 (the default), disk reads remain uncapped so SSD/NVMe users see no behavior change. The semaphore gates only read_exact_at disk reads while keeping CPU zlib decompression and destination copies parallel across all queues.

What is in it

  • crates/xcl/src/hle/dstorage.rs: add parse_io_concurrency, IoLimiter / RAII IoPermit (Mutex<usize> + Condvar initialized once via OnceLock), and gate read_exact_at disk reads (with an early return for empty reads and checked_add offset check).
  • crates/xcl/src/hle/dstorage.rs (mod tests): add unit tests covering env-var parsing/clamping, bounded concurrency (limits 1 and 2) with unwind-safe permit release, and the uncapped default when unset.
  • README.md: document XCL_DSTORAGE_IO_CONCURRENCY.

Tested

  • Windows, AMD Ryzen 5 3500X, NVIDIA GeForce GTX 1070 (driver 32.0.15.8180), Rust 1.100.0 (0ef1bc386 2026-11-09), debug build:
  • cargo test -p xcl --lib dstorage: 16 passed, 0 failed, 0 ignored (0 warnings in crates/xcl/src/hle/dstorage.rs).
  • Earlier local boot test on a 5400 RPM Toshiba HDD showed ~20 s faster boot streaming with XCL_DSTORAGE_IO_CONCURRENCY=2 compared to uncapped concurrent queue reads.

Regression run
Pending: paired scripts/smoke.ps1 runs on clean builds of main and commit dc2143cc2614 are not yet attached.

Not tested

  • Full cargo test --workspace run and paired scripts/smoke.ps1 runs on this commit (dc2143cc2614).
  • Non-Windows / Wine environments.

AI use

  • Antigravity (Gemini 3.1 Pro): extracted the change onto a clean branch from origin/main, added the unit tests and README note, ran cargo test -p xcl --lib dstorage, and drafted the PR description.
<!-- greyfinch-sync:ivall/xcl:issue:5468366875 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/908). Originally posted by [auswhalen999-debug](https://github.com/auswhalen999-debug) on 2026-11-24T08:02:55Z. --- Console titles can drive 16+ concurrent DirectStorage file queues at once. On mechanical HDDs, issuing that many simultaneous `seek_read` calls thrashes the read heads and stalls asset streaming. This adds an opt-in `XCL_DSTORAGE_IO_CONCURRENCY=N` setting (e.g. `2` for mechanical HDDs, clamped to `1..=64`). When unset or `0` (the default), disk reads remain uncapped so SSD/NVMe users see no behavior change. The semaphore gates only `read_exact_at` disk reads while keeping CPU zlib decompression and destination copies parallel across all queues. **What is in it** - `crates/xcl/src/hle/dstorage.rs`: add `parse_io_concurrency`, `IoLimiter` / RAII `IoPermit` (`Mutex<usize>` + `Condvar` initialized once via `OnceLock`), and gate `read_exact_at` disk reads (with an early return for empty reads and `checked_add` offset check). - `crates/xcl/src/hle/dstorage.rs` (`mod tests`): add unit tests covering env-var parsing/clamping, bounded concurrency (limits 1 and 2) with unwind-safe permit release, and the uncapped default when unset. - `README.md`: document `XCL_DSTORAGE_IO_CONCURRENCY`. **Tested** - Windows, AMD Ryzen 5 3500X, NVIDIA GeForce GTX 1070 (driver 32.0.15.8180), Rust 1.100.0 (0ef1bc386 2026-11-09), debug build: - `cargo test -p xcl --lib dstorage`: 16 passed, 0 failed, 0 ignored (0 warnings in `crates/xcl/src/hle/dstorage.rs`). - Earlier local boot test on a 5400 RPM Toshiba HDD showed ~20 s faster boot streaming with `XCL_DSTORAGE_IO_CONCURRENCY=2` compared to uncapped concurrent queue reads. **Regression run** Pending: paired `scripts/smoke.ps1` runs on clean builds of `main` and commit `dc2143cc2614` are not yet attached. **Not tested** - Full `cargo test --workspace` run and paired `scripts/smoke.ps1` runs on this commit (`dc2143cc2614`). - Non-Windows / Wine environments. **AI use** - Antigravity (Gemini 3.1 Pro): extracted the change onto a clean branch from `origin/main`, added the unit tests and README note, ran `cargo test -p xcl --lib dstorage`, and drafted the PR description.
eizispark commented 2026-11-24 09:07:03 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by eizispark on 2026-11-24T08:16:56Z.


Hardware check of dc2143cc2614ce6f6e84dc6f14b6220b8956c5b3 (verified clean merge with main 09940bb): pass.

Tested

  • Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, rustc 1.100.0 (0ef1bc386 2026-11-09), release + test profile
  • cargo test --workspace -- --test-threads=4: 715 passed, 3 failed, 41 ignored (GPU tests skipped on this adapter: none); placed_title_textures_share_vram_and_preserve_pixels flaked under 4-thread shared-singleton contention (poisoning transitions_apply_when_their_list_is_submitted and d32s8_targets_take_their_own_size_of_video_memory), and cargo test -p xcl --lib hle::d3d12x -- --test-threads=1 passed (114 passed, 0 failed, 1 ignored)
  • hle::dstorage::tests (16 passed, 0 failed), including io_concurrency_parsing_defaults_to_uncapped_and_clamps_positive_values, io_limiter_caps_concurrent_holders_and_releases_on_drop, and io_limiter_is_uncapped_when_env_unset

Regression run
main (beaa245):

xcl-smoke v1
commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1660 (PresentX 1660)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14862 MB

PR (dc2143c):

xcl-smoke v1
commit: dc2143cc2614ce6f6e84dc6f14b6220b8956c5b3
gpu: AMD Radeon RX 9070 XT
title: GTA6.Xbox.v1.0.2.1
seconds: 60
exit: 0x0
frames shown: 1660 (PresentX 1661)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14863 MB

Not tested

  • wave32-only GPUs (NVIDIA / Intel); mechanical HDD streaming with XCL_DSTORAGE_IO_CONCURRENCY=2 (smoke ran on SSD with default unset concurrency); gameplay past the menus

AI use

  • Antigravity (Gemini 4 Carbon) ran the build, test suite, and scripts/smoke.ps1 harness on this machine and formatted this report.
<!-- greyfinch-sync:ivall/xcl:comment:7125944673 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/908#issuecomment-7125944673). Originally posted by [eizispark](https://github.com/eizispark) on 2026-11-24T08:16:56Z. --- Hardware check of `dc2143cc2614ce6f6e84dc6f14b6220b8956c5b3` (verified clean merge with `main` `09940bb`): **pass**. **Tested** - Hardware: AMD Radeon RX 9070 XT (RDNA4, driver 32.0.32015.16001), AMD Ryzen 7 9800X3D, 32 GB RAM, Windows 11, `rustc 1.100.0 (0ef1bc386 2026-11-09)`, release + test profile - `cargo test --workspace -- --test-threads=4`: `715 passed, 3 failed, 41 ignored` (GPU tests skipped on this adapter: `none`); `placed_title_textures_share_vram_and_preserve_pixels` flaked under 4-thread shared-singleton contention (poisoning `transitions_apply_when_their_list_is_submitted` and `d32s8_targets_take_their_own_size_of_video_memory`), and `cargo test -p xcl --lib hle::d3d12x -- --test-threads=1` passed (`114 passed, 0 failed, 1 ignored`) - `hle::dstorage::tests` (`16 passed, 0 failed`), including `io_concurrency_parsing_defaults_to_uncapped_and_clamps_positive_values`, `io_limiter_caps_concurrent_holders_and_releases_on_drop`, and `io_limiter_is_uncapped_when_env_unset` **Regression run** `main` (`beaa245`): ``` xcl-smoke v1 commit: beaa245ca04e212f064efc7cafcdce104bc5c0a2 gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1660 (PresentX 1660) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14862 MB ``` PR (`dc2143c`): ``` xcl-smoke v1 commit: dc2143cc2614ce6f6e84dc6f14b6220b8956c5b3 gpu: AMD Radeon RX 9070 XT title: GTA6.Xbox.v1.0.2.1 seconds: 60 exit: 0x0 frames shown: 1660 (PresentX 1661) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14863 MB ``` **Not tested** - wave32-only GPUs (NVIDIA / Intel); mechanical HDD streaming with `XCL_DSTORAGE_IO_CONCURRENCY=2` (smoke ran on SSD with default unset concurrency); gameplay past the menus **AI use** - Antigravity (Gemini 4 Carbon) ran the build, test suite, and `scripts/smoke.ps1` harness on this machine and formatted this report.
dcastell1 commented 2026-11-24 09:07:05 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by dcastell1 on 2026-11-24T08:27:37Z.


Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on clean main@beaa245 (713 passed, 0 failed, 41 ignored on this box):

patch -p1 < this PR            # clean, no fuzz
cargo test --workspace -- --test-threads=4
716 passed; 0 failed; 41 ignored   (exit 0)

Three more passing tests than main: the DirectStorage IO-concurrency cap is covered and green here; nothing else changes verdict.

Tree restored afterwards (md5 and a full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.

<!-- greyfinch-sync:ivall/xcl:comment:7126160737 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/908#issuecomment-7126160737). Originally posted by [dcastell1](https://github.com/dcastell1) on 2026-11-24T08:27:37Z. --- Verified on Windows 11 10.0.26300, NVIDIA GeForce RTX 5090 (driver 621.24), Rust 1.100.0 MSVC 14.44.35207, debug build, on clean `main@beaa245` (713 passed, 0 failed, 41 ignored on this box): ``` patch -p1 < this PR # clean, no fuzz cargo test --workspace -- --test-threads=4 716 passed; 0 failed; 41 ignored (exit 0) ``` Three more passing tests than main: the DirectStorage IO-concurrency cap is covered and green here; nothing else changes verdict. Tree restored afterwards (md5 and a full diff against a clean checkout), hardware adapter, no Wine, no game data. AI-assisted (opencode): applied the patch to a built tree, ran the suite, reverted it.
SlopTart commented 2026-11-24 10:04:47 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by SlopTart on 2026-11-24T09:34:38Z.


Linux / AMD RDNA3 datapoint.

Merged state: head dc2143c onto main 09940bb, clean merge.

Full suite, cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4: 712 passed, 7 failed, 41 ignored; failures are the known Wine-lane set from my #42 rows. DirectStorage IO-concurrency cap green.

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.

<!-- greyfinch-sync:ivall/xcl:comment:7127604624 --> Imported from [ivall/xcl](https://github.com/ivall/xcl/pull/908#issuecomment-7127604624). Originally posted by [SlopTart](https://github.com/SlopTart) on 2026-11-24T09:34:38Z. --- Linux / AMD RDNA3 datapoint. **Merged state:** head `dc2143c` onto main `09940bb`, clean merge. **Full suite, `cargo test --workspace --release --no-fail-fast --target x86_64-pc-windows-gnu -- --test-threads=4`:** **712 passed, 7 failed, 41 ignored**; failures are the known Wine-lane set from my #42 rows. DirectStorage IO-concurrency cap green. **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.
Toons29 commented 2026-11-25 04:10:15 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Toons29 on 2026-11-25T03:09:06Z.


Regression run of 85c92109 on the retail title, for this PR's Regression run section. Both blocks are from scripts/smoke.ps1 as printed, not edited: main on 4178e888, this PR on its head commit with no uncommitted changes, same title and time.

xcl-smoke v1
commit: 4178e888c0b5be50a2887eda45cdb832763b68a4
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1618 (PresentX 1618)
presents per 2 s (last 3): 61 60 60
device removals: 0
crashes: 0
peak commit: 14831 MB
xcl-smoke v1
commit: 85c92109e467431029954641ebc20f269237e921
gpu: AMD Radeon RX 9070
title: game.exe
seconds: 60
exit: 0x0
frames shown: 1633 (PresentX 1633)
presents per 2 s (last 3): 60 60 60
device removals: 0
crashes: 0
peak commit: 14686 MB

Against the limits in CONTRIBUTING.md: 101 % of main's frames, 99 % of its peak commit, no crash, no device removal.

AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, cargo build --release -p xcl, 60 s, XCL_NETWORK=0. This is a regression check only: it does not show whether the run reaches the code this PR changes.

AI use: Claude Code (Claude Opus 5.5) built both trees and ran scripts/smoke.ps1; I checked the blocks before posting.

<!-- greyfinch-sync:ivall/xcl:comment:7151639720 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/908#issuecomment-7151639720). Originally posted by [Toons29](https://github.com/Toons29) on 2026-11-25T03:09:06Z. --- Regression run of `85c92109` on the retail title, for this PR's **Regression run** section. Both blocks are from `scripts/smoke.ps1` as printed, not edited: `main` on `4178e888`, this PR on its head commit with no uncommitted changes, same title and time. ``` xcl-smoke v1 commit: 4178e888c0b5be50a2887eda45cdb832763b68a4 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1618 (PresentX 1618) presents per 2 s (last 3): 61 60 60 device removals: 0 crashes: 0 peak commit: 14831 MB ``` ``` xcl-smoke v1 commit: 85c92109e467431029954641ebc20f269237e921 gpu: AMD Radeon RX 9070 title: game.exe seconds: 60 exit: 0x0 frames shown: 1633 (PresentX 1633) presents per 2 s (last 3): 60 60 60 device removals: 0 crashes: 0 peak commit: 14686 MB ``` Against the limits in CONTRIBUTING.md: 101 % of `main`'s frames, 99 % of its peak commit, no crash, no device removal. AMD Radeon RX 9070 (RDNA4, driver 32.0.32029.2010), Ryzen 7 7800X3D, 32 GB, Windows 11 build 26300, Rust 1.100.0, `cargo build --release -p xcl`, 60 s, `XCL_NETWORK=0`. This is a regression check only: it does not show whether the run reaches the code this PR changes. AI use: Claude Code (Claude Opus 5.5) built both trees and ran `scripts/smoke.ps1`; I checked the blocks before posting.
DavidM1911 commented 2026-11-25 10:10:32 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by DavidM1911 on 2026-11-25T09:31:11Z.


Verification on RTX 3060 Ti (Windows 11): merge conflict with current main (README.md, crates/xcl/src/hle/dstorage.rs) — needs a rebase before it can be tested.

<!-- greyfinch-sync:ivall/xcl:comment:7158439953 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/908#issuecomment-7158439953). Originally posted by [DavidM1911](https://github.com/DavidM1911) on 2026-11-25T09:31:11Z. --- Verification on RTX 3060 Ti (Windows 11): **merge conflict with current `main`** (`README.md`, `crates/xcl/src/hle/dstorage.rs`) — needs a rebase before it can be tested.
Foniass commented 2026-12-01 04:28:44 +00:00 (Migrated from github.com)

Imported from ivall/xcl. Originally posted by Foniass on 2026-12-01T04:28:44Z.


Triage (#1607) – head 85c9210

No open or merged PR caps DirectStorage disk reads. read_exact_at on main has no limiter.
Problem: the merge commit 85c9210 resolved the README conflict by deleting the existing XCL_DRED=1 bullet (the three lines about DRED breadcrumbs). The PR's diff against main removes them, so they need to be restored next to the new XCL_DSTORAGE_IO_CONCURRENCY bullet.
Recommendation: keep open.

AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.

<!-- greyfinch-sync:ivall/xcl:comment:7300774788 --> Imported from [ivall/xcl](https://github.com/xcl-dev/xcl/pull/908#issuecomment-7300774788). Originally posted by [Foniass](https://github.com/Foniass) on 2026-12-01T04:28:44Z. --- **Triage (#1607)** – head 85c9210 No open or merged PR caps DirectStorage disk reads. `read_exact_at` on main has no limiter. Problem: the merge commit 85c9210 resolved the README conflict by deleting the existing `XCL_DRED=1` bullet (the three lines about DRED breadcrumbs). The PR's diff against main removes them, so they need to be restored next to the new `XCL_DSTORAGE_IO_CONCURRENCY` bullet. Recommendation: keep open. AI review: Claude Code (Claude Opus 5.5), diffs read only, not built or run; not checked by a human.
This pull request cannot be merged automatically due to conflicts.
Merge manually to resolve the conflicts.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin 'upstream-pr/908:upstream-pr/908'
git switch 'upstream-pr/908'

Merge

Merge the changes and update on Forgejo.

Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.

git switch 'main'
git merge --no-ff 'upstream-pr/908'
git switch 'upstream-pr/908'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/908'
git switch 'upstream-pr/908'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/908'
git switch 'main'
git merge --squash 'upstream-pr/908'
git switch 'main'
git merge --ff-only 'upstream-pr/908'
git switch 'main'
git merge 'upstream-pr/908'
git push origin 'main'
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!902
No description provided.