Repository navigation
Console CPU instructions: no VirtualQuery at every emulated instruction - #306
Conversation
emulate_console_only asked `readable` about the code at rip twice at every exception, and is_writable asked about the target of every CLZERO and CLZERO loop. VirtualQuery walks a region to its end to size it: the title's code section for rip, and for a title's memset a committed window of unified memory (gpu/uma.rs notes ~40 ms a call on a 4 GiB one). On an Intel CPU a retail title's main thread was in that query in every thread dump taken, and the title showed half a frame a second. - The page rip is on is taken as there - the instruction that raised the exception was fetched from it - and only code bytes on the next page are asked about (code_bytes_at). - A committed window of unified memory is not asked about, as in gpu::shader::readable, which the single CLZERO used before ivall#217. What the emulation does is unchanged. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
|
Tested Tested
Not tested
AI use: Claude Code with Claude Opus 5.5 (ran the tests and wrote this report). |
|
Reviewed The saving, measured. Scratch tests calling the same functions on
Checked for a stale answer
Optional, covers 2 and 3: The PR's test passes on the merge. It also passes on Tested
Not tested
🤖 Claude Fable 5.2 |
|
Merged (2b4bb43). Checked on an RX 9070 (RDNA4) on main 2b4bb43 together with #306, #288 and #294: |
On an Intel CPU the newer retail title of the README shows about half a frame a second on
main. Its main thread zeroes memory with CLZERO, and every emulated instruction asks Windows about memory:readabletwice about the code atrip, andis_writableabout the target of every CLZERO loop.VirtualQuerywalks a region to its end to size it – the title's code section forrip, and for the title's memset a committed window of unified memory (gpu/uma.rsnotes ~40 ms a call on a 4 GiB one). This takes those queries out. Part of #184.What the emulation does is unchanged: the loop's semantics are #290 / #295 and the
is_writableguards are planned in #278; none of them changes what the queries cost, and the hunks here are other lines.What is in it
crates/xcl/src/eh.rs,code_bytes_at: the pageripis on is taken as there, since the instruction that raised the exception was fetched from it; only code bytes on the next page are asked about. Testcode_bytes_on_the_instructions_page_are_not_asked_about(also: a CLZERO in the last bytes of a page with nothing mapped after it is still emulated).crates/xcl/src/eh.rs,is_writable: a committed window of unified memory is not asked about (uma::in_committed_window), as ingpu::shader::readable, which the single CLZERO used before perf(insn): CLZERO loop fast-forwarding and CLWB NOP hot-patching #217.Tested
hardware: Intel Core i7-7700K (4 cores / 8 threads; no CLZERO, CLWB or MWAITX), 16 GB RAM, NVIDIA GeForce RTX 5080 (driver 610.47), Windows 10 22H2 (19045), rustc 1.100.0
stable-x86_64-pc-windows-msvc; debug for the tests, release for the title.cargo build --workspace && cargo test --workspace -- --test-threads=4ona99f64c: 652 passed, 0 failed, 40 ignored (SKIPPED GPU tests:gpu_wave32_program_in_wave64_hardware,gpu_geometry_wave32_prefix_count_over_a_mask– no wave64).game checked: the newer retail title of the README,
scripts/smoke.ps1for 60 s, the two builds alternating on the same warm shader cache. Frames shown:main9ab7d76/2953c11, this commit before its rebase)0e946cf/a99f64c, the blocks below)Every run ended by itself with exit 0, no crash and no device removal.
On
main(60565c4) three thread dumps of three runs had the title's main thread inVirtualQueryunder XCL's illegal-instruction handler.Regression run
main:
PR:
Not tested
rip: not measured separately.is_writablehas no unit test (it needs the process's unified memory); the title runs go through it.VirtualQuerya loop.AI use
Duplicate check before opening (2026-11-23 22:49 UTC,
main0e946cf): read #217, #227, #234, #253, #290, #295 and issue #278.🤖 Generated with Claude Code