Single-source the MEMW_R fill and the BITWISE type↔column map#791
Merged
MauroToscano merged 1 commit intoJul 7, 2026
Merged
Conversation
MEMW_R: - Move RegRow and the direct column fill into memw_register.rs; generate_memw_register_trace is now a thin wrapper (ops -> RegRow::from_memw -> shared fill), so the unit-tested generator and the production fast path run the same code and cannot drift - RegRow::new is the single definition of the row encoding (halved address, masked old_ts_lo); the walk fast path and from_memw both delegate to it - Move the IS_HALFWORD collector next to bus_interactions() so the lookup a row sends and the lookup counted derive from the same module Routing: - Add MemwRoute + classify_memw, shared by MemwBuckets::push, the push_reg_access fallback (which now delegates to push), and count_table_lengths' partition_memw — one classification, three consumers - Drop the single-use push_register/push_register_row helpers BITWISE: - BitwiseOperationType::ALL is the single origin of NUM_LOOKUP_TYPES; type_mu_column is defined as mu_column(ALL[i]), removing the arithmetic column-contiguity assumption instead of guarding it - Replace the runtime histogram_column_map_guard test with a compile-time bijection assert (a mismatch is now a compile error, not a test failure) - Correct bump()'s comment: in release an out-of-domain z would mis-count in another lane rather than panic; constructors' masking upholds the invariant
eedf9d9 to
bf2aa3e
Compare
a0ba503 to
ae7d5d4
Compare
Base automatically changed from
review/pr786-docs-deadcode
to
perf/tracegen-cpu-optimizations
July 7, 2026 15:21
17ad034
into
perf/tracegen-cpu-optimizations
16 of 25 checks passed
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.
Second follow-up from the #786 review, stacked on #790. Removes every "keep the two in sync"-by-comment pair the optimization introduced, with no behavior change (bucket routing, trace cells, and multiplicities are unchanged).
MEMW_R
RegRowand the direct column fill move intomemw_register.rs;generate_memw_register_tracebecomes a thin wrapper (ops → RegRow::from_memw → shared fill). The unit-tested generator and the production fast path now run the same code, so they cannot drift — previously production ran an untested duplicate while the tests exercised the legacy copy.RegRow::newis the single definition of the row encoding (halved address, maskedold_ts_lo); the walk fast path andfrom_memwboth delegate to it.bus_interactions(), so the lookup each row sends and the lookup counted live in the same module.Routing
MemwRoute+classify_memwshared byMemwBuckets::push, thepush_reg_accessfallback (now delegating topush), andcount_table_lengths'partition_memw— the sizing pass and trace generation can no longer classify differently.push_register/push_register_rowhelpers.BITWISE
BitwiseOperationType::ALLis the single origin ofNUM_LOOKUP_TYPES, andtype_mu_column(i) = mu_column(ALL[i])— the arithmeticMU_MSB8 + type_idxshortcut and its column-contiguity assumption are gone rather than guarded.histogram_column_map_guardtest is replaced by a compile-time bijection assert: reorderinglookup_type_indexor forgetting to extendALLfor a new variant is now a compile error instead of a test failure someone has to remember to run.bump()'s indexing comment corrected: in release an out-of-domainzwould silently mis-count in another type's lane rather than panic (the old per-op path panicked); what actually upholds the invariant is that everyBitwiseOperationconstructor masks or debug-assertsz < 16.Testing
cargo test -p lambda-vm-prover --lib: 503 passed, includingtest_prove_verify_with_memw_registerandtest_prove_elfs_test_bitwise_8end-to-end prove+verify.test_pure_commit_rustetc.) are missing rust-guest ELF fixtures in my environment (make compile-programs-rust) — they fail at file-read before any prover code runs.cargo clippyandcargo fmt --checkclean.