Skip to content

perf(new-execution): use page-based approach for merkle tree metering#1770

Merged
jonathanpwang merged 14 commits into
feat/new-executionfrom
feat/new-exec-fix-e2-merkle-hashmap
Jun 23, 2025
Merged

perf(new-execution): use page-based approach for merkle tree metering#1770
jonathanpwang merged 14 commits into
feat/new-executionfrom
feat/new-exec-fix-e2-merkle-hashmap

Conversation

@shuklaayush

@shuklaayush shuklaayush commented Jun 20, 2025

Copy link
Copy Markdown
Collaborator
  • Replace the vector of leaf indices with a BitSet of page indices
  • Update merkle tree chip height based on page faults
  • Fix merkle tree metering when continuations is disabled
  • Fix access adapter metering on finalization
  • Delete test_segmentation_retry since it's not relevant now

Towards INT-4068

@codspeed-hq

codspeed-hq Bot commented Jun 20, 2025

Copy link
Copy Markdown

CodSpeed WallTime Performance Report

Merging #1770 will improve performances by 36.24%

Comparing feat/new-exec-fix-e2-merkle-hashmap (8488120) with feat/new-execution (b0b892f)

⚠️ 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

⚡ 4 improvements
✅ 16 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark_execute_metered[bubblesort] 475.4 ms 417.9 ms +13.74%
benchmark_execute_metered[keccak256] 594.6 ms 437.1 ms +36.04%
benchmark_execute_metered[quicksort] 543.8 ms 440.1 ms +23.58%
benchmark_execute_metered[sha256] 597.9 ms 438.8 ms +36.24%

@github-actions

This comment has been minimized.

@codspeed-hq

codspeed-hq Bot commented Jun 20, 2025

Copy link
Copy Markdown

CodSpeed Instrumentation Performance Report

Merging #1770 will improve performances by 16.4%

Comparing feat/new-exec-fix-e2-merkle-hashmap (8d3bfdf) with feat/new-execution (8730118)

Summary

⚡ 3 improvements
✅ 17 untouched benchmarks

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark_execute_metered[keccak256] 2.8 s 2.4 s +16.31%
benchmark_execute_metered[quicksort] 2.8 s 2.5 s +11.78%
benchmark_execute_metered[sha256] 2.8 s 2.4 s +16.4%

@shuklaayush shuklaayush force-pushed the feat/new-exec-fix-e2-merkle-hashmap branch from 4ef0470 to 8d3bfdf Compare June 20, 2025 13:43
@github-actions

This comment has been minimized.

@shuklaayush shuklaayush changed the title fix: use hashmap in e2 and o(1) updates fix: use fxhashmap in e2 and o(1) updates Jun 20, 2025
@shuklaayush shuklaayush force-pushed the feat/new-exec-fix-e2-merkle-hashmap branch from 6dae7f2 to ba1e9a3 Compare June 20, 2025 14:27
@shuklaayush shuklaayush changed the title fix: use fxhashmap in e2 and o(1) updates fix: use fxhashmap in e2 for o(1) updates Jun 20, 2025
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@shuklaayush shuklaayush changed the title fix: use fxhashmap in e2 for o(1) updates perf(new-execution): use page-based approach for merkle tree metering Jun 20, 2025
@shuklaayush shuklaayush force-pushed the feat/new-exec-fix-e2-merkle-hashmap branch from 759ec11 to 65af708 Compare June 20, 2025 20:50
@shuklaayush shuklaayush marked this pull request as ready for review June 20, 2025 20:53
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

}
}

// TODO(ayush): can segmentation also be triggered by timestamp overflow? should that be tracked?

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.

the interaction bound is always stricter than timestamp overflow, so timestamp overflow does not need to be tracked

@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, although we would still prefer if we could skip the page approach altogether (I'm assuming you tried this one first since it was faster to implement)

Comment thread crates/vm/src/arch/execution_mode/metered/ctx.rs Outdated
@jonathanpwang jonathanpwang merged commit 5eba513 into feat/new-execution Jun 23, 2025
26 of 27 checks passed
@jonathanpwang jonathanpwang deleted the feat/new-exec-fix-e2-merkle-hashmap branch June 23, 2025 02:52
@github-actions

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 (-20 [-1.6%]) 1,270 322,642 17,339,470 - - -
fibonacci (+37 [+1.7%]) 2,214 1,500,277 50,589,503 - - -
regex 6,821 4,165,432 166,519,456 - - -
ecrecover (+6 [+0.5%]) 1,160 137,260 8,151,353 - - -
pairing 3,914 1,862,964 97,508,739 - - -

Commit: 8488120

Benchmark Workflow

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.

2 participants