Skip to content

Profile-powered synthetic tx benchmarks (2/2)#2638

Draft
huitseeker wants to merge 24 commits intonextfrom
huitseeker/feat/synthetic-tx-benchmarks
Draft

Profile-powered synthetic tx benchmarks (2/2)#2638
huitseeker wants to merge 24 commits intonextfrom
huitseeker/feat/synthetic-tx-benchmarks

Conversation

@huitseeker
Copy link
Contributor

@huitseeker huitseeker commented Feb 3, 2026

Companion PR of 0xMiden/protocol#2391

This branch adds a synthetic transaction kernel benchmark so miden-vm can be tested without pulling in the full protocol, as discussed in issue #2256. It introduces a new benchmark crate with generators, validators, and bench targets that consume the VM profile snapshot exported by miden-base, which is treated as the only real workload benchmark. This keeps miden-vm performance testing representative while staying decoupled from protocol dependencies.

Workflow across repos:

  • Run the transaction kernel bench in miden-base and export the VM profile JSON.
  • Copy that profile into benches/synthetic-tx-kernel/profiles in miden-vm.
  • Run the synthetic benchmarks in miden-vm against that snapshot.

Add comprehensive validation and documentation to synthetic-tx-kernel
profile types based on code review feedback:

- Enhanced InstructionMix::validate() to check individual values are
  within [0.0, 1.0] range before checking sum
- Added doc comments clarifying expected formats for version fields
  (semver) and timestamp (ISO 8601)
- Documented expected HashMap key values for phases and operations
- Added unit tests covering validation, serde roundtrips, and edge
  cases (empty maps, zero cycles)

Also fixed minor clippy warnings in validator.rs:
- Added Default impl for ProfileValidator
- Used abs_diff() instead of manual subtraction

All 8 new tests pass and clippy is clean.
The PhaseProfile.operations field is defined as BTreeMap<String, u64>,
but the test code was using HashMap::new(). This caused compilation errors
when running tests. Fix by using BTreeMap consistently throughout.
- Fix profile loading to use CARGO_MANIFEST_DIR for crate-relative paths
- Remove unused CoreLibrary imports from benchmark files
- Fix duplicate CoreLibrary instantiation by creating one instance and reusing
- Add smoke test before benchmarking to validate generated code executes
- Make MASM output conditional on MASM_WRITE env var
- Replace symlink profiles/latest.json with regular file for Windows compatibility
- Improve error messages with file paths in error context
- Fix clippy warnings (default_constructed_unit_structs, unused_variables)
- Update README to remove symlink instructions
- Fix version validation to support both "1.0" and "1.0.0" formats
  (profile.rs doc comment says "major.minor.patch" format)
- Replace manual Default impl with #[derive(Default)] on ProfileValidator
- Add test for "1.0.0" version format and short "1.0" format
- Fix smoke test to use .expect() instead of .unwrap() for better error messages
- Remove unused _total_cycles_expected variable
- Change bench_program to take Program by reference to avoid unnecessary cloning
- Add MASM_WRITE environment variable documentation
- Improve error handling in latest_profile()
- Add comprehensive tolerance boundary tests for instruction mix validation
- Add test for infinity handling in profile diff serialization
- Move INSTRUCTION_MIX_TOLERANCE to associated constant
- Add explanatory comment for BTreeMap usage
- Remove redundant derive attributes from ProfileValidator
- Remove invalid use.miden::core::sys imports (not valid in simple programs)
- Remove exec.sys::truncate_stack calls (not needed without stdlib imports)
- Replace deprecated mem_storew/mem_loadw with mem_storew_be/mem_loadw_be
- Fix memory alignment (use address 0 instead of 1)
- Add actual operation implementations for component benchmarks
Implemented real Falcon512 verification in the component benchmark (with proper core library/advice inputs) and added compile-only generator tests that assemble all component benchmarks, including a verify-opcode check. Also recorded a roborev comment for job 23.

Changes:
- Emit `exec.falcon512poseidon2::verify` in the Falcon component benchmark and wire the bench to run it with real signature/advice inputs.
- Add generator tests that assemble all component benchmarks and assert the Falcon verify opcode is emitted.
Generate executable Miden assembly from VM profiles with realistic
instruction mixes. Key changes:

- Enhanced assembly generator with operation-specific code generation
- Added generate_hperm_block, generate_hmerge_block, generate_falcon_verify_block,
  generate_load_store_block, generate_arithmetic_block, generate_control_flow_block
- Falcon512 verification simulated with cycle-equivalent nested loops
- All operations are stack-balanced to prevent overflow
- Added OperationDetails struct matching miden-base profile format
- Component benchmarks use direct assembly with proper stack inputs
- All 30 tests pass, both benchmark suites run successfully
Use writeln! macro instead of push_str + format! for cleaner code:
- Add std::fmt::Write import for writeln! support
- Simplify generate_kernel() with writeln! macro
- Simplify generate_component_benchmark() with writeln! macro
- Simplify push_single_repeat_block() with writeln! macro
- Simplify push_nested_repeat_block() with writeln! macro
@huitseeker huitseeker force-pushed the huitseeker/feat/synthetic-tx-benchmarks branch from 948bf30 to 509096a Compare February 4, 2026 12:06
@huitseeker huitseeker force-pushed the huitseeker/feat/synthetic-tx-benchmarks branch from 509096a to 2fd3bd8 Compare February 4, 2026 12:41
@huitseeker huitseeker changed the title Profile-powered synthetic tx benchmarks Profile-powered synthetic tx benchmarks (2/2) Feb 10, 2026
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