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

Merged
Lewandox merged 2 commits from upstream-pr/426 into main 2026-11-26 18:31:29 +00:00
Lewandox commented 2026-11-26 18:15:00 +00:00 (Migrated from github.com)

Imported from LooperSalty/AnyXboxX. Originally posted by Lewandox on 2026-11-26T18:15:00Z.


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
<!-- greyfinch-sync:LooperSalty/AnyXboxX:issue:6632660316 --> Imported from [LooperSalty/AnyXboxX](https://github.com/LooperSalty/AnyXboxX/pull/426). Originally posted by [Lewandox](https://github.com/Lewandox) on 2026-11-26T18:15:00Z. --- ## 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`
Sign in to join this conversation.
No reviewers
No labels
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.

Reference
LooperSalty/AnyXboxX!426
No description provided.