Release idle snapshot buffers and streamline write-range tracking #108

Closed
github-bot wants to merge 0 commits from github-bot/gh-108 into main AGit
Owner

@⁠zzzz-26 on GitHub · 2026-11-30 13:02 UTC · original
zzzz-26:codex/memory-bookkeeping → main · +23 −296 · 4 files · 49 commits · closed without merging

CPU snapshots can retain allocations indefinitely after a workload spike, while repeated write declarations scan every pending range and allocate temporary vectors for each subtraction. This change expires unused snapshot buffers and keeps exact write declarations sorted for faster duplicate, coverage and completion handling.

Snapshot allocation and destruction happen outside the cache lock. Idle buffers expire after 30 seconds normally or 2 seconds under memory pressure, with at most 32 releases per sweep; checked-out snapshots remain untouched. Existing count and size limits remain. VICTORY_IDLE_TRIM=0 disables expiry.

Range tracking preserves exact declaration identities and flight counts. It uses binary search for duplicates, linear coverage traversal, and merge-based exact retirement. Existing residency pressure handling and the fence-quarantined GPU buffer cache remain unchanged. There are no launcher, shader, resolution, upscaling or frame-generation changes.

CPU benchmark

Measured on 2026-11-30, AMD Ryzen 7 7800X3D, Windows, rustc 1.98.1 (48a229cea). The standalone benchmark builds with rustc --edition=2024 -O; it calls the updated production range helpers and reproduces the previous algorithms from base 7281175 in the same executable. Each process warms both paths, alternates their measurement order across 11 samples of 20 operations, and reports the median microseconds per operation. The table below takes the median of each column across three process runs; ratios are previous/updated medians.

Case Previous µs Updated µs Ratio
coverage-disjoint-32 4.640 0.450 10.31×
declare-mixed-32 26.745 3.730 7.17×
retire-relay-32 0.325 0.155 2.10×
retire-nonrelay-32 0.275 0.160 1.72×
coverage-disjoint-256 82.560 1.060 77.89×
declare-mixed-256 1627.480 48.420 33.61×
retire-relay-256 4.250 0.750 5.67×
retire-nonrelay-256 12.240 0.775 15.79×
coverage-disjoint-1024 786.665 2.760 285.02×
declare-mixed-1024 24457.015 367.025 66.64×
retire-relay-1024 24.860 2.585 9.62×
retire-nonrelay-1024 162.165 2.890 56.11×

Coverage cases deliberately use disjoint ranges with many holes: these stress repeated subtraction and are not a representative gameplay trace. Mixed declarations include permuted sorted-vector insertions and repeated declarations (4× the range count), so insertion costs are included. Retirement includes cloning the same pending list in both paths. The relay baseline uses its existing binary search; only the non-relay baseline uses linear membership. Assertions check coverage, declarations and relay retirement against the previous implementation before timing.

These results measure CPU range bookkeeping only. They do not establish FPS gains, GPU gains, reduced process working set, or unchanged visual quality in gameplay. The pool expiry policy is covered by deterministic ownership/age/accounting tests, not a RAM-usage benchmark. No game was launched or visual comparison performed. Peak workloads and allocation churn still need gameplay evaluation; sorted-vector insertion is linear and pressure-driven expiry may require later reallocation.

Reproduce from the repository root:

rustc --edition=2024 -O scripts/bench/memory_bookkeeping.rs -o target/memory-bookkeeping.exe
./target/memory-bookkeeping.exe
cargo test -p victory-gpu --lib write_ranges --offline
cargo test -p victory-gpu --lib idle_pool --offline
cargo test -p victory-gpu --lib relay_tests --offline
cargo check -p victory-gpu --features diagnostics --offline

Raw measurements: docs/benchmarks/memory-bookkeeping-{1,2,3}.csv. All 18 focused tests passed (four range, five pool, nine relay); diagnostics compilation passed. Synthetic ignored unit benchmarks are separate from the standalone measurements above.

**@⁠zzzz-26** on GitHub · 2026-11-30 13:02 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/108) `zzzz-26:codex/memory-bookkeeping` → `main` · +23 −296 · 4 files · 49 commits · closed without merging CPU snapshots can retain allocations indefinitely after a workload spike, while repeated write declarations scan every pending range and allocate temporary vectors for each subtraction. This change expires unused snapshot buffers and keeps exact write declarations sorted for faster duplicate, coverage and completion handling. Snapshot allocation and destruction happen outside the cache lock. Idle buffers expire after 30 seconds normally or 2 seconds under memory pressure, with at most 32 releases per sweep; checked-out snapshots remain untouched. Existing count and size limits remain. `VICTORY_IDLE_TRIM=0` disables expiry. Range tracking preserves exact declaration identities and flight counts. It uses binary search for duplicates, linear coverage traversal, and merge-based exact retirement. Existing residency pressure handling and the fence-quarantined GPU buffer cache remain unchanged. There are no launcher, shader, resolution, upscaling or frame-generation changes. ### CPU benchmark Measured on 2026-11-30, AMD Ryzen 7 7800X3D, Windows, rustc 1.98.1 (48a229cea). The standalone benchmark builds with `rustc --edition=2024 -O`; it calls the updated production range helpers and reproduces the previous algorithms from base `7281175` in the same executable. Each process warms both paths, alternates their measurement order across 11 samples of 20 operations, and reports the median microseconds per operation. The table below takes the median of each column across three process runs; ratios are previous/updated medians. | Case | Previous µs | Updated µs | Ratio | |---|---:|---:|---:| | coverage-disjoint-32 | 4.640 | 0.450 | 10.31× | | declare-mixed-32 | 26.745 | 3.730 | 7.17× | | retire-relay-32 | 0.325 | 0.155 | 2.10× | | retire-nonrelay-32 | 0.275 | 0.160 | 1.72× | | coverage-disjoint-256 | 82.560 | 1.060 | 77.89× | | declare-mixed-256 | 1627.480 | 48.420 | 33.61× | | retire-relay-256 | 4.250 | 0.750 | 5.67× | | retire-nonrelay-256 | 12.240 | 0.775 | 15.79× | | coverage-disjoint-1024 | 786.665 | 2.760 | 285.02× | | declare-mixed-1024 | 24457.015 | 367.025 | 66.64× | | retire-relay-1024 | 24.860 | 2.585 | 9.62× | | retire-nonrelay-1024 | 162.165 | 2.890 | 56.11× | Coverage cases deliberately use disjoint ranges with many holes: these stress repeated subtraction and are not a representative gameplay trace. Mixed declarations include permuted sorted-vector insertions and repeated declarations (4× the range count), so insertion costs are included. Retirement includes cloning the same pending list in both paths. The relay baseline uses its existing binary search; only the non-relay baseline uses linear membership. Assertions check coverage, declarations and relay retirement against the previous implementation before timing. These results measure CPU range bookkeeping only. They do not establish FPS gains, GPU gains, reduced process working set, or unchanged visual quality in gameplay. The pool expiry policy is covered by deterministic ownership/age/accounting tests, not a RAM-usage benchmark. No game was launched or visual comparison performed. Peak workloads and allocation churn still need gameplay evaluation; sorted-vector insertion is linear and pressure-driven expiry may require later reallocation. Reproduce from the repository root: ```powershell rustc --edition=2024 -O scripts/bench/memory_bookkeeping.rs -o target/memory-bookkeeping.exe ./target/memory-bookkeeping.exe cargo test -p victory-gpu --lib write_ranges --offline cargo test -p victory-gpu --lib idle_pool --offline cargo test -p victory-gpu --lib relay_tests --offline cargo check -p victory-gpu --features diagnostics --offline ``` Raw measurements: `docs/benchmarks/memory-bookkeeping-{1,2,3}.csv`. All 18 focused tests passed (four range, five pool, nine relay); diagnostics compilation passed. Synthetic ignored unit benchmarks are separate from the standalone measurements above.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-30 13:05:28 +00:00
This reverts commit 7830d4584e.
github-bot closed this pull request 2026-12-01 01:10:30 +00:00
Author
Owner

@⁠readmet3xt-lab on GitHub · 2026-12-01 01:34 UTC · original

Thanks. On hold for measurement: the microbenchmarks are clear, but what decides it is the game itself: the PC's memory over a session and the frame time, before and after, at one place. Memory use is the subject of the next work phase, and this will be measured there.

For the rebase: please leave out the CSV files and the standalone benchmark source under docs/ and scripts/, or say why they should live in the repository.

Main's history was rewritten on 2026-12-01 (text-only changes; every commit hash changed), so a follow-up has to start from the current main, or this branch be rebased onto it.

**@⁠readmet3xt-lab** on GitHub · 2026-12-01 01:34 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/108#issuecomment-7297657916) Thanks. On hold for measurement: the microbenchmarks are clear, but what decides it is the game itself: the PC's memory over a session and the frame time, before and after, at one place. Memory use is the subject of the next work phase, and this will be measured there. For the rebase: please leave out the CSV files and the standalone benchmark source under `docs/` and `scripts/`, or say why they should live in the repository. Main's history was rewritten on 2026-12-01 (text-only changes; every commit hash changed), so a follow-up has to start from the current main, or this branch be rebased onto it.
Author
Owner

@⁠readmet3xt-lab on GitHub · 2026-12-01 01:36 UTC · original

One more note: GitHub closed this pull request by itself when main's history was rewritten, and it cannot be reopened. That is not a rejection. The points above still apply; please open a new pull request from the current main when you have them.

**@⁠readmet3xt-lab** on GitHub · 2026-12-01 01:36 UTC · [original](https://github.com/readmet3xt-lab/foxhound/pull/108#issuecomment-7297686144) One more note: GitHub closed this pull request by itself when main's history was rewritten, and it cannot be reopened. That is not a rejection. The points above still apply; please open a new pull request from the current main when you have them.

Pull request closed

This discussion has been locked. Commenting is limited to contributors.
No description provided.