Skip to content

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

Closed
PiloteCode wants to merge 7 commits into
fxceless:mainfrom
PiloteCode:pr/runtime
Closed

PiloteCode wants to merge 7 commits into
fxceless:mainfrom
PiloteCode:pr/runtime

Conversation

@PiloteCode

Copy link
Copy Markdown

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.

…s-only count

`cargo clippy --workspace --all-targets -- -D warnings` (CI) fails on 9376fd6
with this toolchain: unnecessary_sort_by in draw.rs, the bench's
depth_written in indirect.rs never read, and placed_filler_twins unused
without the diagnostics feature. No code changes.
…t is read again, not failed at once

The title may fill a request's page numbers after it enqueued the
request, and a queue submits on its own once half full, so a worker can
take the request first. An unknown page failed the request at once, and
its model or texture kept whatever its pages held (the title never reads
a request's result): 302 requests of one burst at the opening's loading
in one run, 44 and 9 in others (RTX 5090).

The page numbers are now read as the title has them (volatile, each
time, not kept as a slice). One not known after the decode is read again
for up to 250 ms (15 yields, then 1 ms sleeps); the retries of the write
(VICTORY_DSTORAGE_RETRIES) read them again before each try. In a run, a
number was known 17 us later, and no request failed.

Requests that waited are counted in the lanes' line (destination_waits);
the first wait that ends with every number known is logged once. A
request that still fails says why in one warning: a page number unknown,
or pages the host could not map.
ExoCalibra added a commit to ExoCalibra/victory-exo that referenced this pull request Nov 25, 2026
ExoCalibra added a commit to ExoCalibra/victory-exo that referenced this pull request Nov 25, 2026
…d VICTORY_SKIP_WC_COMPARE water-physics caveat
@MamaLeVrai

Copy link
Copy Markdown

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

Copy link
Copy Markdown
Author

@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).

CernyMuzCZ pushed a commit to CernyMuzCZ/vitezstvi-fork that referenced this pull request Nov 25, 2026
ExoCalibra added a commit to ExoCalibra/victory-exo that referenced this pull request Nov 25, 2026
…held for the title's Submit, beside the wait for late page numbers

One conflict, in crates/victory-hle/src/modules/dstorage.rs: each side
added a static after into_destination (DESTINATION_WAITS here,
AUTO_SUBMITS upstream). Both are kept.

Upstream's 79cfdd9 leaves the reads into physical pages out when a
half-full queue submits itself, until the title's Submit
(Lanes::submit_as), and starts them before it only where a full queue
would otherwise never empty. It does not touch into_destination: the
page numbers are still read volatile each time, read again for up to
250 ms where one is unknown, and read again before each retry of the
write.
…rt, an if joined to its let, counts tested with is_multiple_of)

`cargo clippy --workspace --all-targets --locked -- -D warnings` fails on
085ee7c with the pinned toolchain (1.98.1), after the two fixes before
this one too: map_entry in fpsbox.rs, collapsible_if in
pipeline/library.rs, manual_is_multiple_of in queue.rs and shadow.rs, and
with --all-features in draw.rs and watch.rs (twice). No change of
behaviour.
…d the reads held for Submit, and a test of a number written after its read started

Since upstream's 79cfdd9, a queue that submits itself half full leaves
its reads into physical pages for the title's Submit. The wait in
into_destination is then reached only by a read that starts before the
title wrote its numbers: a full queue's held reads. Its note and the
README line said that a half-full queue's own submission brought a worker
to the request first. Both now say where that still happens, and that the
failures they count were measured before reads were held.

The test submits a read whose list holds no page number yet and writes
the number 20 ms later: the request succeeds and the page holds its
bytes. No change of behaviour.
@PiloteCode

Copy link
Copy Markdown
Author

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

Copy link
Copy Markdown
Author

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

  • main fixed most of it in 79cfdd9 (after upstream eddde73). 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.

@PiloteCode PiloteCode closed this Nov 27, 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