DirectStorage: read a page list naming page 0 again before failing its request #1725

Merged
npanu420 merged 1 commit from upstream-pr/1726 into main 2026-11-25 00:18:17 +00:00
npanu420 commented 2026-11-24 21:24:23 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by npanu420 on 2026-11-24T21:24:23Z.


What

A DirectStorage request into physical pages (PAGE_DESTINATION) whose page list names page 0 is read again for up to 8 ms before the request fails.

Why

The title writes a request's page list after enqueueing it, and queue() submits a queue on its own once half of it is enqueued. A worker can then start the read before the list is filled: it names page 0, which is no page (numbers start at 0x10_0000), xmem::write_physical returns false and the request fails with E_INVALIDARG. Nothing logs it, and the title never reads a request's result (it only polls for completion), so the model or texture is silently left unwritten.

Two measurements on the same machine (RTX 3070, Windows 11, Series X profile, a world load into the first story pack):

Build Failed page-destination requests
without the re-read 883 in one run, in bursts of up to 687 in a single second
copying the list at enqueue instead (rejected) 15,264, and the load never finished: the lists are still empty at enqueue
with this change 0. One list was written late and recovered

These were taken on a branch of fxceless/victory-gta6, whose into_destination is the same code as main here apart from a warning line. This PR is the change rebuilt on main (ffe310e).

Changes

  • into_destination: if write_physical fails and the list holds a 0, the title's list is read again every 1 ms, 8 times. Recovered writes are counted and logged at powers of two (written late). A request that still fails now logs a warning instead of failing silently.
  • Test a_page_list_filled_after_its_request_starts: the list is filled 2 ms after the request is submitted, and the data must arrive. It fails without the change (checked with the retries set to 0) and passes with it, repeatedly.

Verification

cargo test -p victory-hle --lib dstorage              # 14 passed
cargo clippy -p victory-hle --all-targets --locked -- -D warnings
cargo xtask policy

rustfmt --check reports 9 differences in dstorage.rs, all already on main. This change adds none.

No game data is used or committed. AI-assisted (Claude Code).

🤖 Generated with Claude Code

<!-- greyfinch-sync:Marvisak/VIctory:issue:6591711491 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1726). Originally posted by [npanu420](https://github.com/npanu420) on 2026-11-24T21:24:23Z. --- ## What A DirectStorage request into physical pages (`PAGE_DESTINATION`) whose page list names page 0 is read again for up to 8 ms before the request fails. ## Why The title writes a request's page list **after** enqueueing it, and `queue()` submits a queue on its own once half of it is enqueued. A worker can then start the read before the list is filled: it names page 0, which is no page (numbers start at `0x10_0000`), `xmem::write_physical` returns false and the request fails with `E_INVALIDARG`. Nothing logs it, and the title never reads a request's result (it only polls for completion), so the model or texture is silently left unwritten. Two measurements on the same machine (RTX 3070, Windows 11, Series X profile, a world load into the first story pack): | Build | Failed page-destination requests | |---|---| | without the re-read | 883 in one run, in bursts of up to 687 in a single second | | copying the list at enqueue instead (rejected) | 15,264, and the load never finished: the lists are still empty at enqueue | | with this change | **0**. One list was written late and recovered | These were taken on a branch of `fxceless/victory-gta6`, whose `into_destination` is the same code as `main` here apart from a warning line. This PR is the change rebuilt on `main` (ffe310e). ## Changes - `into_destination`: if `write_physical` fails and the list holds a 0, the title's list is read again every 1 ms, 8 times. Recovered writes are counted and logged at powers of two (`written late`). A request that still fails now logs a warning instead of failing silently. - Test `a_page_list_filled_after_its_request_starts`: the list is filled 2 ms after the request is submitted, and the data must arrive. It **fails without the change** (checked with the retries set to 0) and passes with it, repeatedly. ## Verification ```powershell cargo test -p victory-hle --lib dstorage # 14 passed cargo clippy -p victory-hle --all-targets --locked -- -D warnings cargo xtask policy ``` `rustfmt --check` reports 9 differences in `dstorage.rs`, all already on `main`. This change adds none. No game data is used or committed. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
catminou4 commented 2026-11-24 22:02:06 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by catminou4 on 2026-11-24T21:36:43Z.

Review: COMMENTED


Static review only: this crate is Windows-only (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; source review of the diff.

DirectStorage page-list race: page 0 means 'not filled yet' (page numbers start at 0x10_0000); instead of failing the request immediately, the read retries for a few ms (LATE_LIST_TRIES × 1ms sleep), re-reads the title's list, and writes late with a power-of-two-throttled info log. Bounded retry, no unbounded wait. The 'title never looks at a request's result' justification is the kind of assumption worth a comment in the code — it is here. Windows-only.

<!-- greyfinch-sync:Marvisak/VIctory:review:6047808070 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1726#pullrequestreview-6047808070). Originally posted by [catminou4](https://github.com/catminou4) on 2026-11-24T21:36:43Z. **Review:** COMMENTED --- Static review only: this crate is Windows-only (D3D12/windows_sys/Win32) — nothing compiles or runs on macOS; source review of the diff. DirectStorage page-list race: page 0 means 'not filled yet' (page numbers start at 0x10_0000); instead of failing the request immediately, the read retries for a few ms (LATE_LIST_TRIES × 1ms sleep), re-reads the title's list, and writes late with a power-of-two-throttled info log. Bounded retry, no unbounded wait. The 'title never looks at a request's result' justification is the kind of assumption worth a comment in the code — it is here. Windows-only.
acetonahard-code commented 2026-11-24 23:05:46 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by acetonahard-code on 2026-11-24T22:08:35Z.


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

cargo test -p victory-hle passed failed ignored
main 99 0 0
main + this PR 100 0 0
  • The new test passes.
  • cargo clippy --all-targets -- -D warnings, with and without --all-features: clean.

I didn't test with game data.


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

<!-- greyfinch-sync:Marvisak/VIctory:comment:7145858629 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1726#issuecomment-7145858629). Originally posted by [acetonahard-code](https://github.com/acetonahard-code) on 2026-11-24T22:08:35Z. --- Tested on Windows 11 with the repo toolchain, merged into current `main` (70564ae): | `cargo test -p victory-hle` | passed | failed | ignored | |---|---|---|---| | `main` | 99 | 0 | 0 | | `main` + this PR | 100 | 0 | 0 | - The new test passes. - `cargo clippy --all-targets -- -D warnings`, with and without `--all-features`: clean. I didn't test with game data. --- <sub>Tested locally with an AI-assisted script (Claude Code); I checked the results before posting.</sub>
kais7654 commented 2026-11-24 23:06:02 +00:00 (Migrated from github.com)

Imported from Marvisak/VIctory. Originally posted by kais7654 on 2026-11-24T22:50:21Z.


Reviewed and verified: the late-fill test passes and all 14 dstorage
tests stay green on Windows — a list naming page 0 written while the
request runs is caught and applied once the title fills it. One note:
each late request sleeps on its worker thread for up to 8 ms before
failing; fine at these rates, worth revisiting if a frame ever waits
on a batch of them.

<!-- greyfinch-sync:Marvisak/VIctory:comment:7146703980 --> Imported from [Marvisak/VIctory](https://github.com/Marvisak/VIctory/pull/1726#issuecomment-7146703980). Originally posted by [kais7654](https://github.com/kais7654) on 2026-11-24T22:50:21Z. --- Reviewed and verified: the late-fill test passes and all 14 dstorage tests stay green on Windows — a list naming page 0 written while the request runs is caught and applied once the title fills it. One note: each late request sleeps on its worker thread for up to 8 ms before failing; fine at these rates, worth revisiting if a frame ever waits on a batch of them.
upstream-sync closed this pull request 2026-11-25 01:07:06 +00:00
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!1725
No description provided.