DirectStorage: physical pages the host refused a view of are written on a retry #2883
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!2883
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-2883"
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?
@0xkn0wh3r3 on GitHub · 2026-11-25 23:01 UTC · original
0xkn0wh3r3:hle/dstorage-page-writes-retry-host-refusals→main· +181 −38 · 2 files · 3 commits · openWhat
A DirectStorage request whose destination is physical pages writes them through views of their sections (
xmem::write_physical). If every page is known but the host refuses a view, the request used to fail at once. The refusal comes fromMapViewOfFile, or from committing the view, failing while commit or address space is short, for example while a load maps many pages at once. The title never reads a request's result, so the model or texture just kept whatever its pages held. The only case retried was a page list still naming page 0 (#1726).Now
View::mapreturns the Windows error when the host refuses, andwrite_physicalpasses it on. When the error is a memory shortage (ERROR_NOT_ENOUGH_MEMORY,ERROR_NO_SYSTEM_RESOURCESorERROR_COMMITMENT_LIMIT), the write is tried again up to seven times, waiting 2, 4, … 128 ms before each (254 ms in all), before the request fails. Any other error, or a retry that meets one, fails the request at once, and so do requests that name pages xmem doesn't know, so a bad list or a refusal that can't pass doesn't hold up its queue.The warning for a request that fails now includes the error (
error = … (os error N)), and the info line for a write that succeeded on a retry includes the code it first met.Where it came from
From DexNom's fork, DexNom/VIctory@570a941 (
into_destination's retries,VICTORY_DSTORAGE_RETRIES). Their version retries every failure for about 1.5 s. This one only retries known pages refused for lack of memory, and waits less in total. Credited withCo-authored-by: DexNom.Tested
dstorage::tests::host_refusals_are_retried_with_longer_waits: a write refused for lack of memory that succeeds on its third retry waited 2, 4 and 8 ms. One that never succeeds waited 2 … 128 ms and fails with the last error.dstorage::tests::other_refusals_are_not_retried: unknown pages and other errors (access denied) aren't retried, and a retry that meets an error that can't pass stops there.cargo test -p victory-hle --lib: 154 passed. Windows 11.a_page_list_filled_after_its_request_starts(from #1726, unchanged here) failed once out of six full runs. It's timing-based: a filler thread has to write the list within the 8 ms the request re-reads it for.cargo clippy -p victory-hle --all-targets: 0 warnings.cargo xtask policy: ok.Not tested
View::map, and I haven't run the title under commit pressure, so I don't know which error code it actually returns. The warning now names it, so a log from a tester who hits it will show the failure mode.Changes after review
8ad1371(was4e89780before the rebase): if a list naming page 0 gets filled in while the request reads it again, but the write then meets a host refusal, the retries and the failure's log line now use the list as last read, not the first reading.5c87644(triage):View::mapreports the Windows error, the failure warning includes it, and retries happen only for memory-shortage errors.4e897803d1to5c87644762@cloph-dsp on GitHub · 2026-11-25 23:10 UTC · original
Local verification on Windows / rustc 1.100.0 / MSVC, no game data, no GPU, no clippy/rustup.
cargo test --locked -p victory-hle --lib host_refusals_are_retried_with_longer_waits --quiet-> 1 passed, 0 failed (152 filtered out).cargo test --locked -p victory-hle --quiet-> 153 passed, 0 failed, plus doctests.842b0cb: 1 file +61/-0;git diff --checkclean.host_refusals_are_retried_with_longer_waitsis absent from the base commit, so the coverage is new here.victory-gpu/src/object.rsandvictory-hle/src/modules/xmem.rs.AI-assisted (Hy4 flash).
@fuzeofficlal on GitHub · 2026-11-25 23:18 UTC · original
Reviewed and verified
fda4a63don Windows 11 againstmain(842b0cb):victory-hledstorage17/17 (includinghost_refusals_are_retried_with_longer_waits) andxmem14/14 passed,cargo clippy --locked -p victory-hle --all-targets -- -D warnings0 warnings,cargo xtask policy(191 files ok).xmem::write_physicalonly holdsphysical()briefly inruns(), never across sleep backoff orMapViewOfFile, freeing a page mid-retry terminates cleanly viaruns() -> None, and retries are idempotent beforereport_written.pagesslice contains0(entering theLATE_LIST_TRIESloop) and the title finishes filling the list (!again.contains(&0)), but that write is then refused by the host, line 1070 checksxmem::unknown_pages(pages) == 0against the original snapshot containing0and skipsHOST_RETRIES. Passing the refreshed slice (again) intounknown_pagesand the retry closure would cover that combined case too.Looks solid and ready to merge.
@Marvisak on GitHub · 2026-11-26 04:26 UTC · original
Automated triage for the maintainers.
Needs work. This retries
xmem::write_physicalininto_destination(victory-hle/src/modules/dstorage.rs) up to seven times with doubling waits (254 ms total) when all pages are known but the host refused a view. The code is sound, but the PR says the refusal has never been reproduced or logged, and if it is persistent (for example commit exhaustion) each such request now holds its queue for a quarter second without succeeding. Please attach a log showing the warning withunknown = 0followed by a successful retry, or first makeView::mapreport the Windows error so the failure mode is known.CI: passing.
Generated by Claude Code
@0xkn0wh3r3 on GitHub · 2026-11-26 07:22 UTC · original
I can't run the title, so I can't attach a log. I went with the second option in
5c87644(rebased onto main):View::mapnow returns the Windows error, usingGetLastError()right afterMapViewOfFile, or the error from committing the view.write_physicalpasses it through. When a request fails, the warning now includeserror = <message> (os error N)next tounknown. The info line for a write that succeeded on a retry includes the code it first hit.ERROR_NOT_ENOUGH_MEMORY,ERROR_NO_SYSTEM_RESOURCESandERROR_COMMITMENT_LIMIT. Any other error, or a retry that hits one, fails the request right away without waiting. I kept the commit limit in the retry set because it can rise while Windows grows a system-managed page file. When the limit is persistent,commit_refusedalready writes it tocrashes.log, since the title usually faults soon after. New test:other_refusals_are_not_retried.If anyone hits this, please post the
dstorage: a destination's physical pages could not be writtenwarning line (or thewritten after the host refused a viewinfo line) along with theerrorfield.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.