GPU saved-page reuse with a 4 MiB idle limit #3720
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3720"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Imported from Marvisak/VIctory. Originally posted by lmouz823-lang on 2026-11-28T11:16:50Z.
Summary
Reuse the 64 KiB pre-write snapshots in
watch::Savedthrough an exclusiveSavedPageowner. The idle pool holds at most 64 pages, or 4 MiB of page payload. Live pages stay owned by their tracker or the marked copy-back consumer.This implements the returned-buffer follow-up described in #3262. The scope is
Changed::savepage buffers. Coordination claimThe kernel read runs under the same arming/first-save lock. Cold page allocation, the kernel read and excess-page deallocation run outside the pool lock.
taken,disarm, tracker destruction and consumer early returns release their owners throughDrop. The submitted diff is one file, 189 additions and 3 deletions.Evidence
Windows 11 build 26200, Intel Core i9-14900HX, 64 GiB installed RAM, NVIDIA GeForce RTX 4060 Laptop GPU with driver 32.0.16.1088, Rust 1.98.1 MSVC, release profile, locked dependencies. Base
63bcca43c6a00a758510398fa43096ce7e4f7df0. Validated source commitabd2895ce98d5cdfd7dee6e35e5b86eede2107f7. Submittedwatch.rsSHA25621c07dadf155201deffdd92b879deed7c36355199e64a062b2d98912acaf8d62.Synthetic cost comparison
I ran 12 alternating A/B and B/A process pairs with the same appended harness. Each process uses 3 warm-up rounds and 20 measured rounds for each workload. Timing covers actual guarded writes, snapshot consumption, owner drop and disarm. Tracker take/arm happens before the timed window. For each workload, the table reports the median across the 12 per-process round-time medians. Allocation and process-page-fault columns are medians of per-process totals across the 20 measured rounds.
The harness counts Rust allocation layouts of exactly 64 KiB and delegates every operation to
System. It records Windows process page faults. The baseline prints both workloads and intentionally fails its final warm-zero-allocation assertion with exit 101. The pooled version passes. These are synthetic memory-tracking measurements. Gameplay frame-time impact is unmeasured.The benchmark source and binaries retain their actual hashes. A later Clippy correction moved a SAFETY comment inside an assertion macro in a new regression test. Independent comparison confirmed that this is the only source difference from the archived benchmark production code. The final submitted source was separately package-cleaned, rebuilt and rerun.
Final acceptance
The final default-feature build compiled
victory-gpuin 15.40 seconds, and the diagnostics build in 19.21 seconds.watch::tests::, default and diagnosticsshadow::, default NVIDIA, diagnostics NVIDIA, diagnostics WARPThe two NVIDIA failures are
descriptor::host::tests::dynamic_slots_are_held_until_releasedandmemory::tests::lists_share_a_table_and_copies_keep_their_views. I also built an independent, completely unmodified checkout of the exact main revision. Each exact test reproduces the same assertion and exit 101 there, after a fresh 56.82-second build. They are the descriptor-heap-cap assumptions reported in #3178.The one ignored case is
object::tests::benchmark_private_data_release, declared as a synthetic release benchmark requiring--release --ignored --nocapture. It was omitted from the final crate runs. Gameplay, AMD hardware, other operating systems and the full workspace suite were outside this validation.The four added tests cover detached owners across tracker cleanup, two trackers and cross-page refresh, failed partial reads followed by a complete snapshot, idle capacity/live-owner uniqueness, and four concurrent guarded writers. A separate isolated consumer probe verified the normal marked copy-back early return after a partial decommit and the page's subsequent return to the pool. Device/LUID and consumer probes established actual NVIDIA and WARP execution. Those temporary probes were removed and
shadow.rsrestored byte-for-byte before the final rebuild.Two targeted controls detected failure to recycle dropped buffers and publication after a failed read. The original valid-page test continued to pass under those deliberate mutations. The mutations were removed before final acceptance.
Default and diagnostics all-target checks and Clippy with
-D warnings, the 191-file asset-policy check, new-code formatting,git diff --checkand forward/reverse patch checks passed. Whole-file Rustfmt exits 1 on both main and this source, with the same 39 pre-existing hunks and the same ordered formatting edits, 199 added and 46 removed lines.For the WARP diagnostics run, set
VICTORY_D3D12_WARP=1. Clear it for native hardware. The default and diagnostics all-target Clippy commands use the same feature selections.Temporary synthetic cost harness and reproduction
Append the following block to
watch.rsin two isolated checkouts, one at the base revision and one with this patch. Use separate Cargo target directories. Build each withcargo test --release --locked -p victory-gpu --lib --no-runand retain its executable separately. Restore the source after collecting the benchmark binaries.Run each executable with the arguments below. Alternate baseline/pool and pool/baseline order for 12 pairs. The harness prints all 20 sorted timing samples for each workload. Use the average of the two middle samples as each process median, then the median across its 12 processes.
Merge Danger
Door Two-way. Reverting restores per-save allocation.
Blast Radius Tracking. This runs in guarded first-write handling and marked copy-back. The exclusive owner protects the pre-write comparison data while consumers run. Idle page payload is capped at 4 MiB.
AI assistance from Codex covered implementation, tests, execution and this report. Independent Standards and Spec reviews checked the frozen source and evidence.
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-28T11:38:22Z.
Independent local verification (Windows, Rust 1.100.0/MSVC, no game data):
abd2895ce98d5cdfd7dee6e35e5b86eede2107f7, base/parent63bcca43c6a00a758510398fa43096ce7e4f7df0.cargo test --locked -p victory-gpu --lib -- watch::tests::detached_saved_pages_keep_their_bytes_after_tracker_cleanup --exact --test-threads=1 --quiet→ 1 passed, 0 failed, 235 filtered, exit 0 (2 pre-existing warnings in thevictory-gpulib test build).git grep -Ffor the test name on the base returned no match (test is new on this PR);git diff --check 63bcca4 HEADclean (1 file, +189/-3).CARGO_TARGET_DIR(never shared) withCARGO_BUILD_JOBS=2.AI-assisted (Hy4 flash).
View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.