fix: count every loose window copy against VICTORY_WINDOW_BUDGET_MB #466

Open
github-bot wants to merge 1 commit from github-bot/gh-466 into main AGit
Owner

@⁠KainanP on GitHub · 2026-11-27 00:11 UTC · original
KainanP:fix/window-budget-total → main · +87 −27 · 1 files · 1 commits · open

Fixes #450.

The bug, on the Vice-Tay base (b6d86cf8)

#454 brought the window budget back (VICTORY_WINDOW_BUDGET_MB, in shadow.rs), and the problem FunWithFlagsDev found on the combined base is there too.

  1. Only eligible copies were counted. let_go_idle() filters LOOSE down to the copies that can go (strong count 1, idle for idle_ms and 4 frames, COM references 1). window_victims() then compared the budget with the bytes of those copies alone. Copies held by a list or a slot, or used recently, never counted. In the issue's row (3,072 MiB held plus 1,536 MiB idle against a 2,048 MiB budget), nothing went.
  2. A budget kept more than having none. With no budget, or in the Calm band, every eligible copy goes. In Watch or High, only the eligible bytes over the budget went, so idle copies that the plain sweep would release stayed whenever they fit under the budget.

Both are confirmed against main's window_victims. The issue's row gives [] where all three idle copies should go, and two due copies under a budget they fit in give [] where the sweep without a budget releases both.

The change

  • The budget is compared with the unique bytes of every loose copy, eligible or not (loose_bytes, deduplicated by copy identity like the diagnostic memory()). The oldest eligible copies go until that total fits or none are left. Copies that can't go stay; the target isn't always reachable, and that's accepted.
  • Copies in place (crate::inplace) hold no copy of their own, so they count as 0 bytes (copy_bytes). They're never chosen to meet the budget, but they still go once due.
  • Copies that have been idle for the time the sweep uses without a budget (ram_idle_ms) are marked due and go whatever the budget, so a budget never keeps more than no budget would. The band's shorter idle time (10 s in Watch, 2 s in High) only adds candidates for meeting the budget.
  • A copy that stands under several keys goes under all of them. Before, only one key was removed while its bytes were counted as freed. In practice the strong_count == 1 filter keeps such a copy out of the eligible list, but the accounting now matches what it frees.

Behaviour changes

  • VICTORY_WINDOW_BUDGET_MB unset, or the Calm band: unchanged.
  • Watch or High with a budget: more idle window copies go, namely the ones over the budget counted against all copies, plus every copy idle for the plain sweep's time. Nothing that is held or recently used goes; the eligibility checks are unchanged. The cost is more window copies made and copied again if the title comes back to them soon.
  • Mapped windows (window_mapped_for, card memory the CPU writes) count as copies, the same as before. Only in-place ones are excluded.

Tests (rule 5)

shadow::window_tests:

  • window_budget_counts_the_copies_that_cannot_go: the issue's row. 3,072 held + 1,536 idle against 2,048 MiB means all idle copies go; against 4,096 MiB only the oldest goes; under the budget nothing goes.
  • window_budget_never_keeps_what_the_sweep_lets_go_without_one: due copies go even when everything fits; over the budget the rest go oldest first.
  • window_budget_passes_over_copies_in_place.
  • The two existing tests run on the new signature. window_budget_counts_one_copy_under_several_keys_once now expects the shared copy under both of its keys ([0, 1] instead of [0]), for the reason above.

The first two encode cases that main's window_victims gets wrong (checked with a throwaway test on main: [] for both).

Run here (RTX 4060 Laptop GPU, Intel UHD iGPU, WARP):

result
cargo test -p victory-gpu --lib --release --features diagnostics, RTX 480 passed in 38 of 40 full runs (25 in a row). Two runs had one failure each in a watch.rs write-watch timing test (what_is_put_in_beside_the_guards_is_told_at_every_view, no_write_is_lost_with_port_7), and both passed on rerun. watch.rs isn't touched here; main shows the same kind of failure (nothing_is_guarded_between_our_forgetting_it_and_its_unmapping, 1 in 112 runs)
same, VICTORY_D3D12_ADAPTER=Intel 480 passed
same, VICTORY_D3D12_WARP=1 480 passed
cargo clippy -p victory-gpu --lib --tests no new warnings (the same overlay.rs one as main)
cargo xtask policy 285 files ok
cargo build --release --workspace --exclude anyxboxx-launcher ok

No launcher-visible change: the launcher sets no window budget.

Asking for an A/B

The budget only acts in the Watch and High RAM bands, so the useful run is on a machine that gets there. That means 16 GB of RAM, or an 8 GB card where Windows spills into shared memory. If you have one, please run with VICTORY_WINDOW_BUDGET_MB set (for example 2048) on main and on this branch, and compare private bytes and commit, how many window copies go and are made again (sweep: trail lines, the memory line), and frame times (VICTORY_FRAMETIME_DUMP=1).

Credit: FunWithFlagsDev for the analysis and the test row in #450. Thanks to akimfomin for the review of the memory work on #449.

AI use: code, tests and this description written with Claude Code; tests run locally on RTX, Intel UHD and WARP; nothing was run in game.

🤖 Generated with Claude Code

**@⁠KainanP** on GitHub · 2026-11-27 00:11 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/466) `KainanP:fix/window-budget-total` → `main` · +87 −27 · 1 files · 1 commits · open Fixes #450. ## The bug, on the Vice-Tay base (`b6d86cf8`) #454 brought the window budget back (`VICTORY_WINDOW_BUDGET_MB`, in `shadow.rs`), and the problem FunWithFlagsDev found on the combined base is there too. 1. **Only eligible copies were counted.** `let_go_idle()` filters `LOOSE` down to the copies that can go (strong count 1, idle for `idle_ms` and 4 frames, COM references 1). `window_victims()` then compared the budget with the bytes of those copies alone. Copies held by a list or a slot, or used recently, never counted. In the issue's row (3,072 MiB held plus 1,536 MiB idle against a 2,048 MiB budget), nothing went. 2. **A budget kept more than having none.** With no budget, or in the Calm band, every eligible copy goes. In Watch or High, only the eligible bytes *over* the budget went, so idle copies that the plain sweep would release stayed whenever they fit under the budget. Both are confirmed against main's `window_victims`. The issue's row gives `[]` where all three idle copies should go, and two due copies under a budget they fit in give `[]` where the sweep without a budget releases both. ## The change - The budget is compared with the **unique bytes of every loose copy**, eligible or not (`loose_bytes`, deduplicated by copy identity like the diagnostic `memory()`). The oldest **eligible** copies go until that total fits or none are left. Copies that can't go stay; the target isn't always reachable, and that's accepted. - Copies **in place** (`crate::inplace`) hold no copy of their own, so they count as 0 bytes (`copy_bytes`). They're never chosen to meet the budget, but they still go once due. - Copies that have been idle for the time the sweep uses without a budget (`ram_idle_ms`) are marked `due` and go whatever the budget, so a budget never keeps more than no budget would. The band's shorter idle time (10 s in Watch, 2 s in High) only adds candidates for meeting the budget. - A copy that stands under several keys goes under all of them. Before, only one key was removed while its bytes were counted as freed. In practice the `strong_count == 1` filter keeps such a copy out of the eligible list, but the accounting now matches what it frees. ### Behaviour changes - `VICTORY_WINDOW_BUDGET_MB` unset, or the Calm band: **unchanged**. - Watch or High with a budget: more idle window copies go, namely the ones over the budget counted against all copies, plus every copy idle for the plain sweep's time. Nothing that is held or recently used goes; the eligibility checks are unchanged. The cost is more window copies made and copied again if the title comes back to them soon. - Mapped windows (`window_mapped_for`, card memory the CPU writes) count as copies, the same as before. Only in-place ones are excluded. ## Tests (rule 5) `shadow::window_tests`: - `window_budget_counts_the_copies_that_cannot_go`: the issue's row. 3,072 held + 1,536 idle against 2,048 MiB means all idle copies go; against 4,096 MiB only the oldest goes; under the budget nothing goes. - `window_budget_never_keeps_what_the_sweep_lets_go_without_one`: due copies go even when everything fits; over the budget the rest go oldest first. - `window_budget_passes_over_copies_in_place`. - The two existing tests run on the new signature. `window_budget_counts_one_copy_under_several_keys_once` now expects the shared copy under both of its keys (`[0, 1]` instead of `[0]`), for the reason above. The first two encode cases that main's `window_victims` gets wrong (checked with a throwaway test on main: `[]` for both). Run here (RTX 4060 Laptop GPU, Intel UHD iGPU, WARP): | | result | |---|---| | `cargo test -p victory-gpu --lib --release --features diagnostics`, RTX | 480 passed in 38 of 40 full runs (25 in a row). Two runs had one failure each in a `watch.rs` write-watch timing test (`what_is_put_in_beside_the_guards_is_told_at_every_view`, `no_write_is_lost_with_port_7`), and both passed on rerun. `watch.rs` isn't touched here; main shows the same kind of failure (`nothing_is_guarded_between_our_forgetting_it_and_its_unmapping`, 1 in 112 runs) | | same, `VICTORY_D3D12_ADAPTER=Intel` | 480 passed | | same, `VICTORY_D3D12_WARP=1` | 480 passed | | `cargo clippy -p victory-gpu --lib --tests` | no new warnings (the same `overlay.rs` one as main) | | `cargo xtask policy` | 285 files ok | | `cargo build --release --workspace --exclude anyxboxx-launcher` | ok | No launcher-visible change: the launcher sets no window budget. ## Asking for an A/B The budget only acts in the Watch and High RAM bands, so the useful run is on a machine that gets there. That means 16 GB of RAM, or an 8 GB card where Windows spills into shared memory. If you have one, please run with `VICTORY_WINDOW_BUDGET_MB` set (for example 2048) on `main` and on this branch, and compare private bytes and commit, how many window copies go and are made again (`sweep:` trail lines, the memory line), and frame times (`VICTORY_FRAMETIME_DUMP=1`). Credit: FunWithFlagsDev for the analysis and the test row in #450. Thanks to akimfomin for the review of the memory work on #449. _AI use: code, tests and this description written with Claude Code; tests run locally on RTX, Intel UHD and WARP; nothing was run in game._ 🤖 Generated with [Claude Code](https://claude.com/claude-code)
In the Watch and High RAM bands the window budget was compared with the
bytes of the copies eligible to go (idle, held by the table alone) only.
Copies held by a list or a slot, or used lately, never counted, so with
3,072 MiB held and 1,536 MiB idle against a 2,048 MiB budget nothing went.
And because only the eligible bytes above the budget went, setting a
budget kept idle copies that the sweep without one lets go.

Now:
- the budget is compared with the unique bytes of every loose copy
  (loose_bytes; a copy in place holds none of its own, copy_bytes), and
  the oldest eligible copies go until that total fits or none are left;
- copies idle for the time the sweep uses without a budget (ram_idle_ms)
  go whatever the budget, so a budget never keeps more than none;
- a copy that stands under several keys goes under all of them.
Unset budget and the Calm band are unchanged. The eligibility checks
(strong count, COM references, idle time and frames) are unchanged.

Tests: the issue's row (3,072 held + 1,536 idle against 2,048: all idle
copies go; against 4,096: only the oldest), due copies going under a
budget everything fits, copies in place passed over, and the two existing
window_victims tests on the new signature (the shared-key copy now goes
under both keys).

Analysis by FunWithFlagsDev (#450).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-27 00:35:40 +00:00
Author
Owner

@⁠akimfomin on GitHub · 2026-11-27 01:17 UTC · original

PortBridge checked this head against the pinned receiving main 5a08a334ef216eff98d2c7d9a9166f94c9ef70ed: Git reports a clean merge, with shadow.rs as the only changed file. For the one-change A/B I kept your merge base b6d86cf8 separate from that later receiving commit.

PortBridge Lab #109 now has your synthetic test and the Watch/High-only acceptance criteria. I shared it with a Vice-Tay reporter who already measured the separate 16 GB RAM throttle. There is no new hardware result yet. If a volunteer submits one, I'll return the aggregates here with their attribution.

**@⁠akimfomin** on GitHub · 2026-11-27 01:17 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/466#issuecomment-7207175840) PortBridge checked this head against the pinned receiving main `5a08a334ef216eff98d2c7d9a9166f94c9ef70ed`: Git reports a clean merge, with `shadow.rs` as the only changed file. For the one-change A/B I kept your merge base `b6d86cf8` separate from that later receiving commit. [PortBridge Lab #109](https://github.com/akimfomin/PortBridge/issues/109#issuecomment-7207139616) now has your synthetic test and the Watch/High-only acceptance criteria. I shared it with a Vice-Tay reporter who already measured the separate 16 GB RAM throttle. There is no new hardware result yet. If a volunteer submits one, I'll return the aggregates here with their attribution.
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/466/head:github-bot/gh-466'
git switch 'github-bot/gh-466'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-466'
git switch 'github-bot/gh-466'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-466'
git switch 'github-bot/gh-466'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-466'
git switch 'main'
git merge --squash 'github-bot/gh-466'
git switch 'main'
git merge --ff-only 'github-bot/gh-466'
git switch 'main'
git merge 'github-bot/gh-466'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.