Skip to content

DirectStorage: wait up to 250 ms for a page list the title fills late - #2338

Closed
JurajSimicevic wants to merge 1 commit into
Marvisak:mainfrom
JurajSimicevic:dstorage/late-page-lists
Closed

JurajSimicevic wants to merge 1 commit into
Marvisak:mainfrom
JurajSimicevic:dstorage/late-page-lists

Conversation

@JurajSimicevic

Copy link
Copy Markdown

Problem

A DirectStorage request into physical pages (PAGE_DESTINATION) whose page list still names page 0 is read again for 8 ms (#1726) and then fails with E_INVALIDARG. The title never looks at a request's result, so each failure is a model or texture left unwritten. #2181 sees untextured geometry after such a burst.

On a fast host the data is read and inflated before the title has filled the list, and 8 ms is not always enough. On this host (Windows 11, RTX 5080, NVMe), three world loads on main 940d32f, with the typed-UAV check of #1775/#1763 to boot, logged "a destination's physical pages could not be written; its request fails" 391, 45 and 24 times, each time in one burst while the world loads.

What the failed requests had in common (local diagnostics, not in this PR)

  • In all 40 failures logged in detail, the page list still named page 0 when the request failed, in full or in part. The other entries were pages the title holds. No page was freed, out of range or failing to map.
  • 24 lists were watched after their request had failed. Every one was filled 3 to 6.5 ms after the 8 ms ran out, and all the pages were ones the title holds. The data had been read and inflated; only the wait was too short.

Change

  • The list is read again for up to 250 ms (LATE_LIST_WAIT) instead of 8 tries of 1 ms. A list that still names page 0 after that fails as before.
  • The "written late" log line also says how long the read waited (waited_ms).
  • Tests: DirectStorage: read a page list naming page 0 again before failing its request #1726's test is now a helper with two cases, the list filled 2 ms and 40 ms after the request starts. The 40 ms case fails with the 8 ms wait (E_INVALIDARG, -2147024809) and passes with this change.

crates/victory-hle/src/modules/dstorage.rs only, +26 −6.

Tested

  • cargo test -p victory-hle --locked: 144 passed.
  • cargo clippy -p victory-hle --all-targets --locked -- -D warnings, with and without --all-features: clean. No new rustfmt hunks.
  • In the title, with this change (two runs, RTX 5080, diag build):
run requests failed lists written late waited
1 0 none logged –
2 0 16 to 31 (the counter logs at powers of two) 5 to 6 ms

The limit, said plainly: in both runs the race either did not happen or ended within 8 ms, which the old wait also covers. So the in-title runs show that this changes nothing for the worse. The case it fixes, lists later than 8 ms, rests on the diagnostics above and on the test. The lateness varies between runs on the same machine (likely how warm the file cache is). A run on a fast host that logs the old warning on main and then written late with waited_ms over 8 here would settle it.

Notes

No game data attached: counts, timings and log lines only.

AI-assisted.

🤖 Generated with Claude Code

A request into physical pages whose page list still names page 0 was
read again for 8 ms before it failed (Marvisak#1726). On a fast host the data is
read and inflated before the title fills the list: on one Windows 11
host, 24 to 391 such requests failed per world load, each a model or
texture left unwritten. Every failed list named page 0, and the 24 that
were watched after failing were filled 3 to 6.5 ms after the 8 ms had
run out, all with pages the title holds.

The list is now read again for up to 250 ms. The written-late log line
says how long the read waited. A new test fills the list 40 ms after
the request starts; with the 8 ms wait it fails with E_INVALIDARG.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

@catminou4 catminou4 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Static review only: victory-hle is Windows-only; not tested on macOS. Replaces the fixed 8 ms retry loop with a 250 ms deadline for late DirectStorage page lists, motivated by observed 3-6.5 ms fill times — sensible; the waited_ms logging helps verify in the field.

@andrewpozdnakov7-jpg

Copy link
Copy Markdown
Contributor

Independent native Windows check on 77d5d1b. I copied only the two test cases onto 940d32f. The 2 ms case passed there and the 40 ms case returned E_INVALIDARG (0x80070057). Both tests passed five consecutive runs on the exact PR head, including the physical-page byte comparison. The full victory-hle library suite passed all 144 tests. The runs used synthetic requests and mapped pages.

@JurajSimicevic

Copy link
Copy Markdown
Author

In-title result with this PR's change: lists filled 62 to 84 ms late, all written

The PR said the in-title runs after the fix had not yet shown a list later than 8 ms. A longer run has now shown some.

Setup: RTX 5080, diag build of main 940d32f with this PR's commit (the same diff, cherry-picked), #1762, and #1968's program A skipped so the world keeps running. One run of 15 minutes, through the prologue into the first gameplay prompts.

  • written late lines: five, all in one burst while the world loaded. The counter logs at powers of two, so between 16 and 31 lists were filled late.
  • waited_ms on the logged ones: 62, 65, 68, 79, 84. The 8 ms wait on main would have failed every one of them with E_INVALIDARG.
  • a destination's physical pages could not be written: 0.

So the late lists are not limited to the 3 to 6.5 ms seen first. While the title loads they can trail the request by tens of milliseconds, and the 250 ms bound covers that with room to spare. The test's 40 ms case is still below what the title did here. I can raise it to 100 ms if you prefer a case above the longest wait seen.

No game data: log counts and timings only.

AI-assisted.

Marvisak commented Nov 25, 2026 •

Copy link
Copy Markdown
Owner

Automated triage for the maintainers.

This pull request no longer merges cleanly into main (conflicts in crates/victory-hle/src/modules/dstorage.rs). It will be reviewed once it is rebased onto the current main. The earlier verdict (merge-candidate) was for an older state of main.


Generated by Claude Code

@JurajSimicevic

Copy link
Copy Markdown
Author

Closing this: eddde73 on main removes the cause instead of waiting it out. Reads into physical pages now wait for the title's Submit, which is where the title fills the page table. It measured 0 failed and 0 late writes after the change.

Our in-title numbers fit that explanation. The 62 to 84 ms lists in my comment above all came in one burst while the world loaded, which matches a queue that submits itself at half capacity before the title's Submit. A longer retry bound only matters if a list is still empty after Submit, and nothing here shows that. If it shows up later, it can come back as a small change on top of eddde73.

Thanks @andrewpozdnakov7-jpg and @catminou4 for checking it.

AI-assisted.

clquwu added a commit to clquwu/leonida-ultimate that referenced this pull request Nov 25, 2026
…, and rebase frame pacer flips (W14-04, W14-10d)

- W14-04 (runtime/shims/dstorage.cpp):
  - Raise auto-submit threshold from >= half() to strictly > half() (clamped to usable()) and reflect it in Query1::RequestCountUntilAutoSubmit (adapted from Marvisak/VIctory#2074, GPL-3.0).
  - Hold options::kDestinationPages requests and all subsequent entries (plain reads, Status, Signal, Event) on auto-submit until explicit Submit() so DestinationPageArray can be populated before execution and later entries cannot overtake held paged requests or misattribute errors; force-flush only when the queue is completely full with nothing submitted or in flight so titles cannot deadlock (adapted from Marvisak/VIctory#2617, TheBiemGamer/VIctory-Belobug-AMD@5895cd9b07, GPL-3.0).
  - Retry DestinationPageArray reads in paged_request() for up to 250 ms with 1 ms sleeps when any page entry reads 0, honoring cancellation and queue close before failing with E_DSTORAGE_ACCESS_VIOLATION (adapted from Marvisak/VIctory#2338, TheBiemGamer/VIctory-Belobug-AMD@c5e2970aa6, uwutaube/VIctory@85a0f763b9, GPL-3.0), while preserving destination_may_alias and host-bounce recovery.
  - Fix pre-existing C4244 uint64_t->UINT32 narrowing warnings in Stats::snapshot().
- W14-10d (runtime/src/frame_pacer.h):
  - Retire already-passed pending flips (preserving original display timestamps) and rebase remaining pending flips onto consecutive slots of the new vblank grid in FIFO order when the frame interval or FPS limit changes (adapted from ubiquitarianism/leonida#1992, GPL-3.0).
- Tests (runtime/test/dstorage_test.cpp, runtime/test/frame_pacer_test.cpp):
  - Cover strict > half() auto-submit, kDestinationPages hold and ordering with subsequent Status/Signal/Event/plain reads, full-queue deadlock avoidance, late-filled page == 0 retry/timeout/cancellation, and speedup/slowdown/FPS-limit pending-flip rebasing.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants