fix(loader): accelerate 15-byte CLZERO loops with page-readability caching #3276
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/3278"
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 legayclightning22 on 2026-11-26T15:36:58Z.
Summary
Optimizes console-only
CLZEROloop stepping incrates/victory-loader/src/crash.rsand ensures safe handling of unmapped pages without panicking.Changes
CLZEROloop stepping (togglable viaVICTORY_CLZERO_LOOP15=0).MONITORX/MWAITX,CLWB, and SSE4AINSERTQ/EXTRQemulation intact.VICTORY_CLZERO_LOOP15flag parsing and unmapped-page loop stepping.Verification
cargo test -p victory-loader --libcargo clippy --locked -p victory-loader --all-targets -- -D warningscargo xtask policyImported from Marvisak/VIctory. Originally posted by Dukestar69 on 2026-11-26T15:49:25Z.
Review: COMMENTED
Reviewed the diff and ran local verification on Windows 11 x64 (
cargo test -p victory-loader --lib crash:: -- --test-threads=1: 28/28 passed;cargo clippy -p victory-loader --all-targets -- -D warnings: clean;cargo xtask policy: 191 files ok).I cannot approve this as-is because
clzero_page_writableintroduces a serious correctness regression with the GPU write watch:PAGE_READONLY) pages:victory-gpu's write watch (crates/victory-gpu/src/watch.rs) marks clean title-memory pagesPAGE_READONLYso that a CPU write faults into the VEH, marks the page dirty, restoresPAGE_READWRITE, and resumes. Previously,clzero'swrite_bytes(0, 64)triggered that write-watch fault normally and zeroed the memory. Withclzero_page_writable, anyPAGE_READONLYpage returnsfalsefromVirtualQueryandclzerosilently turns into a no-op — leaving stale non-zero bytes in title memory and never notifying the write watch.The 15-byte
clzeroloop was already emulated inclzero(); adding aVirtualQuerysyscall per 4 KiB page on entry actually adds overhead (and in large title poolsVirtualQuerywalks page tables to the end of the region — seecrates/victory-gpu/src/host.rslines 2476-2480).Synthetic tests only (no game files used). AI-assisted (Gemini 4 Neon).
Imported from Marvisak/VIctory. Originally posted by cloph-dsp on 2026-11-26T16:00:35Z.
Independent Windows verification. Head
15628a6, Rust 1.100.0/MSVC, worktree-local CARGO_TARGET_DIR (target-3278), no game data.cargo test --locked -p victory-loader --lib -- --exact crash::tests::clzero_loop15_switch_is_off_only_for_zero crash::tests::clzero_page_cache_remembers_recent_pages crash::tests::clzero_does_not_write_an_unmapped_page crash::tests::emulated_clzero_loop15_skips_unmapped_pages_without_panicking-> 4 passed, 0 failed, 35 filtered, exit 0.git diff --check origin/main HEADclean; all four test names absent on merge base63bcca4.AI-assisted (Hy4 flash). GPU/driver N/A (CPU-only loader tests). No game data.
Imported from Marvisak/VIctory. Originally posted by legayclightning22 on 2026-11-26T16:08:43Z.
Pushed
1adf566removingclzero_page_writable/VirtualQuerypre-checks soclzerowrites through normally without skippingPAGE_READONLYwrite-watch pages or adding per-pageVirtualQueryoverhead, while keeping safe non-panicking handling and tests passing.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.