feat(runtime): budget DirectStorage buffers and loose GPU shadows #3067
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!3067
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-3067"
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?
@brainbudt on GitHub · 2026-11-26 06:08 UTC · original
brainbudt:feat/host-ram-budget→main· +507 −45 · 16 files · 2 commits · openProblem
DirectStorage can reserve a few compressed file bytes and then allocate a much larger zlib-to-BCPack intermediate on each worker. Loose GPU shadow windows also compete for host RAM during loading. The title's staging setting controls only part of that demand. Addresses held by descriptors, lists, and shader page tables can remain live under pressure.
Change
Add an opt-in host buffer budget through
VICTORY_HOST_RAM_BUDGET_MIBor the top-levelhost_ram_budget_mibconfig key. Reserve each read's input, intermediate, BCPack workspace, and possible scattered output before dispatch. A read waits for running reads to release capacity. A request that cannot fit completes through its queue's ordered error path withE_OUTOFMEMORY.Charge loose buffers through their D3D resource lifetime. Reclaim whole, unused windows over released guest memory. In budgeted runs, return idle snapshot buffers, use one runtime pipeline compiler worker, and report accounted bytes (sampled after
lanes.finishreleases the completed job's reservation) alongside process working set and available physical memory.Scope & relation to #3012
Implements the opt-in host-RAM budget requested in #3012 (there is no other open PR addressing #3012). Zero or unset preserves existing scheduling unchanged. The cap covers the named buffers (DirectStorage input/intermediate/workspace/output + loose GPU shadow windows); guest memory, registered resources, active snapshots, compiler internals, and driver allocations remain outside it.
Note for maintainers: this adds
victory-coretovictory-gpuandvictory-hle, addswindows-coretovictory-gpu(forSetPrivateDataInterface), and returnsE_OUTOFMEMORYfor reads that cannot fit within the configured budget.Verification
cargo check --testsandcargo clippy --tests -- -D warningsfor all affected crates, including an additional--all-featuresClippy run.Reviewed with mistral-loop: APPROVE (2 rounds,
mistral-large-4-0+deepseek-v4-1-flash-1017).Created with gpt-6.2-astra in Codex (orchestrated with Gemini 4 Neon in T3 Code).
@Marvisak on GitHub · 2026-11-26 06:18 UTC · original
Automated triage for the maintainers.
Needs work. This needs the maintainer's decision. The PR adds an opt-in host RAM budget:
victory-core::host_ram, the config keyhost_ram_budget_miband the env varVICTORY_HOST_RAM_BUDGET_MIB. Under the budget, DirectStorage reads are admitted (dstorage.rs), loose shadow windows are charged and reclaimed (shadow.rs, plus a newrelease_loose_windowscall inXMemFreeDefault), and the runtime pipeline compiler drops to one worker (pipeline/make.rs). That touches the dependency graph:victory-gpuandvictory-hlegainvictory-core,victory-gpugainswindows-core(Cargo.toml,Cargo.lock). It also adds a runtime-wide feature that can make DirectStorage requests fail withE_OUTOFMEMORY. Both are the maintainer's call.To move forward, apart from that decision:
CI:
checkpassing.Generated by Claude Code
@fuzeofficlal on GitHub · 2026-11-26 06:23 UTC · original · approved these changes
Reviewed all 16 changed files at
b19608cc:host_ram::Budget::usedis strictly a leaf lock, so there is no lock-order inversion withscheduler.lanes,LOOSE, orxmem. Indstorage::Lanes::start, settingstarved = trueonly whenreservefails withbytes <= budget.limit - used.loose_shadowsguaranteesused.direct_storage > 0(at least one in-flight worker will finish, drop itsReservationinlanes.finish, and notifyscheduler.work), while requests that no longer fit afterloose_shadowsgrows fail cleanly in queue order withE_OUTOFMEMORY.WindowChargeviaID3D12Resource::SetPrivateDataInterfacekeeps loose-window capacity charged for the true D3D12 resource lifetime (even across retired descriptors / in-flight command lists),retire_unusedusesArc::try_unwrapatomically so concurrentWeakupgrades from write-marks cannot race,find_with_owner+for_viewreturnkeep = truefor budgeted loose shadows soHostHeap::keptretains theArc<Shadow>, andhost_ram_budget_mib = 0leavesBUDGETuninitialized with zero behavioral change.Minor non-blocking notes:
dstorage::work,lanes.count(&job, started)samplesbudget.usage()just beforelanes.finish(job, result)dropsjob.memory, so the 5-second"host RAM budget (bytes)"log includes the just-finished job'sdirect_storagebytes; sampling afterlanes.finishwould reflect post-completion usage.VirtualFree(..., MEM_RELEASE)/ 32-bitXMemFreeDefaultand no newloose()allocation has triggeredfree_windowyet, staleMEM_FREEloose windows remain charged inused.loose_shadowswhendstoragechecksbytes <= budget.limit - used.loose_shadows; a future follow-up could sweepMEM_FREEloose windows before returningE_OUTOFMEMORY.HostHeap::sync_rangesPhase 2find_existing_batch) also lands, its Phase 2 path should preserveown = truefor budgeted loose shadows just asfor_viewdoes here.Looks solid overall.
@kotekompotek on GitHub · 2026-11-26 06:37 UTC · original · approved these changes
Verified end to end: Budget/Reservation charge-before-allocate under one lock with RAII refund; DS start() distinguishes starved (fits once running reads release, wakes via starved flag) from never-fitting (ordered E_OUTOFMEMORY inside the Job so statuses still land in sequence); loose-shadow reservation hangs on the D3D resource via SetPrivateDataInterface so the charge outlives Shadow; release_loose_windows requires whole-window MEM_FREE + last-Arc + try_unwrap (Weak-upgrade safe); for_view keeps budgeted loose windows alive for views; 1 pipeline worker under budget; combined-read test proves correct bytes through the real zlib+BCPack path. Config/env plumbing and docs included.
@brainbudt on GitHub · 2026-11-26 10:21 UTC · original
Addressed the triage and review notes:
README.mdaddition to a concise 3-line pointer tovictory.example.toml/VICTORY_HOST_RAM_BUDGET_MIB.E_OUTOFMEMORYmaintainer decision points.budget.usage()is now sampled afterlanes.finish(job, result)releases the finished job's reservation.(A matched 16 GiB title load remains open for anyone with game files.)
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.