HLE: fail DirectStorage startup when no worker can start #3205

Open
yumaste wants to merge 2 commits from upstream-pr/3207 into main
yumaste commented 2026-11-26 12:46:15 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-26T12:46:15Z.


Problem

If every DirectStorage worker thread fails to start, the scheduler is still published. Queue creation then succeeds, but there is no worker to run submitted requests. Reads remain pending and a caller waiting for completion or queue capacity can hang.

Change

Publish the scheduler only after at least one worker starts. If none start, queue creation and staging configuration report E_OUTOFMEMORY. A partial worker pool still services queues. The process still attempts initialization once. The title stops at startup when staging setup fails, as noted at the call site. It now sees the error there instead of hanging while waiting for I/O.

Validation

  • Simulated zero successful spawns and one successful spawn after an initial failure. Removing the zero-worker guard makes the regression fail.
  • cargo test --locked -p victory-hle -- --test-threads=1: 153 unit tests and 2 integration tests passed on Windows.
  • cargo clippy --locked -p victory-hle --all-targets --all-features -- -D warnings and cargo xtask policy passed.

Coordination claim. Synthetic test data only. AI-assisted (Codex).

<!-- greyfinch-sync:Marvisak/VIctory:issue:5510273505 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3207). Originally posted by [yumaste](https://github.com/yumaste) on 2026-11-26T12:46:15Z. --- ## Problem If every DirectStorage worker thread fails to start, the scheduler is still published. Queue creation then succeeds, but there is no worker to run submitted requests. Reads remain pending and a caller waiting for completion or queue capacity can hang. ## Change Publish the scheduler only after at least one worker starts. If none start, queue creation and staging configuration report `E_OUTOFMEMORY`. A partial worker pool still services queues. The process still attempts initialization once. The title stops at startup when staging setup fails, as noted at the call site. It now sees the error there instead of hanging while waiting for I/O. ## Validation - Simulated zero successful spawns and one successful spawn after an initial failure. Removing the zero-worker guard makes the regression fail. - `cargo test --locked -p victory-hle -- --test-threads=1`: 153 unit tests and 2 integration tests passed on Windows. - `cargo clippy --locked -p victory-hle --all-targets --all-features -- -D warnings` and `cargo xtask policy` passed. [Coordination claim](https://github.com/Marvisak/VIctory/issues/1633#issuecomment-7192393034). Synthetic test data only. AI-assisted (Codex).
cloph-dsp commented 2026-11-26 13:04:37 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T13:03:35Z.


Independent local verification of head 7088627 on Windows 11, Rust 1.100.0/MSVC:

  • cargo test --locked -p victory-hle --lib -- modules::dstorage::tests::a_scheduler_requires_at_least_one_worker --exact — 1 passed, 0 failed.
  • git diff --check origin/main HEAD — clean.

Used a worktree-local CARGO_TARGET_DIR. The scheduler test uses synthetic spawn closures; no D3D12 device or game assets were used. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only).

<!-- greyfinch-sync:Marvisak/VIctory:comment:7192817811 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3207#issuecomment-7192817811). Originally posted by [cloph-dsp](https://github.com/cloph-dsp) on 2026-11-26T13:03:35Z. --- Independent local verification of head `7088627` on Windows 11, Rust 1.100.0/MSVC: - `cargo test --locked -p victory-hle --lib -- modules::dstorage::tests::a_scheduler_requires_at_least_one_worker --exact` — 1 passed, 0 failed. - `git diff --check origin/main HEAD` — clean. Used a worktree-local `CARGO_TARGET_DIR`. The scheduler test uses synthetic spawn closures; no D3D12 device or game assets were used. AI-assisted (Hy4 flash). GPU/driver: N/A (CPU-only).
AurumCarlos commented 2026-11-26 13:05:55 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by AurumCarlos on 2026-11-26T13:05:55Z.

Review: COMMENTED


Looks good to me. The doc comment on scheduler() already promised "None if not even one worker could start", and on main the code never did that: the scheduler was published before STARTED ran, whatever the spawn count. This makes the code match the comment. I checked it against main:

  • Callers: create_queue already maps None to E_OUTOFMEMORY, so with no workers a title now fails at queue creation instead of hanging on its first read. close_lane, queue and submit all need a queue that already exists, so they can't hit None in practice.
  • Spawning inside get_or_init: the workers start while the OnceLock is still initialising. That's safe because work → execute never calls scheduler(), so no worker can block on the cell it's being started from. On main this was guaranteed by the separate Once; now it relies on that call graph, so a short comment on start ("workers must not call scheduler()") would keep it from breaking quietly later.
  • Arc instead of &'static: needed now that the workers start before the scheduler is in the static. The failure path drops it cleanly, and a partial pool keeps its own clones. 👍
  • set_staging_buffer_size: returning E_OUTOFMEMORY there means Grand Theft Auto VI stops at startup (per the comment above it) instead of hanging later. A clear failure is better here. It might be worth one line in the PR description that this is the visible effect for that title.

The test exercises start with injected spawns, which covers the decision itself. The E_OUTOFMEMORY paths stay untested because scheduler() is a process-wide OnceLock, which is fair.

<!-- greyfinch-sync:Marvisak/VIctory:review:6074631174 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3207#pullrequestreview-6074631174). Originally posted by [AurumCarlos](https://github.com/AurumCarlos) on 2026-11-26T13:05:55Z. **Review:** COMMENTED --- Looks good to me. The doc comment on `scheduler()` already promised "`None` if not even one worker could start", and on `main` the code never did that: the scheduler was published before `STARTED` ran, whatever the spawn count. This makes the code match the comment. I checked it against `main`: - **Callers**: `create_queue` already maps `None` to `E_OUTOFMEMORY`, so with no workers a title now fails at queue creation instead of hanging on its first read. `close_lane`, `queue` and `submit` all need a queue that already exists, so they can't hit `None` in practice. - **Spawning inside `get_or_init`**: the workers start while the `OnceLock` is still initialising. That's safe because `work` → `execute` never calls `scheduler()`, so no worker can block on the cell it's being started from. On `main` this was guaranteed by the separate `Once`; now it relies on that call graph, so a short comment on `start` ("workers must not call `scheduler()`") would keep it from breaking quietly later. - **`Arc` instead of `&'static`**: needed now that the workers start before the scheduler is in the static. The failure path drops it cleanly, and a partial pool keeps its own clones. 👍 - **`set_staging_buffer_size`**: returning `E_OUTOFMEMORY` there means Grand Theft Auto VI stops at startup (per the comment above it) instead of hanging later. A clear failure is better here. It might be worth one line in the PR description that this is the visible effect for that title. The test exercises `start` with injected spawns, which covers the decision itself. The `E_OUTOFMEMORY` paths stay untested because `scheduler()` is a process-wide `OnceLock`, which is fair.
yumaste commented 2026-11-26 14:01:49 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by yumaste on 2026-11-26T13:12:56Z.


Thanks. 09dadaf documents why workers receive the scheduler directly and must not call scheduler() while the OnceLock is initializing. I also added the startup behavior to the PR description. The synthetic scheduler test still passes.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7193031358 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3207#issuecomment-7193031358). Originally posted by [yumaste](https://github.com/yumaste) on 2026-11-26T13:12:56Z. --- Thanks. `09dadaf` documents why workers receive the scheduler directly and must not call `scheduler()` while the `OnceLock` is initializing. I also added the startup behavior to the PR description. The synthetic scheduler test still passes.
futurepro62 commented 2026-11-27 22:41:11 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by futurepro62 on 2026-11-27T22:41:11Z.


NVIDIA full-suite run, to go with the reports above by cloph-dsp, since none of them names a GPU run. Tested exact head 09dadaf (on its base 63bcca4).

Tested

  • NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), dxil.dll from Windows SDK 10.0.26100 (the loader's default), debug.
  • cargo build --workspace --locked, then cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware: 867 passed, 0 failed, 10 ignored.
  • The new tests ran and passed: a_scheduler_requires_at_least_one_worker.
  • --skip leaves out tests that fail on main 63bcca4 on this card too, not because of this PR: heap_direct_texture_reads_mark_their_heap_index ends the victory-shader test process with 0xc0000005 (#2571), so without the skip the rest of that crate never reports; dynamic_slots_are_held_until_released, lists_share_a_table_and_copies_keep_their_views and the two stride_tests hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); gathers_at_a_level_match_the_hardware fails on lane 0 (#1744).

Not tested

  • AMD (the tests take the default adapter), a release build, the title (test run only).

AI use

  • Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
<!-- greyfinch-sync:Marvisak/VIctory:comment:7229533085 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/3207#issuecomment-7229533085). Originally posted by [futurepro62](https://github.com/futurepro62) on 2026-11-27T22:41:11Z. --- NVIDIA full-suite run, to go with the reports above by cloph-dsp, since none of them names a GPU run. Tested exact head `09dadaf` (on its base `63bcca4`). **Tested** - NVIDIA GeForce RTX 5070 Ti 16 GB (Blackwell, 32-lane waves only, mesh shaders), driver 621.40, Ryzen 7 9800X3D, Windows 11 Home 26300, Rust 1.98.1 MSVC (pinned), `dxil.dll` from Windows SDK 10.0.26100 (the loader's default), debug. - `cargo build --workspace --locked`, then `cargo test --workspace --locked --no-fail-fast -- --test-threads=4 --skip emit::memory_tests::heap_direct_texture_reads_mark_their_heap_index --skip descriptor::host::tests::dynamic_slots_are_held_until_released --skip memory::tests::lists_share_a_table_and_copies_keep_their_views --skip emit::stride_tests::a_heap_buffer_read_by_element_takes_the_views_stride --skip emit::stride_tests::a_heap_buffer_read_where_no_buffer_view_is_reads_zeros --skip emit::synthetic_tests::gathers_at_a_level_match_the_hardware`: **867 passed, 0 failed, 10 ignored**. - The new tests ran and passed: `a_scheduler_requires_at_least_one_worker`. - `--skip` leaves out tests that fail on main `63bcca4` on this card too, not because of this PR: `heap_direct_texture_reads_mark_their_heap_index` ends the `victory-shader` test process with `0xc0000005` (#2571), so without the skip the rest of that crate never reports; `dynamic_slots_are_held_until_released`, `lists_share_a_table_and_copies_keep_their_views` and the two `stride_tests` hit the 1,000,000-view heap cap of NVIDIA drivers (#1835, #2317); `gathers_at_a_level_match_the_hardware` fails on lane 0 (#1744). **Not tested** - AMD (the tests take the default adapter), a release build, the title (test run only). **AI use** - Claude Code (Claude Opus 5.5) ran the tests and wrote this report. I checked it before posting.
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/3207:upstream-pr/3207'
git switch 'upstream-pr/3207'

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/3207'
git switch 'upstream-pr/3207'
git rebase 'main'
git switch 'main'
git merge --ff-only 'upstream-pr/3207'
git switch 'upstream-pr/3207'
git rebase 'main'
git switch 'main'
git merge --no-ff 'upstream-pr/3207'
git switch 'main'
git merge --squash 'upstream-pr/3207'
git switch 'main'
git merge --ff-only 'upstream-pr/3207'
git switch 'main'
git merge 'upstream-pr/3207'
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
Marvisak/VIctory!3205
No description provided.