DirectStorage: keep raw reads running while staging drains #1457

Open
github-bot wants to merge 1 commit from github-bot/gh-1457 into main AGit
Owner

@⁠Luizbc2 on GitHub · 2026-11-24 18:09 UTC · original
Luizbc2:fix/directstorage-raw-reads-while-staging-drains → main · +55 −13 · 1 files · 1 commits · open

Summary

If the scheduler picks a read that cannot fit in the remaining staging space, it currently stops dispatching reads from every queue. A raw read at the front of a different queue needs zero staging bytes and can run while the buffered work drains.

Allow that read to run. Keep the existing weighted queue order among eligible reads and continue reserving staging space for the blocked request. Smaller buffered requests therefore cannot indefinitely postpone a larger one.

Reproduction and testing

cargo test --workspace --lib --locked --offline modules::dstorage::tests

The new synthetic test sets a 100-byte staging limit, holds 60 bytes in flight, and queues a blocked 120-byte read, a raw read, and a small buffered read in different queues. On ffe310e the scheduler returns no work. With the patch it starts the raw read, waits for staging to drain, then starts the 120-byte read. All 14 DirectStorage tests passed on Windows.

AI-assisted with Codex.

**@⁠Luizbc2** on GitHub · 2026-11-24 18:09 UTC · [original](https://github.com/Marvisak/VIctory/pull/1457) `Luizbc2:fix/directstorage-raw-reads-while-staging-drains` → `main` · +55 −13 · 1 files · 1 commits · open ## Summary If the scheduler picks a read that cannot fit in the remaining staging space, it currently stops dispatching reads from every queue. A raw read at the front of a different queue needs zero staging bytes and can run while the buffered work drains. Allow that read to run. Keep the existing weighted queue order among eligible reads and continue reserving staging space for the blocked request. Smaller buffered requests therefore cannot indefinitely postpone a larger one. ## Reproduction and testing `cargo test --workspace --lib --locked --offline modules::dstorage::tests` The new synthetic test sets a 100-byte staging limit, holds 60 bytes in flight, and queues a blocked 120-byte read, a raw read, and a small buffered read in different queues. On `ffe310e` the scheduler returns no work. With the patch it starts the raw read, waits for staging to drain, then starts the 120-byte read. All 14 DirectStorage tests passed on Windows. AI-assisted with Codex.
Allow reads at the front of other queues to run if they require no staging.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 04:32:38 +00:00
Author
Owner

@⁠acetonahard-code on GitHub · 2026-11-24 21:05 UTC · original

Heads-up: #1187 (opened about two hours earlier) changes the same scheduler block in dstorage.rs. A read that needs no staging keeps going when the next read can't fit the staging space. The two conflict, so only one can land as-is.

Tested on Windows 11 with the repo toolchain, merged into current main (ffe310e):

cargo test -p victory-hle passed failed ignored
main 95 0 0
main + this PR 96 0 0
  • The new test passes.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.
  • Minor: cargo fmt --check would rewrap one block this PR adds (dstorage.rs). main isn't rustfmt-clean either, so take it or leave it.

I didn't test with game data.


Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.

**@⁠acetonahard-code** on GitHub · 2026-11-24 21:05 UTC · [original](https://github.com/Marvisak/VIctory/pull/1457#issuecomment-7144473338) Heads-up: #1187 (opened about two hours earlier) changes the same scheduler block in `dstorage.rs`. A read that needs no staging keeps going when the next read can't fit the staging space. The two conflict, so only one can land as-is. Tested on Windows 11 with the repo toolchain, merged into current `main` (ffe310e): | `cargo test -p victory-hle` | passed | failed | ignored | |---|---|---|---| | `main` | 95 | 0 | 0 | | `main` + this PR | 96 | 0 | 0 | - The new test passes. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. - Minor: `cargo fmt --check` would rewrap one block this PR adds (`dstorage.rs`). `main` isn't rustfmt-clean either, so take it or leave it. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
Author
Owner

@⁠Marvisak on GitHub · 2026-11-25 03:28 UTC · original

Automated triage for the maintainers.

Merge candidate. Lanes::start in crates/victory-hle/src/modules/dstorage.rs now starts a queue's raw (zero-staging) read when the next read in order must wait for staging space. It still holds staging back for the blocked request, so smaller buffered reads cannot overtake it. The candidate tuple (class clock, class, lane clock, seq, id) gives the same order as main's two-step choice, and the new test covers the blocked/raw/drain sequence. The overlapping #1187 is closed. One small point: a raw read from another class sets now from that class's clock, which can later step back; #1187 used max for this, which may be worth doing here too. CI has not run on this head; a tester reports the HLE tests and clippy pass.


Generated by Claude Code

**@⁠Marvisak** on GitHub · 2026-11-25 03:28 UTC · [original](https://github.com/Marvisak/VIctory/pull/1457#issuecomment-7151943431) <!-- victory-triage v1 head=ff3b10e753a30714c581af7614d30f6f7dd5cf67 verdict=merge-candidate at=2026-11-25T03:30:00Z --> Automated triage for the maintainers. **Merge candidate.** `Lanes::start` in `crates/victory-hle/src/modules/dstorage.rs` now starts a queue's raw (zero-staging) read when the next read in order must wait for staging space. It still holds staging back for the blocked request, so smaller buffered reads cannot overtake it. The candidate tuple (class clock, class, lane clock, seq, id) gives the same order as `main`'s two-step choice, and the new test covers the blocked/raw/drain sequence. The overlapping #1187 is closed. One small point: a raw read from another class sets `now` from that class's clock, which can later step back; #1187 used `max` for this, which may be worth doing here too. CI has not run on this head; a tester reports the HLE tests and clippy pass. --- _Generated by [Claude Code](https://claude.ai/code)_
Author
Owner

@⁠fuzeofficlal on GitHub · 2026-11-26 00:51 UTC · original

Code review (concurrency & ordering audit) and Windows 11 verification at head ff3b10e753a3 merged cleanly onto main (63bcca43c6a0):

  • Concurrency & ordering audit (crates/victory-hle/src/modules/dstorage.rs:513-557):
    • When the highest-priority head request needs staging (selected.5 != 0) and self.staged > 0 && self.staged + selected.5 > self.staging, falling back to next_read(true) still inspects only each queue's lane.reads.front(). Raw reads in the same queue never overtake a blocked staged read ahead of them, so Lane::flush seq ordering and error propagation stay intact.
    • self.starved = true is set before the raw fallback (line 536), so when the in-flight staged read completes, work() (std::mem::take(&mut lanes.starved)) wakes waiting workers via notify_all() with no lost-wakeup or deadlock window.
    • Anti-starvation is preserved: raw bypass only occurs while self.staged > 0 (so oversized single requests still launch once staged == 0), and blocked staged queues do not advance their virtual clock.
  • Verified (Windows 11, Rust 1.98.1):
    • cargo xtask policy: 191 files ok; cargo clippy --locked -p victory-hle --tests -- -D warnings: 0 warnings
    • cargo test --locked -p victory-hle -- dstorage: 17/17 passed (including raw_reads_from_other_queues_can_run_while_staging_drains).

LGTM.

**@⁠fuzeofficlal** on GitHub · 2026-11-26 00:51 UTC · [original](https://github.com/Marvisak/VIctory/pull/1457#issuecomment-7179191630) Code review (concurrency & ordering audit) and Windows 11 verification at head `ff3b10e753a3` merged cleanly onto `main` (`63bcca43c6a0`): - **Concurrency & ordering audit (`crates/victory-hle/src/modules/dstorage.rs:513-557`)**: - When the highest-priority head request needs staging (`selected.5 != 0`) and `self.staged > 0 && self.staged + selected.5 > self.staging`, falling back to `next_read(true)` still inspects only each queue's `lane.reads.front()`. Raw reads in the same queue never overtake a blocked staged read ahead of them, so `Lane::flush` `seq` ordering and error propagation stay intact. - `self.starved = true` is set before the raw fallback (line 536), so when the in-flight staged read completes, `work()` (`std::mem::take(&mut lanes.starved)`) wakes waiting workers via `notify_all()` with no lost-wakeup or deadlock window. - Anti-starvation is preserved: raw bypass only occurs while `self.staged > 0` (so oversized single requests still launch once `staged == 0`), and blocked staged queues do not advance their virtual clock. - **Verified (Windows 11, Rust 1.98.1)**: - `cargo xtask policy`: `191 files ok`; `cargo clippy --locked -p victory-hle --tests -- -D warnings`: 0 warnings - `cargo test --locked -p victory-hle -- dstorage`: **17/17 passed** (including `raw_reads_from_other_queues_can_run_while_staging_drains`). LGTM.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/1457/head:github-bot/gh-1457'
git switch 'github-bot/gh-1457'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-1457'
git switch 'github-bot/gh-1457'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-1457'
git switch 'github-bot/gh-1457'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-1457'
git switch 'main'
git merge --squash 'github-bot/gh-1457'
git switch 'main'
git merge --ff-only 'github-bot/gh-1457'
git switch 'main'
git merge 'github-bot/gh-1457'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No reviewers
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.

Dependencies

No dependencies set

Reference
github/Marvisak--VIctory!1457
No description provided.