Skip to content

chore: Optimistic E3 Execution for Poseidon2 Chip#1896

Merged
jonathanpwang merged 1 commit into
feat/new-executionfrom
chore/e3-poseidon
Aug 1, 2025
Merged

chore: Optimistic E3 Execution for Poseidon2 Chip#1896
jonathanpwang merged 1 commit into
feat/new-executionfrom
chore/e3-poseidon

Conversation

@nyunyunyunyu

@nyunyunyunyu nyunyunyunyu commented Jul 24, 2025

Copy link
Copy Markdown
Contributor

Add a flag to execute E3 optimistically. When the flag is enabled, verify_batch skips all verification logic and postpone all poseidon2 hash computation to the tracegen phase.

Reth-benchmark shows 20% execution time reduction. Tracegen time slightly increases but the increment is less than the saving.

Close INT-4374

Per opcode stats on my laptop(variance is large but we could see a significant difference):

Before:

GROUP FREQUENCY TOTAL EXEC TIME AVG TIME Percentage
ADD 599175 46411254 77.46 9.30%
BBE4DIV 19534 7959238 407.46 1.60%
BBE4MUL 52005 9243036 177.73 1.85%
COMP_POS2 27 53917 1,996.93 0.01%
DIV 2184 390832 178.95 0.08%
FE4ADD 27755 3580894 129.02 0.72%
FE4SUB 6709 1523758 227.12 0.31%
FRI_REDUCED_OPENING 17500 47049340 2,688.53 9.43%
HINT_STOREW 54961 6639322 120.80 1.33%
JAL 20264 1670740 82.45 0.33%
LOADW 332530 56095576 168.69 11.25%
MUL 146789 11367159 77.44 2.28%
NativeBranchEqualOpcode(BEQ) 8951 570160 63.70 0.11%
NativeBranchEqualOpcode(BNE) 151700 10170358 67.04 2.04%
PERM_POS2 1968 3516015 1,786.59 0.70%
PHANTOM 16541 1531674 92.60 0.31%
PUBLISH 36 16165 449.03 0.00%
RANGE_CHECK 26909 1374440 51.08 0.28%
STOREW 72946 10643024 145.90 2.13%
SUB 61182 7812138 127.69 1.57%
VERIFY_BATCH 2700 271206706 100,446.93 54.37%
    498825746   100.00%

After:

GROUP FREQUENCY TOTAL EXEC TIME AVG TIME Percentage
ADD 599175 50,137,976 83.68 11.65%
BBE4DIV 19534 10,487,243 536.87 2.44%
BBE4MUL 52005 11,279,418 216.89 2.62%
COMP_POS2 27 109,915 4,070.93 0.03%
DIV 2184 502,509 230.09 0.12%
FE4ADD 27755 4,140,336 149.17 0.96%
FE4SUB 6709 1,979,492 295.05 0.46%
FRI_REDUCED_OPENING 17500 57,441,000 3,282.34 13.34%
HINT_STOREW 54961 9,498,320 172.82 2.21%
JAL 20193 1,504,236 74.49 0.35%
LOADW 332530 60,762,686 182.73 14.12%
MUL 146789 12,791,836 87.14 2.97%
NativeBranchEqualOpcode(BEQ) 8951 662,178 73.98 0.15%
NativeBranchEqualOpcode(BNE) 151700 10,591,935 69.82 2.46%
PERM_POS2 1968 4,060,309 2,063.17 0.94%
PHANTOM 16541 2,082,586 125.90 0.48%
PUBLISH 36 233,085 6,474.58 0.05%
RANGE_CHECK 26909 1,326,437 49.29 0.31%
STOREW 72946 10,698,539 146.66 2.49%
SUB 61182 9,573,439 156.47 2.22%
VERIFY_BATCH 2700 170,589,925 63,181.45 39.63%
    430,453,400   100.00%

@nyunyunyunyu nyunyunyunyu added run-benchmark triggers benchmark workflows on the pr run-benchmark-e2e labels Jul 24, 2025
@codspeed-hq

codspeed-hq Bot commented Jul 24, 2025

Copy link
Copy Markdown

CodSpeed WallTime Performance Report

Merging #1896 will not alter performance

Comparing chore/e3-poseidon (b98c4a3) with feat/new-execution (ffc9f3e)

⚠️ Unknown Walltime execution environment detected

Using the Walltime instrument on standard Hosted Runners will lead to inconsistent data.

For the most accurate results, we recommend using CodSpeed Macro Runners: bare-metal machines fine-tuned for performance measurement consistency.

Summary

✅ 24 untouched benchmarks

@github-actions

This comment has been minimized.

@nyunyunyunyu nyunyunyunyu marked this pull request as ready for review July 25, 2025 00:30
@github-actions

This comment has been minimized.

Comment thread extensions/native/circuit/src/poseidon2/chip.rs Outdated
Comment thread extensions/native/circuit/src/poseidon2/chip.rs Outdated
@jonathanpwang

Copy link
Copy Markdown
Contributor

Please provide an update on the measured time in insn/s of just verifybatch before and after this PR

@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Aug 1, 2025

Copy link
Copy Markdown
group app.proof_time_ms app.cycles app.cells_used leaf.proof_time_ms leaf.cycles leaf.cells_used
verify_fibair (-9 [-0.8%]) 1,055 322,700 17,672,408 - - -
fibonacci 2,110 3,000,420 51,503,521 2,932 1,248,029 70,625,644
regex 6,894 8,217,194 163,669,874 8,656 3,326,693 234,118,948
ecrecover (+23 [+2.1%]) 1,138 274,568 8,596,011 9,951 2,934,871 246,667,012
pairing (+99 [+2.7%]) 3,714 3,725,930 93,105,105 4,361 2,010,448 138,831,313
fib_e2e 19,462 24,000,420 410,933,023 16,196 7,462,555 435,494,883
kitchen_sink 14,392 309,192 899,580,290 21,492 7,952,478 748,994,058

Commit: b98c4a3

Benchmark Workflow

Comment thread extensions/native/circuit/src/poseidon2/chip.rs
let mut row_idx = 0;
let mut row_slice = trace.values.as_mut_slice();
let mut chunk_start = Vec::new();
while row_idx < rows_used {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe you could have used RecordSeeker for this, not sure

@jonathanpwang jonathanpwang left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@jonathanpwang jonathanpwang merged commit 9086b77 into feat/new-execution Aug 1, 2025
32 checks passed
@jonathanpwang jonathanpwang deleted the chore/e3-poseidon branch August 1, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

run-benchmark triggers benchmark workflows on the pr run-benchmark-e2e

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants