Skip to content

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

Closed
npanu420 wants to merge 1 commit into
fxceless:mainfrom
npanu420:dstorage/late-page-lists
Closed

npanu420 wants to merge 1 commit into
fxceless:mainfrom
npanu420:dstorage/late-page-lists

Conversation

@npanu420

Copy link
Copy Markdown

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

…s request

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 <noreply@anthropic.com>
@deepdev237

deepdev237 commented Nov 25, 2026 •

Copy link
Copy Markdown

🤖 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

@npanu420

Copy link
Copy Markdown
Author

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 npanu420 closed this Nov 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants