[RAM] VICTORY_WINDOW_BUDGET_MB only accounts for eviction-eligible windows instead of total cached copies #450
Labels
No labels
accessibility
bloqué : binaire console
bug
chargeur
console-dll
cpu
documentation
duplicate
enhancement
good first issue
gpu
help wanted
invalid
performance
question
runtime-gdk
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/LooperSalty--AnyXboxX#450
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
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?
@FunWithFlagsDev on GitHub · 2026-11-26 20:01 UTC · original
<html>Summary
The current implementation of
VICTORY_WINDOW_BUDGET_MBappears to calculate memory pressure against eviction-eligible loose window copies only, rather than the total size of cached loose window copies.As a result, the configured budget may already be exceeded while eligible idle resources remain unnecessarily cached.
This may contribute to avoidable host memory pressure, particularly on systems with limited RAM and GPUs with limited VRAM.
Reviewed revision
Commit:
37d4686711bbb04c2cc3825f3f13bbff7c140fb0Component:
third_party/victory/crates/victory-gpu/src/shadow.rsSource code analysis
1. Window budget configuration
shadow.rs#L2982-L2994
The documentation describes
VICTORY_WINDOW_BUDGET_MBas an optional byte cap for loose title-window copies.The configured budget is applied under the Watch and High RAM pressure bands, with the High band reducing the target to half the configured value.
2. Eviction candidate selection
shadow.rs#L3064-L3087
let_go_idle()filters theLOOSEmap before callingwindow_victims().Only resources satisfying the following conditions are included:
Arc::strong_count(s) == 1The resource has been idle for the required duration and number of frames.
The host buffer reference count is equal to one.
These are important lifetime safeguards and should be preserved.
3. Budget accounting
shadow.rs#L2999-L3018
window_victims()calculates its initial byte count exclusively from the supplied eviction candidates.Consequently, memory occupied by active, recently used or otherwise retained windows does not contribute to the eviction decision.
The current behavior effectively limits the eligible idle subset rather than the total cached window footprint.
Illustrative reproduction
Assume the Watch RAM pressure band is active and the following synthetic cache state exists:
Resource category | Size -- | -- Active or non-evictable window copies | 3,072 MiB Eligible idle window copies | 1,536 MiB Total cached window copies | 4,608 MiB Configured window budget | 2,048 MiBCurrent behavior:
window_victims()receives only the 1,536 MiB of eligible copies.The eligible subset is below the 2,048 MiB budget.
No resources are selected for eviction.
The total cached footprint remains 4,608 MiB.
Expected behavior, if the budget is intended to cover total cached copies:
Account for the full relevant cache footprint.
Select eligible idle copies until the target is reached or no eligible copies remain.
Preserve all active resources.
In this example, up to 1,536 MiB of eligible copies could be selected for reclamation, leaving 3,072 MiB of non-evictable copies.
The target cannot always be reached safely, and that is acceptable.
These figures represent a synthetic logical reproduction, not measured in-game memory usage.
Proposed change
Separate budget accounting from eviction eligibility.
Calculate the unique byte footprint of the relevant cached copies.
Calculate the excess above the configured budget.
Select the oldest eligible resources until that excess is covered, or the eligible candidates are exhausted.
Preserve existing Arc, COM reference count, idle-time and retirement safeguards.
Conceptually:
The existing diagnostic
memory()function already demonstrates identity-based deduplication across theLOOSEmap:shadow.rs#L3110-L3121
However, accounting should distinguish actual allocated copies from in-place mappings that do not allocate an additional copy of title memory.
Care should also be taken not to count aliased entries multiple times or report memory as immediately reclaimed before deferred retirement has completed.
Existing test coverage
shadow.rs#L5790-L5808
The existing tests cover:
Oldest-first victim selection.
Deduplication of a copy represented under multiple keys.
A regression test involving both eligible and non-evictable resources would help clarify the intended budget semantics.
Preliminary verification
The original and proposed selection policies were evaluated using an isolated Python model.
The model covered:
Reproduction of the original accounting mismatch.
Reclamation limited to eligible resources.
Preservation of active resources.
No additional eviction below the configured budget.
Identity-based deduplication.
Compatibility when all cached resources are eligible.
Reduced budget under the High pressure band.
Full Rust integration tests, GPU tests and in-game measurements have not been performed.
Related work
#256 — Adaptive memory caps.
#350 — Host RAM reclamation through
MEM_DECOMMITand cold-cache trimming.#409 — Migration to the combined VIctory base.
This proposal concerns budget accounting and victim selection, rather than introducing a new memory allocator or replacing existing reclamation mechanisms.
Done when
Clarify whether
VICTORY_WINDOW_BUDGET_MBis intended to limit the entire relevant cache or only its eligible idle subset.Add a regression test containing both active and eligible idle copies.
Account for unique cached allocations without double-counting aliases.
Distinguish actual memory copies from in-place mappings.
Preserve existing resource lifetime and synchronization safeguards.
Preserve existing behavior when the budget is disabled or the RAM pressure band is Calm.
Validate memory usage, cache recreation frequency and frame times under sustained streaming workloads.
Is the current eligible-only accounting intentional, or should active copies contribute to the total budget used to determine reclamation pressure?
If total-cache accounting is intended, I would be interested in preparing a focused patch with regression tests.
AI disclosure
AI assistance (OpenAI ChatGPT) was used for static source analysis, policy modeling and drafting this report.
</html>## SummaryThe current implementation of
VICTORY_WINDOW_BUDGET_MBappears to calculate memory pressure against eviction-eligible loose window copies only, rather than the total size of cached loose window copies.As a result, the configured budget may already be exceeded while eligible idle resources remain unnecessarily cached.
This may contribute to avoidable host memory pressure, particularly on systems with limited RAM and GPUs with limited VRAM.
Reviewed revision
Commit:
37d4686711bbb04c2cc3825f3f13bbff7c140fb0Component:
third_party/victory/crates/victory-gpu/src/shadow.rsSource code analysis
1. Window budget configuration
[shadow.rs#L2982-L2994](
github.com/LooperSalty/AnyXboxX@37d4686711/third_party/victory/crates/victory-gpu/src/shadow.rs (L2982-L2994))The documentation describes
VICTORY_WINDOW_BUDGET_MBas an optional byte cap for loose title-window copies.The configured budget is applied under the Watch and High RAM pressure bands, with the High band reducing the target to half the configured value.
2. Eviction candidate selection
[shadow.rs#L3064-L3087](
github.com/LooperSalty/AnyXboxX@37d4686711/third_party/victory/crates/victory-gpu/src/shadow.rs (L3064-L3087))let_go_idle()filters theLOOSEmap before callingwindow_victims().Only resources satisfying the following conditions are included:
Arc::strong_count(s) == 1These are important lifetime safeguards and should be preserved.
3. Budget accounting
[shadow.rs#L2999-L3018](
github.com/LooperSalty/AnyXboxX@37d4686711/third_party/victory/crates/victory-gpu/src/shadow.rs (L2999-L3018))window_victims()calculates its initial byte count exclusively from the supplied eviction candidates.Consequently, memory occupied by active, recently used or otherwise retained windows does not contribute to the eviction decision.
The current behavior effectively limits the eligible idle subset rather than the total cached window footprint.
Illustrative reproduction
Assume the Watch RAM pressure band is active and the following synthetic cache state exists:
Current behavior:
window_victims()receives only the 1,536 MiB of eligible copies.Expected behavior, if the budget is intended to cover total cached copies:
In this example, up to 1,536 MiB of eligible copies could be selected for reclamation, leaving 3,072 MiB of non-evictable copies.
The target cannot always be reached safely, and that is acceptable.
These figures represent a synthetic logical reproduction, not measured in-game memory usage.
Proposed change
Separate budget accounting from eviction eligibility.
Conceptually:
The existing diagnostic
memory()function already demonstrates identity-based deduplication across theLOOSEmap:[shadow.rs#L3110-L3121](
github.com/LooperSalty/AnyXboxX@37d4686711/third_party/victory/crates/victory-gpu/src/shadow.rs (L3110-L3121))However, accounting should distinguish actual allocated copies from in-place mappings that do not allocate an additional copy of title memory.
Care should also be taken not to count aliased entries multiple times or report memory as immediately reclaimed before deferred retirement has completed.
Existing test coverage
[shadow.rs#L5790-L5808](
github.com/LooperSalty/AnyXboxX@37d4686711/third_party/victory/crates/victory-gpu/src/shadow.rs (L5790-L5808))The existing tests cover:
A regression test involving both eligible and non-evictable resources would help clarify the intended budget semantics.
Preliminary verification
The original and proposed selection policies were evaluated using an isolated Python model.
The model covered:
Full Rust integration tests, GPU tests and in-game measurements have not been performed.
Related work
MEM_DECOMMITand cold-cache trimming.This proposal concerns budget accounting and victim selection, rather than introducing a new memory allocator or replacing existing reclamation mechanisms.
Done when
VICTORY_WINDOW_BUDGET_MBis intended to limit the entire relevant cache or only its eligible idle subset.Is the current eligible-only accounting intentional, or should active copies contribute to the total budget used to determine reclamation pressure?
If total-cache accounting is intended, I would be interested in preparing a focused patch with regression tests.
any008_window_budget_model.py
@KainanP on GitHub · 2026-11-26 20:39 UTC · original
Thanks. I checked this against both revisions:
37d4686(combined base, #409): confirmed.shadow::let_go_idlebuildseligible(strong count 1, idle, COM refs 1) and passes only those entries towindow_victims, which sumsleftfrom the eligible copies alone. Copies that are active or recently used never count towardsVICTORY_WINDOW_BUDGET_MB. One more thing I noticed: with the budget unset, or in the Calm band,keep == u64::MAXand every eligible copy goes. In Watch/High,window_victimskeeps up tokeepbytes of eligible idle copies that would otherwise have been released. The budget therefore makes the sweep keep more idle copies than having no budget would, apart from the shorter idle time it also applies. The fix you describe addresses both problems: compute the excess from the unique bytes of all non-transient, non-in-place loose copies (the dedup inmemory()), then take the oldest eligible copies until that excess is covered.main(15024d5): not present. #452 reverted #409. The Neptune base onmainhas noVICTORY_WINDOW_BUDGET_MBand nowindow_victims. Itslet_go_idlereleases every eligible window copy once it has been idle forram_idle_ms(10 s, 5 s, or 2 s depending on free RAM), so no budget exists to be exceeded.No PR against
mainfor that reason. If the combined base is re-landed, the total-footprint accounting above should go in with it, along with a regression test that mixes held and eligible copies (as in your table: 3,072 MiB held + 1,536 MiB eligible against 2,048 MiB, where all of the eligible copies should be selected).AI use: analysis done with Claude Code (reading both revisions' source); nothing was run in game.
github-bot referenced this issue2026-11-27 00:35:39 +00:00
@KainanP on GitHub · 2026-11-27 00:11 UTC · original
This is confirmed again on the Vice-Tay base (#454 brought
VICTORY_WINDOW_BUDGET_MBback). Fix in #466. The budget is now compared with the unique bytes of every loose copy (copies in place count as 0), and the oldest eligible copies go until the total fits. Copies that have been idle for the plain sweep's time go whatever the budget, so setting a budget no longer keeps more than leaving it unset. Your 3,072 + 1,536 vs 2,048 row is a regression test. Main'swindow_victimsreturns[]for it.AI use: Claude Code.