perf(victory-gpu): reuse fault_buf and shrink oversized refused set in memory #426

Manually merged
github merged 2 commits from github-bot/gh-426 into main 2026-11-26 18:35:11 +00:00 AGit
Owner

@⁠Lewandox on GitHub · 2026-11-26 18:15 UTC · original
Lewandox:perf/memory-reuse-fault-buf-and-shrink-refused → main · +48 −3 · 1 files · 2 commits · merged 2026-11-26 18:31 UTC

Summary

Reduces per-frame heap churn and cleans up stale heap/refused-page retention in third_party/victory/crates/victory-gpu/src/memory.rs:

  1. Zero-allocation steady-state take_faults():
    • Previously take_faults() unconditionally created a fresh Vec, scanned all MEMORY_FAULTS, and only avoided allocation because Vec::new() is lazy; now tracks a reusable fault_buf: Vec<u32> on Memory (shrunk if oversized) so fault bursts do not reallocate per frame.
  2. Reclaim oversized refused set capacity on frame rollover:
    • When m.refused grows large during loading spikes (scanning root constants that are not title memory), clearing it on the next frame now calls shrink_to(256) so peak HashSet bucket tables are not retained forever.
  3. Unit tests:
    • Adds unit test clear_refused_reclaims_oversized_capacity_and_keeps_warm_set verifying clear_refused reclaims oversized HashSet capacity while preserving small warm capacity.

Verification

  • cargo test -p victory-gpu --lib memory::tests (default and --features diagnostics)
  • cargo xtask policy inside third_party/victory
**@⁠Lewandox** on GitHub · 2026-11-26 18:15 UTC · [original](https://github.com/LooperSalty/AnyXboxX/pull/426) `Lewandox:perf/memory-reuse-fault-buf-and-shrink-refused` → `main` · +48 −3 · 1 files · 2 commits · merged 2026-11-26 18:31 UTC ## Summary Reduces per-frame heap churn and cleans up stale heap/refused-page retention in `third_party/victory/crates/victory-gpu/src/memory.rs`: 1. **Zero-allocation steady-state `take_faults()`**: - Previously `take_faults()` unconditionally created a fresh `Vec`, scanned all `MEMORY_FAULTS`, and only avoided allocation because `Vec::new()` is lazy; now tracks a reusable `fault_buf: Vec<u32>` on `Memory` (shrunk if oversized) so fault bursts do not reallocate per frame. 2. **Reclaim oversized `refused` set capacity on frame rollover**: - When `m.refused` grows large during loading spikes (scanning root constants that are not title memory), clearing it on the next frame now calls `shrink_to(256)` so peak `HashSet` bucket tables are not retained forever. 3. **Unit tests**: - Adds unit test `clear_refused_reclaims_oversized_capacity_and_keeps_warm_set` verifying `clear_refused` reclaims oversized `HashSet` capacity while preserving small warm capacity. ## Verification - `cargo test -p victory-gpu --lib memory::tests` (default and `--features diagnostics`) - `cargo xtask policy` inside `third_party/victory`
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 18:16:44 +00:00
github manually merged commit c3cc02932f into main 2026-11-26 18:35:11 +00:00
This discussion has been locked. Commenting is limited to contributors.
No description provided.