Skip to content

Trace-gen cleanup: single MU-column source, simpler push_reg_access, tighter visibility, stale docs#795

Open
MauroToscano wants to merge 1 commit into
perf/tracegen-cpu-optimizationsfrom
review/pr786-cleanup
Open

Trace-gen cleanup: single MU-column source, simpler push_reg_access, tighter visibility, stale docs#795
MauroToscano wants to merge 1 commit into
perf/tracegen-cpu-optimizationsfrom
review/pr786-cleanup

Conversation

@MauroToscano

Copy link
Copy Markdown
Contributor

Cleanup bundle from #786's final review (findings #1/#3/#4/#7/#8). No behavior change; prove+verify pass byte-identical.

#1 — one source of truth for the MU-column map (bitwise.rs)

The compile-time guard proved ALL ↔ lookup_type_index is a bijection but did not cover mu_column itself, so a future typo mapping two lookup types to the same MU column would be silently lossy under fill_multiplicities' overwrite semantics (and diverge from update_multiplicities, which increments). Now a single const MU_COLUMNS: [usize; NUM_LOOKUP_TYPES] in lookup_type_index order is the only type→column source; mu_column/type_mu_column both read from it, and a const _ assert checks the entries are pairwise distinct — a duplicate column is now a build error. Also deletes the second 10-arm match.

#7 — simpler push_reg_access (trace_builder.rs)

Was 8 loose scalars (val0/val1/old0/old1 among them) plus a build_fallback closure repeated at 3 call sites, needing #[allow(clippy::too_many_arguments)]. Now takes val: [u32;2], old: [u32;2] (kills the transposition footgun — a swapped arg would silently write a wrong trace cell) and a shared build_reg_fallback builds the op internally. Verified byte-for-byte against the old closures: reads pass val==old==reg_value, the write passes val=reg_value, old=old_value; the fallback packs [v0,v1,0,…] which is identical since pack_register_value already zeroes indices 2–7.

#8 — tighter visibility (bitwise.rs, memw_register.rs)

BitwiseHistogram + its methods and the MU-column/lookup-type helpers (mu_column, lookup_type_index, NUM_LOOKUP_TYPES, BitwiseOperationType::ALL) are internal to the prover crate → pub(crate) (grep-verified no cross-crate use). The MemwOperation-based generate_memw_register_trace had only test callers → #[cfg(test)] (production uses generate_memw_register_trace_from_rows).

#3, #4 — stale docs

MemwSink's Vec impl is used by the count_table_lengths sizing pass, not "tests/scratch"; generate_bitwise_trace's MU columns are filled by fill_multiplicities, not update_multiplicities (which now only tops up the continuation L2G path).

Testing

cargo test -p lambda-vm-prover --lib: 502 passed (only the 5 known missing rust-guest ELF fixtures fail, at file-read). make lint, clippy --all-targets, fmt --check clean.

Independent of #794 (the parallelism ABBA PR); both branch off perf.

…tighter visibility, stale docs

- BITWISE MU columns now derive from one `MU_COLUMNS` array with a
  compile-time distinctness assert, so a duplicate column is a build
  error rather than a silent overwrite in fill_multiplicities.
- push_reg_access takes [u32;2] val/old pairs and builds its own
  fallback op instead of an 8-scalar signature plus a repacking closure.
- Narrow BitwiseHistogram + the MU-column/lookup-type helpers to
  pub(crate); scope the test-only generate_memw_register_trace wrapper.
- Fix stale docs (MemwSink Vec impl is the sizing pass, not tests;
  generate_bitwise_trace MU columns are filled by fill_multiplicities).
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