[RAM] VICTORY_WINDOW_BUDGET_MB only accounts for eviction-eligible windows instead of total cached copies #450

Open
opened 2026-11-26 20:13:43 +00:00 by github-bot · 2 comments
Owner

@⁠FunWithFlagsDev on GitHub · 2026-11-26 20:01 UTC · original

<html>

Summary

The current implementation of VICTORY_WINDOW_BUDGET_MB appears 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: 37d4686711bbb04c2cc3825f3f13bbff7c140fb0

Component: third_party/victory/crates/victory-gpu/src/shadow.rs

Source code analysis

1. Window budget configuration

shadow.rs#L2982-L2994

The documentation describes VICTORY_WINDOW_BUDGET_MB as 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 the LOOSE map before calling window_victims().

Only resources satisfying the following conditions are included:

  • Arc::strong_count(s) == 1

  • The 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 MiB

Current 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.

  1. Calculate the unique byte footprint of the relevant cached copies.

  2. Calculate the excess above the configured budget.

  3. Select the oldest eligible resources until that excess is covered, or the eligible candidates are exhausted.

  4. Preserve existing Arc, COM reference count, idle-time and retirement safeguards.

Conceptually:

let excess = total_cached_bytes.saturating_sub(keep);
let victims = oldest_eligible_covering(&eligible, excess);

The existing diagnostic memory() function already demonstrates identity-based deduplication across the LOOSE map:

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_DECOMMIT and 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_MB is 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>## Summary

The current implementation of VICTORY_WINDOW_BUDGET_MB appears 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: 37d4686711bbb04c2cc3825f3f13bbff7c140fb0

Component: third_party/victory/crates/victory-gpu/src/shadow.rs

Source 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_MB as 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 the LOOSE map before calling window_victims().

Only resources satisfying the following conditions are included:

  • Arc::strong_count(s) == 1
  • The 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](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:

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 MiB

Current 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.

  1. Calculate the unique byte footprint of the relevant cached copies.
  2. Calculate the excess above the configured budget.
  3. Select the oldest eligible resources until that excess is covered, or the eligible candidates are exhausted.
  4. Preserve existing Arc, COM reference count, idle-time and retirement safeguards.

Conceptually:

let excess = total_cached_bytes.saturating_sub(keep);
let victims = oldest_eligible_covering(&eligible, excess);

The existing diagnostic memory() function already demonstrates identity-based deduplication across the LOOSE map:

[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:

  • 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.

  • #256 — Adaptive memory caps.
  • #350 — Host RAM reclamation through MEM_DECOMMIT and 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_MB is 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.

any008_window_budget_model.py

**@⁠FunWithFlagsDev** on GitHub · 2026-11-26 20:01 UTC · [original](https://github.com/LooperSalty/AnyXboxX/issues/450) <html> <body> <!--StartFragment--><h2><span>Summary</span></h2><p><span>The current implementation of </span><code><span>VICTORY_WINDOW_BUDGET_MB</span></code><span> appears to calculate memory pressure against eviction-eligible loose window copies only, rather than the total size of cached loose window copies.</span></p><p><span>As a result, the configured budget may already be exceeded while eligible idle resources remain unnecessarily cached.</span></p><p><span>This may contribute to avoidable host memory pressure, particularly on systems with limited RAM and GPUs with limited VRAM.</span></p><h2><span>Reviewed revision</span></h2><p><span>Commit: </span><code><span>37d4686711bbb04c2cc3825f3f13bbff7c140fb0</span></code></p><p><span>Component: </span><code><span>third_party/victory/crates/victory-gpu/src/shadow.rs</span></code></p><h2><span>Source code analysis</span></h2><h3><span>1. Window budget configuration</span></h3><p><a href="https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L2982-L2994"><span>shadow.rs#L2982-L2994</span></a></p><p><span>The documentation describes </span><code><span>VICTORY_WINDOW_BUDGET_MB</span></code><span> as an optional byte cap for loose title-window copies.</span></p><p><span>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.</span></p><h3><span>2. Eviction candidate selection</span></h3><p><a href="https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L3064-L3087"><span>shadow.rs#L3064-L3087</span></a></p><p><code><span>let_go_idle()</span></code><span> filters the </span><code><span>LOOSE</span></code><span> map before calling </span><code><span>window_victims()</span></code><span>.</span></p><p><span>Only resources satisfying the following conditions are included:</span></p><ul><li><p><code><span>Arc::strong_count(s) == 1</span></code></p></li><li><p><span>The resource has been idle for the required duration and number of frames.</span></p></li><li><p><span>The host buffer reference count is equal to one.</span></p></li></ul><p><span>These are important lifetime safeguards and should be preserved.</span></p><h3><span>3. Budget accounting</span></h3><p><a href="https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L2999-L3018"><span>shadow.rs#L2999-L3018</span></a></p><p><code><span>window_victims()</span></code><span> calculates its initial byte count exclusively from the supplied eviction candidates.</span></p><p><span>Consequently, memory occupied by active, recently used or otherwise retained windows does not contribute to the eviction decision.</span></p><p><span>The current behavior effectively limits the eligible idle subset rather than the total cached window footprint.</span></p><h2><span>Illustrative reproduction</span></h2><p><span>Assume the Watch RAM pressure band is active and the following synthetic cache state exists:</span></p> 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 MiB <p><span>Current behavior:</span></p><ul><li><p><code><span>window_victims()</span></code><span> receives only the 1,536 MiB of eligible copies.</span></p></li><li><p><span>The eligible subset is below the 2,048 MiB budget.</span></p></li><li><p><span>No resources are selected for eviction.</span></p></li><li><p><span>The total cached footprint remains 4,608 MiB.</span></p></li></ul><p><span>Expected behavior, if the budget is intended to cover total cached copies:</span></p><ul><li><p><span>Account for the full relevant cache footprint.</span></p></li><li><p><span>Select eligible idle copies until the target is reached or no eligible copies remain.</span></p></li><li><p><span>Preserve all active resources.</span></p></li></ul><p><span>In this example, up to 1,536 MiB of eligible copies could be selected for reclamation, leaving 3,072 MiB of non-evictable copies.</span></p><p><span>The target cannot always be reached safely, and that is acceptable.</span></p><p><span>These figures represent a synthetic logical reproduction, not measured in-game memory usage.</span></p><h2><span>Proposed change</span></h2><p><span>Separate budget accounting from eviction eligibility.</span></p><ol start="1"><li><p><span>Calculate the unique byte footprint of the relevant cached copies.</span></p></li><li><p><span>Calculate the excess above the configured budget.</span></p></li><li><p><span>Select the oldest eligible resources until that excess is covered, or the eligible candidates are exhausted.</span></p></li><li><p><span>Preserve existing Arc, COM reference count, idle-time and retirement safeguards.</span></p></li></ol><p><span>Conceptually:</span></p><pre><code><span>let excess = total_cached_bytes.saturating_sub(keep); let victims = oldest_eligible_covering(&amp;eligible, excess);</span></code></pre><p><span>The existing diagnostic </span><code><span>memory()</span></code><span> function already demonstrates identity-based deduplication across the </span><code><span>LOOSE</span></code><span> map:</span></p><p><a href="https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L3110-L3121"><span>shadow.rs#L3110-L3121</span></a></p><p><span>However, accounting should distinguish actual allocated copies from in-place mappings that do not allocate an additional copy of title memory.</span></p><p><span>Care should also be taken not to count aliased entries multiple times or report memory as immediately reclaimed before deferred retirement has completed.</span></p><h2><span>Existing test coverage</span></h2><p><a href="https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L5790-L5808"><span>shadow.rs#L5790-L5808</span></a></p><p><span>The existing tests cover:</span></p><ul><li><p><span>Oldest-first victim selection.</span></p></li><li><p><span>Deduplication of a copy represented under multiple keys.</span></p></li></ul><p><span>A regression test involving both eligible and non-evictable resources would help clarify the intended budget semantics.</span></p><h2><span>Preliminary verification</span></h2><p><span>The original and proposed selection policies were evaluated using an isolated Python model.</span></p><p><span>The model covered:</span></p><ul><li><p><span>Reproduction of the original accounting mismatch.</span></p></li><li><p><span>Reclamation limited to eligible resources.</span></p></li><li><p><span>Preservation of active resources.</span></p></li><li><p><span>No additional eviction below the configured budget.</span></p></li><li><p><span>Identity-based deduplication.</span></p></li><li><p><span>Compatibility when all cached resources are eligible.</span></p></li><li><p><span>Reduced budget under the High pressure band.</span></p></li></ul><p><span>Full Rust integration tests, GPU tests and in-game measurements have not been performed.</span></p><h2><span>Related work</span></h2><ul><li><p><span>#256 — Adaptive memory caps.</span></p></li><li><p><span>#350 — Host RAM reclamation through </span><code><span>MEM_DECOMMIT</span></code><span> and cold-cache trimming.</span></p></li><li><p><span>#409 — Migration to the combined VIctory base.</span></p></li></ul><p><span>This proposal concerns budget accounting and victim selection, rather than introducing a new memory allocator or replacing existing reclamation mechanisms.</span></p><h2><span>Done when</span></h2><ul><li><span><input type="checkbox" disabled=""></span><div><p><span>Clarify whether </span><code><span>VICTORY_WINDOW_BUDGET_MB</span></code><span> is intended to limit the entire relevant cache or only its eligible idle subset.</span></p></div></li><li><span><input type="checkbox" disabled=""></span><div><p><span>Add a regression test containing both active and eligible idle copies.</span></p></div></li><li><span><input type="checkbox" disabled=""></span><div><p><span>Account for unique cached allocations without double-counting aliases.</span></p></div></li><li><span><input type="checkbox" disabled=""></span><div><p><span>Distinguish actual memory copies from in-place mappings.</span></p></div></li><li><span><input type="checkbox" disabled=""></span><div><p><span>Preserve existing resource lifetime and synchronization safeguards.</span></p></div></li><li><span><input type="checkbox" disabled=""></span><div><p><span>Preserve existing behavior when the budget is disabled or the RAM pressure band is Calm.</span></p></div></li><li><span><input type="checkbox" disabled=""></span><div><p><span>Validate memory usage, cache recreation frequency and frame times under sustained streaming workloads.</span></p></div></li></ul><p><span>Is the current eligible-only accounting intentional, or should active copies contribute to the total budget used to determine reclamation pressure?</span></p><p><span>If total-cache accounting is intended, I would be interested in preparing a focused patch with regression tests.</span></p><h2><span>AI disclosure</span></h2><p><span>AI assistance (OpenAI ChatGPT) was used for static source analysis, policy modeling and drafting this report.</span></p><!--EndFragment--> </body> </html>## Summary The current implementation of `VICTORY_WINDOW_BUDGET_MB` appears 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: `37d4686711bbb04c2cc3825f3f13bbff7c140fb0` Component: `third_party/victory/crates/victory-gpu/src/shadow.rs` ## Source code analysis ### 1. Window budget configuration [[shadow.rs#L2982-L2994](https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L2982-L2994)](https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L2982-L2994) The documentation describes `VICTORY_WINDOW_BUDGET_MB` as 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](https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L3064-L3087)](https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L3064-L3087) `let_go_idle()` filters the `LOOSE` map before calling `window_victims()`. Only resources satisfying the following conditions are included: - `Arc::strong_count(s) == 1` - The 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](https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L2999-L3018)](https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/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: | 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 MiB | Current 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. 1. Calculate the unique byte footprint of the relevant cached copies. 2. Calculate the excess above the configured budget. 3. Select the oldest eligible resources until that excess is covered, or the eligible candidates are exhausted. 4. Preserve existing Arc, COM reference count, idle-time and retirement safeguards. Conceptually: ```rust let excess = total_cached_bytes.saturating_sub(keep); let victims = oldest_eligible_covering(&eligible, excess); ``` The existing diagnostic `memory()` function already demonstrates identity-based deduplication across the `LOOSE` map: [[shadow.rs#L3110-L3121](https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L3110-L3121)](https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/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](https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/shadow.rs#L5790-L5808)](https://github.com/LooperSalty/AnyXboxX/blob/37d4686711bbb04c2cc3825f3f13bbff7c140fb0/third_party/victory/crates/victory-gpu/src/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_DECOMMIT` and 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_MB` is 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. [any008_window_budget_model.py](https://github.com/user-attachments/files/35482604/any008_window_budget_model.py)
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 20:13:43 +00:00
Author
Owner

@⁠KainanP on GitHub · 2026-11-26 20:39 UTC · original

Thanks. I checked this against both revisions:

  • At 37d4686 (combined base, #409): confirmed. shadow::let_go_idle builds eligible (strong count 1, idle, COM refs 1) and passes only those entries to window_victims, which sums left from the eligible copies alone. Copies that are active or recently used never count towards VICTORY_WINDOW_BUDGET_MB. One more thing I noticed: with the budget unset, or in the Calm band, keep == u64::MAX and every eligible copy goes. In Watch/High, window_victims keeps up to keep bytes 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 in memory()), then take the oldest eligible copies until that excess is covered.
  • On current main (15024d5): not present. #452 reverted #409. The Neptune base on main has no VICTORY_WINDOW_BUDGET_MB and no window_victims. Its let_go_idle releases every eligible window copy once it has been idle for ram_idle_ms (10 s, 5 s, or 2 s depending on free RAM), so no budget exists to be exceeded.

No PR against main for 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.

**@⁠KainanP** on GitHub · 2026-11-26 20:39 UTC · [original](https://github.com/LooperSalty/AnyXboxX/issues/450#issuecomment-7202942820) Thanks. I checked this against both revisions: - **At `37d4686` (combined base, #409): confirmed.** `shadow::let_go_idle` builds `eligible` (strong count 1, idle, COM refs 1) and passes only those entries to `window_victims`, which sums `left` from the eligible copies alone. Copies that are active or recently used never count towards `VICTORY_WINDOW_BUDGET_MB`. One more thing I noticed: with the budget unset, or in the Calm band, `keep == u64::MAX` and *every* eligible copy goes. In Watch/High, `window_victims` keeps up to `keep` bytes 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 in `memory()`), then take the oldest eligible copies until that excess is covered. - **On current `main` (`15024d5`): not present.** #452 reverted #409. The Neptune base on `main` has no `VICTORY_WINDOW_BUDGET_MB` and no `window_victims`. Its `let_go_idle` releases every eligible window copy once it has been idle for `ram_idle_ms` (10 s, 5 s, or 2 s depending on free RAM), so no budget exists to be exceeded. No PR against `main` for 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._
Author
Owner

@⁠KainanP on GitHub · 2026-11-27 00:11 UTC · original

This is confirmed again on the Vice-Tay base (#454 brought VICTORY_WINDOW_BUDGET_MB back). 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's window_victims returns [] for it.

AI use: Claude Code.

**@⁠KainanP** on GitHub · 2026-11-27 00:11 UTC · [original](https://github.com/LooperSalty/AnyXboxX/issues/450#issuecomment-7206247333) This is confirmed again on the Vice-Tay base (#454 brought `VICTORY_WINDOW_BUDGET_MB` back). 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's `window_victims` returns `[]` for it. _AI use: Claude Code._
This discussion has been locked. Commenting is limited to contributors.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
github/LooperSalty--AnyXboxX#450
No description provided.