perf(insn): CLZERO loop fast-forwarding and CLWB NOP hot-patching #214
Loading…
Reference in a new issue
No description provided.
Delete branch "upstream-pr/217"
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 ivall/xcl. Originally posted by Jefter5549 on 2026-11-23T21:12:47Z.
Follow-up to #151 with performance and safety improvements for non-Zen / older host CPUs:
• CLZERO loop fast-path: titles emit 12-byte unrolled loops (
clzero; add rax, 0x40; cmp rax, <reg>; jb -12) during heap allocations. Emulating 64 bytes per exception generates an exception storm (18,000+ VEH round-trips/s).insn::decodenow recognizes this 12-byte pattern (ConsoleOnly::ClzeroLoop { end_reg }), clears[rax..end)in one burst viawrite_bytes, and steps past the loop (+12 bytes).• CLWB NOP hot-patching: hot-patches the instruction bytes with NOPs (
0x90) viaVirtualProtect. Host memory caches are coherent, eliminating repeated exception overhead across subsequent frames and update loops.• Memory writability check:
is_writablechecksMEM_COMMITandPAGE_READWRITE/PAGE_EXECUTE_READWRITEviaVirtualQuerybeforewrite_bytesto prevent taking an unhandled AV inside the VEH.• MWAITX: added
std::hint::spin_loop()hint.• Crash diagnostics: include volatile scratch registers
r10andr11inunhandled_filter.upstream-sync referenced this pull request2026-11-24 06:57:54 +00:00
Imported from ivall/xcl. Originally posted by ivall on 2026-11-23T21:24:21Z.
Merged (main
d4f17ca). Checked on an RX 9070 (RDNA4) with 11 PRs merged together on mainaf20b4b:cargo build --workspace && cargo test --workspace -- --test-threads=4- 605 unit tests passed, 0 failed (20 ignored), the integration and e2e tests passed; and the retail game still reaches its first menu at 30 fps (720 draws per 2 s).upstream-sync referenced this pull request2026-11-24 23:06:49 +00:00