Skip to content

Commit d1c2d16

Browse files
authored
[witness gene] optimize StepRecord only copy once (#1250)
### design rationales previous flow: tracer generate steprecord -> dispatch steprecord to respective witness table now: tracer generate steprecord -> dispatch steprecord index only -> each table take step record index then fetch from steprecord it improves the performance to avoid per record copy twice within memory due to the ownership taken. ### benchmark tested on `23817600` `generate_witness` | Shard | master (s) | optimized (s) | Improvement (%) | |-------|------------|----------------|------------------| | 0 | 6.88 | 4.13 | 39.97% | | 1 | 3.97 | 2.83 | 28.72% | | 2 | 3.72 | 2.85 | 23.39% | | 3 | 3.66 | 2.83 | 22.68% | | 4 | 2.80 | 2.19 | 21.79% | | 5 | 2.37 | 1.99 | 16.03% | | 6 | 4.34 | 4.42 | -1.84% | | 7 | 6.40 | 3.78 | 40.94% | | 8 | 5.94 | 3.76 | 36.64% | | 9 | 5.69 | 3.83 | 32.69% | | 10 | 5.78 | 3.85 | 33.38% | | 11 | 3.80 | 2.72 | 28.42% | | 12 | 3.57 | 2.66 | 25.49% | | 13 | 3.51 | 2.59 | 26.21% |
1 parent 30381b6 commit d1c2d16

38 files changed

+563
-286
lines changed

ceno_emul/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ pub use platform::{CENO_PLATFORM, Platform};
1010

1111
mod tracer;
1212
pub use tracer::{
13-
Change, FullTracer, LatestAccesses, MemOp, NextAccessPair, NextCycleAccess, PreflightTracer,
14-
PreflightTracerConfig, ReadOp, ShardPlanBuilder, StepCellExtractor, StepRecord, Tracer,
15-
WriteOp,
13+
Change, FullTracer, FullTracerConfig, LatestAccesses, MemOp, NextAccessPair, NextCycleAccess,
14+
PreflightTracer, PreflightTracerConfig, ReadOp, ShardPlanBuilder, StepCellExtractor, StepIndex,
15+
StepRecord, Tracer, WriteOp,
1616
};
1717

1818
mod vm_state;

ceno_emul/src/test_utils.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ pub fn keccak_step() -> (StepRecord, Vec<Instruction>) {
2424
Default::default(),
2525
);
2626
let mut vm = VMState::new(CENO_PLATFORM.clone(), program.into());
27-
let steps = vm.iter_until_halt().collect::<Result<Vec<_>>>().unwrap();
27+
vm.iter_until_halt().collect::<Result<Vec<_>>>().unwrap();
28+
let steps = vm.tracer().recorded_steps();
2829

2930
(steps[2].clone(), instructions)
3031
}

0 commit comments

Comments
 (0)