xtajit64: batch Unicorn context transfers on Apple Silicon - #15
xtajit64: batch Unicorn context transfers on Apple Silicon#15jungwuk-ryu wants to merge 4 commits into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 743f2c8312
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| python3 dlls/xtajit64/provider_tests/check_syscall_register_batching.py \ | ||
| dlls/xtajit64/unixlib.c |
There was a problem hiding this comment.
Add the missing syscall batching scripts before invoking them
On every pull request touching dlls/xtajit64/**, this step invokes check_syscall_register_batching.py, but the reviewed tree contains neither that file nor the subsequently invoked run_syscall_register_hotpath.sh (a repository-wide git grep finds only these YAML references). Python therefore exits with a missing-file error before the benchmark starts, making the new workflow fail for every matching PR; add both scripts or remove their invocations.
Useful? React with 👍 / 👎.
Summary
uc_reg_write()calls with oneuc_reg_write_batch()calluc_reg_read()calls with oneuc_reg_read_batch()callMotivation
write_context()andread_context()execute on theBeginSimulationboundary. The previous implementation crossed the Unicorn dylib/API dispatch boundary once for every register. This change keeps that dispatch and register-routing setup outside the per-register loop, reducing a complete write/read boundary from 71 Unicorn API calls to 2.This is deliberately measurement-driven: optimize a proven hot boundary, preserve semantics, and reject instruction-level substitutions that do not improve measured Apple Silicon performance.
Native Apple Silicon measurements
Environment for every result below:
macos-26-arm64Apple M1 (Virtual)8028ec436f2d9376525352dd38ed9ed6b9f6be10-O3benchmark buildThe virtualized M1 runner has visible run-to-run noise, so this PR does not treat one sample as a stable absolute latency. All independent native-arm64 measurements preserve the same result: batching wins, while the structural API-boundary reduction is deterministic at 71 calls → 2 calls.
The result is intentionally scoped. It measures the Unicorn register-transfer portion of a full context write/read boundary, not total translated-application runtime, and does not claim that the complete transition executes in 1 ns.
Validation
write_context()andread_context()each use exactly one batch API boundarypython3 -m py_compilebash -nfor the benchmark and provider-concurrency scriptsgit diff --checkxtajit64 Apple Silicon hot pathsPR workflow: passing on the original run and rerunCommit structure
xtajit64: batch Unicorn context transferstest: add Apple Silicon context-transfer benchmarkci: benchmark xtajit64 context batching on Apple SiliconRejected alternative
A separate experiment replaced EC-bitmap integer division with a shift derived from the power-of-two page size. On the same Apple Silicon runner it regressed the isolated classifier from 1.407 ns to 1.516 ns, so it is deliberately not included.
Unrelated repository check
The repository-wide
Source integrityworkflow currently fails in the pre-existingswitchyard/tests/build_runtime_failure_propagation_test.shcheck withnested failure returned 0 instead of 1. The exact failure also occurs on PR #14, which predates and does not contain this change. The dedicated native-arm64 contracts and benchmark for this PR pass.