fix(hle): retry transient physical destination writes in DirectStorage #3282
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3282
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3282"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
@legayclightning22 on GitHub · 2026-11-26 15:41 UTC · original
legayclightning22:fix/dstorage-destination-write-retries→main· +171 −1 · 1 files · 1 commits · openSummary
Adds bounded retries with capped exponential backoff to DirectStorage physical destination writes in
crates/victory-hle/src/modules/dstorage.rsso transient page/view refusals during launch and streaming recover cleanly instead of dropping reads.Changes
xmem::write_physicalfailures up to 12 times by default (VICTORY_DSTORAGE_RETRIESoverride capped at 64) with capped exponential backoff (1–100 ms).Verification
cargo test -p victory-hle --libcargo clippy --locked -p victory-hle --all-targets -- -D warningscargo xtask policy@AurumCarlos on GitHub · 2026-11-26 15:46 UTC · original · reviewed
The retry treats every
write_physicalfailure as transient, butinto_destinationalready handles a known permanent one right after it (page number 0, "no page"). With this change, that case and any other bad destination now sleep through 12 attempts (about 0.6 s: 1+2+…+64 ms, then 100 ms × 5) on a DirectStorage worker before reaching the same fallback, with the worker blocked the whole time. A title issuing several such requests would stall the queue.What makes a refusal transient here? If there's a log showing
write_physicalfailing and then succeeding for the same pages (e.g. a mapping racing the read), please link it. Otherwise, retrying only when the pages exist but aren't mapped yet, and failing at once for page 0 or unknown pages, would keep the bad cases fast.@Dukestar69 on GitHub · 2026-11-26 15:47 UTC · original · approved these changes
Reviewed the diff and verified locally on Windows 11 x64:
xmem::write_physicalrefusals with capped exponential backoff (VICTORY_DSTORAGE_RETRIES, capped at 64, max 100 ms backoff) and surfacingdestination_retriesin the periodic debug line is clean and bounded.cargo test -p victory-hle --lib modules::dstorage:: -- --test-threads=1: 19 passed, 0 failed (includingdestination_retry_setting_is_bounded,physical_writes_retry_transient_refusals, andphysical_writes_report_exhausted_retries_without_panicking).cargo clippy -p victory-hle --all-targets -- -D warnings: clean.cargo xtask policy: 191 files ok.Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
5bbed0f1b9to891dfa023c@legayclightning22 on GitHub · 2026-11-26 16:20 UTC · original
Pushed
891dfa0adding an immediate fail-fast check for page0/ unknown or unmapped destination addresses before retrying so bad addresses don't incur retry backoff, along with a unit test asserting zero retry attempts. Re-verifieddstoragetests (20/20 passing),clippy -- -D warnings, andcargo xtask policy.@fuzeofficlal on GitHub · 2026-11-26 20:24 UTC · original · requested changes
Thanks for adding the fail-fast precheck in
891dfa0. Local tests pass (victory-hle: 156 lib + 2 integration tests,dstorage::: 20 passed), andclippy(default &--all-features) is clean, but a few issues ininto_destination/retry_physical_writestill need attention before merge:Requested changes
crates/victory-hle/src/modules/dstorage.rs:1057-1067,1143-1161):pagesviews title memory directly (1113). Ifretry_physical_writeobserves0at1057and returnsErr(E_INVALIDARG), and the title finishes populating the page list before1143(if pages.contains(&0)),1143seesfalse, skipsLATE_LIST_TRIESand the write, and fails the request withE_INVALIDARG. Even without the race,1059also logs"dstorage: physical destination has no allocated pages"atwarn!beforeLATE_LIST_TRIESgets a chance to succeed.dstorage.rs:909-918,1113-1131):inflate(912) accepts outputs shorter thanlen(n < len), andinto_destinationonly writes&data[..n](1129). However,pagesis sliced for(offset + len).div_ceil(PAGE)(1116), sopages.contains(&0)andunknown_pages(pages)inspect trailing pages pastoffset + nthat will not be written. If any unused trailing page is0or unknown, the precheck rejects a write that fits cleanly in the leading pages. Slicingpagesto(offset + n).div_ceil(PAGE)before callingretry_physical_writewould avoid this.dstorage.rs:459,523,669,1086):Retrying with
std::thread::sleep(up to ~627 ms at the default 12 retries, or ~5.8 s at the cap of 64) holds the worker thread,self.stagedquota, queue status flushing, andclose_lanewithout checkinglane.closed. Also, as asked earlier, oncezero == false && unknown == 0, it would be helpful to clarify what concrete transient condition makeswrite_physicalsucceed after sleeping.Minor nits
DESTINATION_RETRIESis a process-wide static read byLanes::count(497,swap(0)) and asserted inphysical_writes_retry_transient_refusals(1928) /physical_writes_fail_fast_on_page_zero_or_unknown_pages(1962), which can race if tests run concurrently or with debug logging enabled.allocated_page()(1346) does not free its allocated physical page viaXMemFreePhysicalPagesat the end of those two tests.rustfmt --edition 2024diffs appear in the PR hunks atdstorage.rs:1038and1910.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.