fileback, shadow: clean up orphaned cpu-mirrors .tmp files on startup #4714
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/4714"
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 trustno1-coder/VIctory-NVIDIA. Originally posted by nidea1 on 2026-12-01T03:10:27Z.
What it changes
VICTORY_CARD_CPU_FILE=1backs two-sided CPU mirrors withtempfile::tempfile_in(FILE_FLAG_DELETE_ON_CLOSE), which cleans up automatically on normal exit or process crash, but leaves orphaned.tmp*files behind incache/cpu-mirrorsafter a Windows BSOD or hard power loss. Over repeated unclean shutdowns this can accumulate thousands of stale files (gigabytes of disk space).fileback::cleanup_orphans(folder: &Path) -> (usize, u64)incrates/victory-gpu/src/fileback.rs, invoked once fromshadow::cpu_mirror_files(crates/victory-gpu/src/shadow.rs) when the mirror directory is configured.tempfile's.tmpprefix (len > 4); live mirrors held open by another running instance (tempfile::tempfile_inopens withshare_mode(0)so removal fails cleanly), directories, symlinks, and unrelated files are left untouched.How it was tested
--fg-type fsr --framegen 3), ray tracing off,VICTORY_SAMPLED_EVICT=1,VICTORY_WINDOW_GROW=1..tmp*files permanently incache/cpu-mirrors(3,700stale files /995.5 MBpresent on disk before first launch with this fix).removed orphaned file-backed CPU mirror temp files on startup removed=3700 mb=995, freeing3,700orphaned.tmp*files (995.5 MB) cleanly;cache/cpu-mirrorsstayed at0orphaned files across subsequent launches and a full 12-minute (720.7 sin-world) live soak (0crashes,0Victory errors)..tmp*cleanup, preservation of non-.tmpfiles and subdirectories, clean skipping of in-useMappedStoragehandles, and graceful handling of missing directories.cargo testpassed for the crates it touches: yes (on7c7d567c, base7d93ee0759)cargo test -j 2 -p victory-gpu --locked --lib fileback::tests: 5 passed, 0 failed (new:cleanup_orphans_removes_unlocked_tmp_files_and_preserves_other_entries,cleanup_orphans_skips_in_use_mapped_storage_without_error,cleanup_orphans_ignores_missing_folder)cargo test -j 2 -p victory-gpu --locked --lib shadow::: 84 passed, 0 failed, 6 ignoredcargo clippy -j 2 -p victory-gpu --all-targets --locked -- -D warningsand--all-features: 0 warnings on7d93ee0759(note: currentmain5fabb46ehas 5 pre-existing clippy errors infont.rs/menu.rs/panel.rsfrom#4634, tracked in#4679/#4707).cargo xtask policy: 464 files ok (--staged: 2 files ok).Checked for overlap
fileback.rs,cpu-mirrors,VICTORY_CARD_CPU_FILE, andshadow::cpu_mirror_files; no open PR touchesfileback.rsor cleans up orphanedcpu-mirrorstemp files.Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by nidea1 on 2026-12-01T12:33:45Z.
Live post-crash startup verification on
7c7d567c(RTX 3060 Ti 8 GB (ReBAR off, driver621.40), 32 GB RAM, Windows 11, Series S, DLSS Quality, FSR 3 FG, RT off,VICTORY_SAMPLED_EVICT=1,VICTORY_WINDOW_GROW=1,VICTORY_POOL_SMALL=0,VICTORY_RIPE_BLOCKS=12— 5-minute (300 sin-world,357 stotal) live validation on a combined 15-PR release build overorigin/main(5fabb46eaf).):3,701orphanedcpu-mirrorstemp files (995.6 MB) on disk before launch.#4714immediately cleaned all of them in one pass:INFO victory_gpu::fileback: removed orphaned file-backed CPU mirror temp files on startup removed=3701 mb=9950cpu-mirrorsfiles (0 MB) remaining,0Victory errors, and0nvlddmkmevents.Caveat: verified in a combined 15-PR build (5-minute opening/cell session, not an isolated A/B).
Imported from trustno1-coder/VIctory-NVIDIA. Originally posted by cloph-dsp on 2026-12-01T18:51:29Z.
Verification (independent, AI-assisted: Hy4 flash). Windows, Rust 1.100.0 (Scoop rust-msvc), MSVC, commit-scoped shallow worktree.
Base
5fabb46eaf6ed8771321787f8871051abde69b9b(current main), head7c7d567c0bebcfca538127d9f59fc5ab00d5bf88. The PR's own change is two files:crates/victory-gpu/src/fileback.rs110/0 andcrates/victory-gpu/src/shadow.rs7/1.One thing to know before the numbers: this branch sits on an older main, so a two-dot diff against today's main also shows
menu.rs,panel.rs,font.rsandREADME.mdgoing back to the pre-F1-menu state (that is the merge base difference, not part of the proposal). I therefore read and checked only the two files above; the merge itself keeps main's version of the menu files because the branch does not touch them.All three tests are new on the base (
git grep -F <name> 5fabb46e -- .exit 1 for each):cleanup_orphans_removes_unlocked_tmp_files_and_preserves_other_entries,cleanup_orphans_skips_in_use_mapped_storage_without_error,cleanup_orphans_ignores_missing_folder.git diff --check "5fabb46e..7c7d567c" -- crates/victory-gpu/src/fileback.rs crates/victory-gpu/src/shadow.rs→ no output, exit 0.Result, each:
running 1 test,test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 1201 filtered out.What they cover, from the bodies: the first builds a temp tree with two
.tmpXXXXXXXXorphans plus the near misses (.tmpbare,other.tmp, asubdir, a.tmpDirdirectory holding a nested.tmpNested, and a.tmpLinksymlink tokeep.bin), assertscleanup_orphansreturns(2, 4096 + 123)— both counts and bytes — and then that the two orphans are gone while every near miss survives. The second keeps aMappedStorageopen, fills it with a byte pattern, drops an unrelated.tmporphan beside it, and asserts cleanup returns(1, 2048), that one file remains in the folder ("live mirror file stays"), that the mapped bytes are unchanged after cleanup, and that dropping the storage leaves the folder empty. The third calls it on a path that was never created and expects(0, 0).Two caveats. The symlink arm of the first test is probed rather than required (
symlink_fileresult captured ashas_symlink), so on a machine that cannot create symlinks that assertion is skipped. Andcleanup_orphans_skips_in_use_mapped_storage_without_errorproves the file survives clean-up, not that the survival comes from the lock check rather than fromMappedStoragecreating its file under a name the scan skips — worth knowing if the file-naming rule ever changes.Temp dirs only, no title files, no device; GPU/driver N/A. No game data.
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.