feat: estimate cycles#17
Draft
not-matthias wants to merge 4 commits into
Draft
Conversation
not-matthias
commented
Jun 9, 2026
Member
- feat: add cycle estimation based on LUT
- fix(callgrind): make Capstone cycle-estimation build and link
- chore: wip [skip ci]
Merging this PR will not alter performance
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression by commenting Comparing Footnotes
|
Add callgrind/lut-gen/ (offline generators for the --cycle-estimation cost tables) and the regenerated x86_caps_lut.inc / arm64_caps_lut.inc. - lib/: sigkey.py (Python mirror of sigkey.h's packed-key contract) and gen_common.py (shared measurement parsing, collision collapse, emit). - x86/gen_x86_lut.py: Zen4-tuned table from uops.info instructions.xml. - arm64/: measured Cortex-A72 table from ocxtal/insn_bench_aarch64 via insn_bench_to_xml.py -> gen_arm64_lut.py -> merge_arm64_lut.py, with a hand-frozen guide supplement for ops insn_bench does not benchmark. - test_lut.py: validates the committed tables against the runtime keying contract and asserts sigkey.py stays in lockstep with sigkey.h.
Add the --cycle-estimation=yes runtime: decode each guest instruction with Capstone and look its reciprocal-throughput cost up in the generated cost table (x86/arm64_caps_lut.inc), accumulating a per-instruction Cy event. - cycledecode.c/.h: isolated Capstone decode + LUT lookup behind a plain-C ABI (no Valgrind tool headers, to avoid type clashes); freestanding libc shims since the tool links -nodefaultlibs. - sigkey.h: packed (insn-id, signature) key contract shared with the offline LUT generators in lut-gen/. - main.c/sim.c/bbcc.c/global.h/clo.c: wire Cy through callgrind (CLI option, EventSet, self + inclusive cost, fallback warning when an instruction has no table match). - configure.ac/Makefile.am: build cycledecode against Capstone. Emits only Cy (reciprocal throughput); no latency event.
4b2e2b7 to
22e0934
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.