DirectStorage: a destination page number the title has not written yet is read again, not failed at once #854

Closed
PiloteCode wants to merge 7 commits from upstream-pr/855 into main
PiloteCode commented 2026-11-25 10:47:55 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by PiloteCode on 2026-11-25T10:47:55Z.


Based on 9376fd6. It changes one file of victory-hle (modules/dstorage.rs) and adds a README line.

What was wrong

A request to a destination of physical pages carries an array of page numbers, one per 64 KiB. The title may fill that array after it has enqueued the request. A queue also submits on its own once it is half full, so a worker can take the request before the numbers are there. Until now, an unknown page number failed the request at once. The title never reads a request's result (it only polls for completion), so the model or texture kept whatever its pages held.

Measured at the opening's loading on an RTX 5090: 302 requests of one burst failed this way in one run, and 44 and 9 in two other runs.

What changes (into_destination)

  • The page numbers are read as the title has them now, with volatile reads each time, instead of once as a slice.
  • If one is not known after the data is decoded, the numbers are read again for up to 250 ms (15 yields, then 1 ms sleeps) until every page is known.
  • The retries that were already there (VICTORY_DSTORAGE_RETRIES, 12 tries, about 0.9 s) read the numbers again before each try.
  • Consecutive pages of one allocation, the usual case, still go through one view as before.
  • Logging. Requests that had to wait are counted in the lanes' periodic line (destination_waits). The first wait that ends with every number known is logged once, with the tries and microseconds it took. When a request still fails, one warning now says why: a page number is unknown, or the host could not map the pages. It also gives the first page number, the tries, and the totals given up and recovered on a retry. This one warning replaces two.

Measured

RTX 5090, the opening's loading and the first minutes after it:

  • With the change, no request failed. In one run, a number was known 17 µs after the worker first read it.
  • Before, 302, 44 and 9 requests failed in three runs.

Switches

  • VICTORY_DSTORAGE_RETRIES=0: as before, no retry of the write. The wait for page numbers has no switch of its own: it only runs where the request would otherwise fail.

Tested

RTX 5090, Intel i9-14900KF, Windows 11. The branch was checked as it is, on 9376fd6:

  • cargo test -p victory-hle: 98 + 1 passed, none failed.
  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean. The first commit fixes the three lints that make CI fail on 9376fd6; the shader and GPU PRs start with the same commit.
  • cargo build --release -p victory, cargo build --profile diag -p victory --features diagnostics and cargo xtask policy pass.
  • Game runs of our tree, with this change, on the RTX 5090.

No unit test: the race needs the title's own queue.

Overlaps with open pull requests

#816 (VICTORY_DSTORAGE_ZERO_FAILED) and #836 (decode intermediates) touch the same file, for other failures.

Not tested

Other GPUs, the Series S profile, Linux/Proton.

<!-- greyfinch-sync:fxceless/victory-fork:issue:5489833211 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/855). Originally posted by [PiloteCode](https://github.com/PiloteCode) on 2026-11-25T10:47:55Z. --- Based on `9376fd6`. It changes one file of `victory-hle` (`modules/dstorage.rs`) and adds a README line. ## What was wrong A request to a destination of physical pages carries an array of page numbers, one per 64 KiB. The title may fill that array after it has enqueued the request. A queue also submits on its own once it is half full, so a worker can take the request before the numbers are there. Until now, an unknown page number failed the request at once. The title never reads a request's result (it only polls for completion), so the model or texture kept whatever its pages held. Measured at the opening's loading on an RTX 5090: 302 requests of one burst failed this way in one run, and 44 and 9 in two other runs. ## What changes (`into_destination`) - The page numbers are read as the title has them now, with volatile reads each time, instead of once as a slice. - If one is not known after the data is decoded, the numbers are read again for up to 250 ms (15 yields, then 1 ms sleeps) until every page is known. - The retries that were already there (`VICTORY_DSTORAGE_RETRIES`, 12 tries, about 0.9 s) read the numbers again before each try. - Consecutive pages of one allocation, the usual case, still go through one view as before. - **Logging.** Requests that had to wait are counted in the lanes' periodic line (`destination_waits`). The first wait that ends with every number known is logged once, with the tries and microseconds it took. When a request still fails, one warning now says why: a page number is unknown, or the host could not map the pages. It also gives the first page number, the tries, and the totals given up and recovered on a retry. This one warning replaces two. ## Measured RTX 5090, the opening's loading and the first minutes after it: - With the change, no request failed. In one run, a number was known 17 µs after the worker first read it. - Before, 302, 44 and 9 requests failed in three runs. ## Switches - `VICTORY_DSTORAGE_RETRIES=0`: as before, no retry of the write. The wait for page numbers has no switch of its own: it only runs where the request would otherwise fail. ## Tested RTX 5090, Intel i9-14900KF, Windows 11. The branch was checked as it is, on `9376fd6`: - `cargo test -p victory-hle`: 98 + 1 passed, none failed. - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. The first commit fixes the three lints that make CI fail on `9376fd6`; the shader and GPU PRs start with the same commit. - `cargo build --release -p victory`, `cargo build --profile diag -p victory --features diagnostics` and `cargo xtask policy` pass. - Game runs of our tree, with this change, on the RTX 5090. No unit test: the race needs the title's own queue. ## Overlaps with open pull requests #816 (`VICTORY_DSTORAGE_ZERO_FAILED`) and #836 (decode intermediates) touch the same file, for other failures. ## Not tested Other GPUs, the Series S profile, Linux/Proton.
MamaLeVrai commented 2026-11-25 13:06:01 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by MamaLeVrai on 2026-11-25T12:23:29Z.


Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head e821cdb into main f85101b in a throwaway tree (no conflict). cargo clippy --workspace --all-targets --locked -- -D warnings: clean, and the same with --all-features: clean (main itself fails both on this machine: dead code and a sort in victory-gpu). cargo test --workspace --locked: run 1: 555 passed, 0 failed, 11 ignored; run 2: 555 passed, 0 failed, 11 ignored (main alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data.

AI-assisted (Claude Code); no game data.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7162308928 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/855#issuecomment-7162308928). Originally posted by [MamaLeVrai](https://github.com/MamaLeVrai) on 2026-11-25T12:23:29Z. --- Test report on real hardware: AMD RX 6950 XT (RDNA2), Windows 11, Rust 1.98.1, with a GPU present. I merged this PR's head `e821cdb` into `main` `f85101b` in a throwaway tree (no conflict). `cargo clippy --workspace --all-targets --locked -- -D warnings`: **clean**, and the same with `--all-features`: clean (`main` itself fails both on this machine: dead code and a sort in `victory-gpu`). `cargo test --workspace --locked`: run 1: 555 passed, 0 failed, 11 ignored; run 2: 555 passed, 0 failed, 11 ignored (`main` alone: 555 passed, 0 failed, 11 ignored). The title was not run, so this says nothing about in-game effect. No game data. AI-assisted (Claude Code); no game data.
PiloteCode commented 2026-11-25 17:08:01 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by PiloteCode on 2026-11-25T16:23:24Z.


@MamaLeVrai Thanks for the build and test run on an RX 6950 XT. It confirms that the branch merges into f85101b without a conflict, passes clippy with and without --all-features, and keeps main's test count (555 passed, 11 ignored).

The clippy failures you saw on main alone are the ones this PR's first commit fixes (19d40a7), all in victory-gpu:

  • unnecessary_sort_by in draw.rs;
  • the bench's depth_written, never read, in indirect.rs;
  • placed_filler_twins, unused without the diagnostics feature.

#854 starts with the same commit.

For the effect in the title: on our RTX 5090 test machine, 302, 44 and 9 requests failed in three runs of the opening's loading before the change, and none after. If you run the title with it, any build logs:

  • one line the first time a request's page numbers become known only after a worker took it;
  • one warning, with the reason, for each request that still fails.

A diagnostics build with VICTORY_LOG=victory_hle::modules::dstorage=debug,info also counts the requests that waited, every 5 s (destination_waits).

<!-- greyfinch-sync:fxceless/victory-fork:comment:7167901527 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/855#issuecomment-7167901527). Originally posted by [PiloteCode](https://github.com/PiloteCode) on 2026-11-25T16:23:24Z. --- @MamaLeVrai Thanks for the build and test run on an RX 6950 XT. It confirms that the branch merges into `f85101b` without a conflict, passes clippy with and without `--all-features`, and keeps `main`'s test count (555 passed, 11 ignored). The clippy failures you saw on `main` alone are the ones this PR's first commit fixes (`19d40a7`), all in `victory-gpu`: - `unnecessary_sort_by` in `draw.rs`; - the bench's `depth_written`, never read, in `indirect.rs`; - `placed_filler_twins`, unused without the `diagnostics` feature. #854 starts with the same commit. For the effect in the title: on our RTX 5090 test machine, 302, 44 and 9 requests failed in three runs of the opening's loading before the change, and none after. If you run the title with it, any build logs: - one line the first time a request's page numbers become known only after a worker took it; - one warning, with the reason, for each request that still fails. A diagnostics build with `VICTORY_LOG=victory_hle::modules::dstorage=debug,info` also counts the requests that waited, every 5 s (`destination_waits`).
PiloteCode commented 2026-11-25 23:09:54 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by PiloteCode on 2026-11-25T22:11:37Z.


Merged main (c36971b) into the branch: a merge commit on top of the commits already here (fee0239), then three small commits. The branch merges into main without a conflict again.

The conflict. One, in dstorage.rs: each side had added a static after into_destination (DESTINATION_WAITS here, AUTO_SUBMITS on main). Both are kept.

What main's 79cfdd9 changes for this PR. A queue that submits itself half full now leaves its reads into physical pages for the title's Submit. That closes the path this PR was written for. It also covers a list that still names a page's previous owner, which this PR never did: it only waits for a number that is not known. What this PR still adds on top of the hold:

  • The page numbers are read with volatile reads each time, not through a slice over memory the title may be writing.
  • A read that starts before the title wrote its numbers reads them again for up to 250 ms, and again before each retry of the write. With reads held, only a full queue's held reads start that early (queue).
  • The waits are counted in the lanes' line, and a request that still fails says why in one warning.

The numbers in the description (302, 44 and 9 failed requests before, none after) were measured before 79cfdd9. What this PR changes in the title on top of the hold has not been measured: the merged branch has not run in the title.

Added after the merge:

  • Two lint commits for main's newer code, the same as on our other open branches: manual_is_multiple_of in shadow.rs, queue.rs, draw.rs and watch.rs, map_entry in fpsbox.rs, collapsible_if in pipeline/library.rs. Without them cargo clippy --workspace --all-targets --locked -- -D warnings fails on c36971b, with or without --all-features.
  • One commit that brings the note in into_destination and the README line up to date (they said a half-full queue's own submission brought a worker to the request first), and adds a test, a_page_number_written_after_its_read_started_is_read_again: a read is submitted with no page number in its list, the number is written 20 ms later, the request succeeds and the page holds its bytes. The test passes on main alone too (c36971b with only the test added): there the retries of the write read the list's memory again. So it holds the behaviour, and does not tell this branch from main. No change of behaviour in this commit.

Checked, the branch as it is (f0c8068), every test on the software adapter:

  • cargo clippy --workspace --all-targets --locked -- -D warnings, and the same with --all-features: clean.
  • cargo xtask policy, cargo build --release -p victory and cargo build --profile diag -p victory --features diagnostics: pass.
  • cargo test -p victory-hle -- --test-threads=1: 101 + 1 passed (main: 100 + 1; the one more is the new test).
  • cargo test -p victory-gpu --features diagnostics -- --test-threads=1 with VICTORY_D3D12_WARP=1: 200 passed, 1 failed, 6 ignored, as on main. The failure is depth_bounds_pipeline_loads_and_filters_draws: WARP does not reject the pixels outside the depth bounds.
  • cargo test -p victory-shader -- --test-threads=1 with VICTORY_WARP=1: 212 passed, 4 failed, 3 ignored, the same four as on main on the software adapter.
  • cargo test -p victory -p victory-loader: passed.
<!-- greyfinch-sync:fxceless/victory-fork:comment:7176054556 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/855#issuecomment-7176054556). Originally posted by [PiloteCode](https://github.com/PiloteCode) on 2026-11-25T22:11:37Z. --- Merged `main` (`c36971b`) into the branch: a merge commit on top of the commits already here (`fee0239`), then three small commits. The branch merges into `main` without a conflict again. **The conflict.** One, in `dstorage.rs`: each side had added a static after `into_destination` (`DESTINATION_WAITS` here, `AUTO_SUBMITS` on `main`). Both are kept. **What `main`'s 79cfdd9 changes for this PR.** A queue that submits itself half full now leaves its reads into physical pages for the title's Submit. That closes the path this PR was written for. It also covers a list that still names a page's previous owner, which this PR never did: it only waits for a number that is not known. What this PR still adds on top of the hold: - The page numbers are read with volatile reads each time, not through a slice over memory the title may be writing. - A read that starts before the title wrote its numbers reads them again for up to 250 ms, and again before each retry of the write. With reads held, only a full queue's held reads start that early (`queue`). - The waits are counted in the lanes' line, and a request that still fails says why in one warning. The numbers in the description (302, 44 and 9 failed requests before, none after) were measured before 79cfdd9. What this PR changes in the title on top of the hold has not been measured: the merged branch has not run in the title. **Added after the merge:** - Two lint commits for `main`'s newer code, the same as on our other open branches: `manual_is_multiple_of` in `shadow.rs`, `queue.rs`, `draw.rs` and `watch.rs`, `map_entry` in `fpsbox.rs`, `collapsible_if` in `pipeline/library.rs`. Without them `cargo clippy --workspace --all-targets --locked -- -D warnings` fails on `c36971b`, with or without `--all-features`. - One commit that brings the note in `into_destination` and the README line up to date (they said a half-full queue's own submission brought a worker to the request first), and adds a test, `a_page_number_written_after_its_read_started_is_read_again`: a read is submitted with no page number in its list, the number is written 20 ms later, the request succeeds and the page holds its bytes. The test passes on `main` alone too (`c36971b` with only the test added): there the retries of the write read the list's memory again. So it holds the behaviour, and does not tell this branch from `main`. No change of behaviour in this commit. **Checked**, the branch as it is (`f0c8068`), every test on the software adapter: - `cargo clippy --workspace --all-targets --locked -- -D warnings`, and the same with `--all-features`: clean. - `cargo xtask policy`, `cargo build --release -p victory` and `cargo build --profile diag -p victory --features diagnostics`: pass. - `cargo test -p victory-hle -- --test-threads=1`: 101 + 1 passed (`main`: 100 + 1; the one more is the new test). - `cargo test -p victory-gpu --features diagnostics -- --test-threads=1` with `VICTORY_D3D12_WARP=1`: 200 passed, 1 failed, 6 ignored, as on `main`. The failure is `depth_bounds_pipeline_loads_and_filters_draws`: WARP does not reject the pixels outside the depth bounds. - `cargo test -p victory-shader -- --test-threads=1` with `VICTORY_WARP=1`: 212 passed, 4 failed, 3 ignored, the same four as on `main` on the software adapter. - `cargo test -p victory -p victory-loader`: passed.
PiloteCode commented 2026-11-27 00:04:39 +00:00 (Migrated from github.com)

Imported from fxceless/victory-fork. Originally posted by PiloteCode on 2026-11-27T00:04:39Z.


Closing this one: on today's main we cannot show that it still does anything.

  • main fixed most of it in 79cfdd96 (after upstream eddde734). When a half-full queue submits itself, it now holds reads into physical pages for the title's Submit, so a worker no longer reads their page numbers before the title has written them. The 302, 44 and 9 failed requests we measured at the opening's loading were all from before that.

  • What this PR would still add:

    • the page numbers read again with volatile reads, for up to 250 ms, until every one is known;
    • the numbers read again before each retry;
    • one warning that says why a request fails.

    The one place left where a read can start before its numbers are written is a full queue whose held reads go early (queue, which warns once).

  • The test we wrote for it writes a page number 20 ms after its read started, and it passes on main unchanged, in debug and release builds. main's retries (VICTORY_DSTORAGE_RETRIES, about 0.9 s) read the title's list again on each try, since the slice they read points into it. So we have no evidence that the rest is needed.

If failed destinations show up again (the warning "a destination's physical pages could not be written", or "a full queue's reads into physical pages start before the title's Submit"), we will come back with a log.

<!-- greyfinch-sync:fxceless/victory-fork:comment:7206149879 --> Imported from [fxceless/victory-fork](https://github.com/fxceless/victory-fork/pull/855#issuecomment-7206149879). Originally posted by [PiloteCode](https://github.com/PiloteCode) on 2026-11-27T00:04:39Z. --- Closing this one: on today's `main` we cannot show that it still does anything. - `main` fixed most of it in 79cfdd96 (after upstream eddde734). When a half-full queue submits itself, it now holds reads into physical pages for the title's Submit, so a worker no longer reads their page numbers before the title has written them. The 302, 44 and 9 failed requests we measured at the opening's loading were all from before that. - What this PR would still add: - the page numbers read again with volatile reads, for up to 250 ms, until every one is known; - the numbers read again before each retry; - one warning that says why a request fails. The one place left where a read can start before its numbers are written is a full queue whose held reads go early (`queue`, which warns once). - The test we wrote for it writes a page number 20 ms after its read started, and it passes on `main` unchanged, in debug and release builds. `main`'s retries (`VICTORY_DSTORAGE_RETRIES`, about 0.9 s) read the title's list again on each try, since the slice they read points into it. So we have no evidence that the rest is needed. If failed destinations show up again (the warning "a destination's physical pages could not be written", or "a full queue's reads into physical pages start before the title's Submit"), we will come back with a log.

Pull request closed

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
fxceless/victory-fork!854
No description provided.