Derive page configs without a per-byte image - #1006
Open
jotabulacios wants to merge 2 commits into
Open
jotabulacios wants to merge 2 commits into
jotabulacios wants to merge 2 commits into
Conversation
`page_configs_from_elf` built a `HashMap<u64, u8>` holding every byte of the ELF, one SipHash insert each, only to read back which pages exist and what they start as. The verifier runs it, and the recursion guest runs the verifier: it was 50.5% of that guest's cycles on a 3.95 MB ELF. Write the bytes straight into their page instead, walking each segment in page-aligned runs: one map lookup per page rather than one per byte. A segment whose base is not 4-aligned keeps the byte path, since a word can then straddle a page boundary. Order and values are what the map produced, which `page_configs_match_the_byte_image_derivation` pins against the old derivation over the repo's Rust ELFs. Worth 2 600 M guest cycles, the same in both proof layouts because the cost follows the ELF and not the proof: the monolithic proof drops 38.9%, from 6 681 722 024 to 4 082 687 027, and the batched one 49.0%.
jotabulacios
force-pushed
the
perf/page-configs-no-byte-image
branch
from
September 23, 2026 18:45
c8d9958 to
5d7a693
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.
Motivation
page_configs_from_elfanswers one question — which memory pages the programstarts with, and what is in them — and it answered it by building a
HashMap<u64, u8>with one entry per byte of the ELF, then grouping thosebytes into pages, then cloning each page's data. With
ethrex.elfthat isabout four million SipHash inserts to reorganize data the segments already
hold in order.
The verifier runs this: it does not receive the initial memory image in the
proof, it reconstructs it from the ELF to check the
PAGEtable'spreprocessed columns. And the recursion guest runs the verifier, where every
instruction is a trace row someone has to prove. On the ethrex mainnet block
it was 50.5% of the batched guest's cycles.
It is not specific to prove-and-retire: the monolithic verifier
(
prover/src/lib.rs) reaches it through the samepage_configs_from_elf_and_runtime, so the proofmainemits today pays ittoo.
Description
Write straight into the page instead. For each segment, compute how many words
fit in the current page, look that page up once, and copy the run with
copy_from_slice— one lookup per page-run rather than one per byte. Asegment whose base is not 4-aligned keeps the byte path, because a word can
then straddle a page boundary.
into_iter()moves eachVec<u8>into itsPageConfig, so the final clone is gone as well.The result has to be identical, not equivalent — this is a verifier path.
Ascending bases (
BTreeMapiterates sorted, as theBTreeSetdid), lastwrite wins inside a segment run, and partial pages zero-filled. The
else { zero_init(base) }arm that disappears was dead:page_basescamefrom
init_page_data.keys().build_initial_imageitself stays — six othercallers use it.
page_configs_match_the_byte_image_derivationruns both derivations over theRust ELF artifacts and compares page count, bases and init values.
Results
Recursion guest cycles on the ethrex mainnet block (blowup 2, 219 queries),
measured on
vm-benchmarks-1with the same input blob on both sides:mainemits)Keccak call counts are identical on both sides — 3,963,993 batched,
11,803,481 monolithic — so the two runs do the same work and only the path to
it changed. Native verification moves little: the derivation is a small share
of a 6 s host verify.
(¹) The monolithic figure is from a run that also carried the keccak-state fix
(#1000); that fix is worth 8.2% of the batched guest, so essentially all of
this delta is the page derivation.
For the batched path the ordering changes with it: without this fix the
batched guest costs 5.31 G against continuations' 4.65 G, and with it 2.70 G —
42% below continuations instead of 14% above.
How to test
cargo test --release -p lambda-vm-prover page_configs_match_the_byte_image_derivationNeeds the Rust ELF artifacts (
make compile-programs-rust); the test skipsany it cannot read and fails if it found none.