fix(loader): accelerate 15-byte CLZERO loops with page-readability caching #3278
No reviewers
Labels
No labels
accessibility
area: build
area: formats
area: gpu
area: loader
area: runtime
area: shader
bug
documentation
duplicate
enhancement
good first issue
gpu: amd
gpu: intel
gpu: nvidia
help wanted
host: wine
invalid
out of scope
question
request
run report
triage: confirmed
triage: has patch
triage: merge candidate
triage: needs info
triage: needs rebase
triage: needs work
triage: proposed close
wontfix
No milestone
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github/Marvisak--VIctory!3278
Loading…
Reference in a new issue
No description provided.
Delete branch "github-bot/gh-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?
@legayclightning22 on GitHub · 2026-11-26 15:36 UTC · original
legayclightning22:fix/clzero-and-console-insn-emulation→main· +228 −5 · 1 files · 1 commits · openSummary
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 policy@Dukestar69 on GitHub · 2026-11-26 15:49 UTC · original · reviewed
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).
@cloph-dsp on GitHub · 2026-11-26 16:00 UTC · original
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.
15628a6949to1adf566d53@legayclightning22 on GitHub · 2026-11-26 16:08 UTC · original
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.