Skip to content

Speed up coverage-guided execution with predecoded hevm blocks - #1661

Draft
elopez wants to merge 4 commits into
masterfrom
foundry-catchup
Draft

elopez wants to merge 4 commits into
masterfrom
foundry-catchup

Conversation

@elopez

@elopez elopez commented Nov 28, 2026

Copy link
Copy Markdown
Member

Echidna now caches predecoded bytecode across transactions and runs eligible instructions in blocks while recording coverage at every executed program counter. The remaining instructions use hevm’s single-step interpreter. This uses the block runner from hevm PR #1268, pinned at 05ce440e.

Repeated visits at the same call depth now read only the coverage depth bits. Each run also tracks its last covered position and whether coverage grew, then updates the shared coverage context once when the run ends.

Reuse bytecode analysis across transactions and allocate scratch per executing thread. Keep single-step handling for the remaining instructions. The profiled handler executed 1,934 of 1,984 instructions in the block path. Batching and indexed stack operands on earlier prototypes gained 15.57% and a further 7.43%. Those effects span both repositories. The batched-coverage and compact-scratch comparison gained 4.12% together.

(cherry picked from commit 2c9774675394c3e164748e24e2ac572d675e2146)
Hoist the frame-depth mask and read the unboxed depth column before touching the instruction index or result. With 100,000 passing handlers per seed, throughput increased from 6,789 to 7,168 calls/s, a paired median gain of 5.59% (5.06% to 5.67%). All three seeds covered 2,936 instructions.

(cherry picked from commit 8d2a42bbe6239c8ffce145d1619ffd23f2047f0f)
Carry the last covered offset and growth flag in one machine word. Reattach the shared vector once after each run. Across 3 paired native Nix release seeds the fixed passing allowance handler gained 2.55% throughput (+2.05% to +2.99%) and saved 3.18 process CPU µs/call. Median rates were 7,899 and 8,100 calls/s with assertions and coverage enabled.

(cherry picked from commit c9d4ff5750c6b7599f6e2dfad14d9ac56cf38592)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant