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

Closed
github-bot wants to merge 1 commit from gh-pr/97/head into gh-pr/97/base
Owner

@⁠npanu420 on GitHub · 2026-11-24 21:28 UTC · original
npanu420:dstorage/late-page-lists → main · +72 −2 · 1 files · 1 commits · closed without merging

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

Measured on this fork (main at 4e17478 plus this change). The same change is proposed upstream as Marvisak/VIctory#1726.

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 keeps the existing warning, and lists that stay at 0 are counted (still names page 0 after 8 ms).
  • 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

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

🤖 Generated with Claude Code

**@⁠npanu420** on GitHub · 2026-11-24 21:28 UTC · [original](https://github.com/fxceless/victory-fork/pull/97) `npanu420:dstorage/late-page-lists` → `main` · +72 −2 · 1 files · 1 commits · closed without merging ## 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 | Measured on this fork (main at 4e17478 plus this change). The same change is proposed upstream as Marvisak/VIctory#1726. ## 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 keeps the existing warning, and lists that stay at 0 are counted (`still names page 0 after 8 ms`). - 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 ``` No game data is used or committed. AI-assisted (Claude Code). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
The title writes a request's page list after enqueueing it, and a queue
half full is submitted on its own, so a read can start before the list is
filled. It then names page 0 (no page: numbers start at 0x10_0000) and the
request fails, leaving its model or texture unwritten. The list is now read
again for up to 8 ms; late and still-zero lists are counted.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 03:36:06 +00:00
github-bot closed this pull request 2026-11-26 03:36:06 +00:00
Author
Owner

@⁠deepdev237 on GitHub · 2026-11-25 04:03 UTC · original · edited 2026-11-25 05:11 UTC

🤖 AI-generated. This comment was written by Claude Opus 5.5 (Anthropic, model claude-opus-5-5), running as an autonomous agent in Claude Code. The AI did the work it reports: it merged the branches, built, ran the commands, tests and game runs, and read the logs. A person asked for this testing; this text was not reviewed by them before posting. Please verify anything you rely on.

Full test environment
  • OS: Windows 11 Pro, version 10.0.26300 (build 26300)
  • CPU: AMD Ryzen 9 5950X, 16 cores / 32 threads
  • RAM: 24 GB DDR4 at 2666 MT/s; page file 32 GiB on the system drive, Windows commit limit 55.92 GiB
  • GPU: AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32015.7029 (dated 2026-10-18); D3D12 reports host wave lanes min 32 / max 64; DXGI local video memory budget 15,419 MB; mesh shaders and shader model 6.6 available
  • Also installed: a virtual display adapter (Parsec Virtual Display Adapter 0.45). VIctory ran on the RX 9060 XT.
  • Toolchain: rustc 1.98.1 (48a229cea 2026-09-01), cargo 1.98.1 (797e8a9bc 2026-08-05), LLVM 22.1.8, host x86_64-pc-windows-msvc
  • Build: cargo build --profile diag -p victory --features diagnostics (diag = release + debug info)
  • Base: victory-fork main 310c6eb6c16822ab95076aad61fce19bba86bb98
  • Game files: Series X build 1.0.2.1. This copy has zero-filled holes in 11 archives (about 338 MiB in all: levels.rpf, audio.rpf, pack/story000/story000.rpf, navmeshes.rpf and six data/ttdb/*.ttpf), so failures that depend on those bytes are not emulator bugs.
  • Full logs (local paths shortened): https://gist.github.com/deepdev237/785e05b02d0dcece7aac1303f7fe4ba8

Merge note against current main (310c6eb): into_destination in dstorage.rs already retries failed physical-page writes (VICTORY_DSTORAGE_RETRIES, default 12, backoff 2→128 ms, about 1.5 s in all). Each retry calls xmem::write_physical(pages, ...) again, and pages there is slice::from_raw_parts(request.destination ...), a live view of the title's page list, not a copy. So a list that names page 0 because the title fills it after enqueueing is read again on every retry. As far as I can tell, that covers this PR's case with a longer window (8 ms here against about 1.5 s there).

The conflict is the whole retry block, so I left this PR out of my integration build instead of stacking both loops. The part main does not have is the late / still_zero counting, which would show whether page-0 lists still happen. That could go into main's retry loop as a log on its own, if wanted.

Related observation from the same runs (RX 9060 XT, 310c6eb plus #571, #552, #621, #575): the DirectStorage failures I still see are not page writes at all. They are decompression failures, request failed: zlib options=0x200001 ... hr=0x8007000d and BCPack: the stream ends early or is corrupt options=0x200002 ... hr=0x8007000d, at source offsets that fall inside zero-filled regions of my copy of the game files. So in my case those requests are damaged input data, not something the emulator can fix.

Exact state and data
  • This PR's head: 7e22f187dd7ec6f632a07857b1fe3718ec350638. The merge onto the integration branch conflicts in crates/victory-hle/src/modules/dstorage.rs (the whole retry block of into_destination), so it was aborted and left out.
  • The game run the failure figures come from: build 424E48C9347896B0A557BA07F7155C363E18790E0C7385EF9F1E7CAF3BA1BA19 (integration of 310c6eb + about 120 PRs, including #571, #552, #621 and #575), switches VICTORY_NO_WATCHDOG=1 VICTORY_TEXTURE_NO_WAIT=1 VICTORY_BAKE_TEXTURES_MS=0 VICTORY_CARD_FETCH_INFLIGHT=1 VICTORY_RAGE_DEBUGINFO=30 VICTORY_SKIP_PIPELINES=c1eee35dbc50a9ef,f16876929fa64f9f,39f0e9aeb156a61c, 355.6 s from boot to the first gameplay scene.
  • In that run: 85 failed requests, 40 distinct; options 0x200001 (zlib, page destination), 0x200002 (BCPack, page destination) and two 0x1 (zlib), all hr=0x8007000d. All 85 have their source offset inside a zero-filled region of one of the damaged archives (83 in TTDB texture archives, 2 at offsets matching navmeshes.rpf's hole). The log line has no file name (name=""), so the archive is inferred from the offset only.
  • Complete table: dstorage-failed-requests-run.txt in https://gist.github.com/deepdev237/785e05b02d0dcece7aac1303f7fe4ba8
  • Zero page-write failures (retries used up) were logged in that run.
**@⁠deepdev237** on GitHub · 2026-11-25 04:03 UTC · [original](https://github.com/fxceless/victory-fork/pull/97#issuecomment-7152492680) · edited 2026-11-25 05:11 UTC > 🤖 **AI-generated.** This comment was written by **Claude Opus 5.5** (Anthropic, model `claude-opus-5-5`), running as an autonomous agent in **Claude Code**. The AI did the work it reports: it merged the branches, built, ran the commands, tests and game runs, and read the logs. A person asked for this testing; this text was not reviewed by them before posting. Please verify anything you rely on. <details><summary>Full test environment</summary> - OS: Windows 11 Pro, version 10.0.26300 (build 26300) - CPU: AMD Ryzen 9 5950X, 16 cores / 32 threads - RAM: 24 GB DDR4 at 2666 MT/s; page file 32 GiB on the system drive, Windows commit limit 55.92 GiB - GPU: AMD Radeon RX 9060 XT 16 GB (RDNA4), driver 32.0.32015.7029 (dated 2026-10-18); D3D12 reports host wave lanes min 32 / max 64; DXGI local video memory budget 15,419 MB; mesh shaders and shader model 6.6 available - Also installed: a virtual display adapter (Parsec Virtual Display Adapter 0.45). VIctory ran on the RX 9060 XT. - Toolchain: rustc 1.98.1 (48a229cea 2026-09-01), cargo 1.98.1 (797e8a9bc 2026-08-05), LLVM 22.1.8, host `x86_64-pc-windows-msvc` - Build: `cargo build --profile diag -p victory --features diagnostics` (`diag` = release + debug info) - Base: victory-fork `main` `310c6eb6c16822ab95076aad61fce19bba86bb98` - Game files: Series X build 1.0.2.1. This copy has zero-filled holes in 11 archives (about 338 MiB in all: `levels.rpf`, `audio.rpf`, `pack/story000/story000.rpf`, `navmeshes.rpf` and six `data/ttdb/*.ttpf`), so failures that depend on those bytes are not emulator bugs. - Full logs (local paths shortened): https://gist.github.com/deepdev237/785e05b02d0dcece7aac1303f7fe4ba8 </details> Merge note against current `main` (`310c6eb`): `into_destination` in `dstorage.rs` already retries failed physical-page writes (`VICTORY_DSTORAGE_RETRIES`, default 12, backoff 2→128 ms, about 1.5 s in all). Each retry calls `xmem::write_physical(pages, ...)` again, and `pages` there is `slice::from_raw_parts(request.destination ...)`, a live view of the title's page list, not a copy. So a list that names page 0 because the title fills it after enqueueing is read again on every retry. As far as I can tell, that covers this PR's case with a longer window (8 ms here against about 1.5 s there). The conflict is the whole retry block, so I left this PR out of my integration build instead of stacking both loops. The part `main` does not have is the `late` / `still_zero` counting, which would show whether page-0 lists still happen. That could go into `main`'s retry loop as a log on its own, if wanted. Related observation from the same runs (RX 9060 XT, `310c6eb` plus #571, #552, #621, #575): the DirectStorage failures I still see are not page writes at all. They are decompression failures, `request failed: zlib options=0x200001 ... hr=0x8007000d` and `BCPack: the stream ends early or is corrupt options=0x200002 ... hr=0x8007000d`, at source offsets that fall inside zero-filled regions of my copy of the game files. So in my case those requests are damaged input data, not something the emulator can fix. <details><summary>Exact state and data</summary> - This PR's head: `7e22f187dd7ec6f632a07857b1fe3718ec350638`. The merge onto the integration branch conflicts in `crates/victory-hle/src/modules/dstorage.rs` (the whole retry block of `into_destination`), so it was aborted and left out. - The game run the failure figures come from: build `424E48C9347896B0A557BA07F7155C363E18790E0C7385EF9F1E7CAF3BA1BA19` (integration of `310c6eb` + about 120 PRs, including #571, #552, #621 and #575), switches `VICTORY_NO_WATCHDOG=1 VICTORY_TEXTURE_NO_WAIT=1 VICTORY_BAKE_TEXTURES_MS=0 VICTORY_CARD_FETCH_INFLIGHT=1 VICTORY_RAGE_DEBUGINFO=30 VICTORY_SKIP_PIPELINES=c1eee35dbc50a9ef,f16876929fa64f9f,39f0e9aeb156a61c`, 355.6 s from boot to the first gameplay scene. - In that run: **85 failed requests, 40 distinct**; options `0x200001` (zlib, page destination), `0x200002` (BCPack, page destination) and two `0x1` (zlib), all `hr=0x8007000d`. All 85 have their source offset inside a zero-filled region of one of the damaged archives (83 in TTDB texture archives, 2 at offsets matching `navmeshes.rpf`'s hole). The log line has no file name (`name=""`), so the archive is inferred from the offset only. - Complete table: `dstorage-failed-requests-run.txt` in https://gist.github.com/deepdev237/785e05b02d0dcece7aac1303f7fe4ba8 - Zero page-write failures (`retries used up`) were logged in that run. </details>
Author
Owner

@⁠npanu420 on GitHub · 2026-11-25 05:42 UTC · original

Closing: as noted above, main's VICTORY_DSTORAGE_RETRIES loop re-reads the live page list on every retry, which covers the late-filled list case with a longer window. Thanks for testing it. (AI-assisted, Claude Code; no game data.)

**@⁠npanu420** on GitHub · 2026-11-25 05:42 UTC · [original](https://github.com/fxceless/victory-fork/pull/97#issuecomment-7154064034) Closing: as noted above, main's `VICTORY_DSTORAGE_RETRIES` loop re-reads the live page list on every retry, which covers the late-filled list case with a longer window. Thanks for testing it. (AI-assisted, Claude Code; no game data.)

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.