Skip to content

feat: use memmap instead of paged_vecs on platforms that support it#1734

Merged
jonathanpwang merged 54 commits into
feat/new-executionfrom
feat/new-execution-mmap
Jun 25, 2025
Merged

feat: use memmap instead of paged_vecs on platforms that support it#1734
jonathanpwang merged 54 commits into
feat/new-executionfrom
feat/new-execution-mmap

Conversation

@pjabbarzade

@pjabbarzade pjabbarzade commented Jun 12, 2025

Copy link
Copy Markdown
Contributor

@github-actions

This comment has been minimized.

@codspeed-hq

codspeed-hq Bot commented Jun 12, 2025

Copy link
Copy Markdown

CodSpeed WallTime Performance Report

Merging #1734 will improve performances by 44.58%

Comparing feat/new-execution-mmap (bb09764) with feat/new-execution (6446607)

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

⚡ 20 improvements

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark_execute[bubblesort] 330.4 ms 166.4 ms +98.57%
benchmark_execute[factorial_iterative_u256] 742.4 ms 443.8 ms +67.28%
benchmark_execute[fibonacci_iterative] 351.6 ms 174.3 ms ×2
benchmark_execute[fibonacci_recursive] 447.6 ms 223 ms ×2
benchmark_execute[keccak256] 343.6 ms 165.5 ms ×2.1
benchmark_execute[keccak256_iter] 489.7 ms 247.2 ms +98.1%
benchmark_execute[quicksort] 352.6 ms 171.7 ms ×2.1
benchmark_execute[revm_snailtracer] 279.6 ms 139.5 ms ×2
benchmark_execute[sha256] 335.7 ms 166.5 ms ×2
benchmark_execute[sha256_iter] 500.2 ms 263.2 ms +90.1%
benchmark_execute_metered[bubblesort] 429.8 ms 243.5 ms +76.52%
benchmark_execute_metered[factorial_iterative_u256] 1,098.4 ms 759.7 ms +44.58%
benchmark_execute_metered[fibonacci_iterative] 489.2 ms 301.5 ms +62.24%
benchmark_execute_metered[fibonacci_recursive] 601.5 ms 369.8 ms +62.66%
benchmark_execute_metered[keccak256] 455 ms 249.9 ms +82.08%
benchmark_execute_metered[keccak256_iter] 681.5 ms 429.4 ms +58.69%
benchmark_execute_metered[quicksort] 458.4 ms 262.6 ms +74.58%
benchmark_execute_metered[revm_snailtracer] 290.5 ms 140.4 ms ×2.1
benchmark_execute_metered[sha256] 445.5 ms 249.2 ms +78.76%
benchmark_execute_metered[sha256_iter] 698.1 ms 441.4 ms +58.13%

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@codspeed-hq

codspeed-hq Bot commented Jun 13, 2025

Copy link
Copy Markdown

CodSpeed Instrumentation Performance Report

Merging #1734 will improve performances by 11.69%

Comparing feat/new-execution-mmap (b647e68) with feat/new-execution (70ae977)

Summary

⚡ 20 improvements

Benchmarks breakdown

Benchmark BASE HEAD Change
benchmark_execute[bubblesort] 1.6 s 1.1 s +45.43%
benchmark_execute[factorial_iterative_u256] 4.1 s 3.2 s +30.38%
benchmark_execute[fibonacci_iterative] 1.6 s 1.1 s +48.05%
benchmark_execute[fibonacci_recursive] 2.2 s 1.5 s +42.81%
benchmark_execute[keccak256] 1.7 s 1.2 s +44.91%
benchmark_execute[keccak256_iter] 2.5 s 1.8 s +36.95%
benchmark_execute[quicksort] 1.8 s 1.2 s +44.06%
benchmark_execute[revm_snailtracer] 910.5 ms 541.5 ms +68.14%
benchmark_execute[sha256] 1.7 s 1.2 s +43.84%
benchmark_execute[sha256_iter] 2.8 s 2.1 s +32.91%
benchmark_execute_metered[bubblesort] 2.6 s 2.1 s +19.97%
benchmark_execute_metered[factorial_iterative_u256] 7.1 s 6.4 s +11.69%
benchmark_execute_metered[fibonacci_iterative] 2.6 s 2.2 s +20.87%
benchmark_execute_metered[fibonacci_recursive] 3.5 s 3 s +18%
benchmark_execute_metered[keccak256] 2.9 s 2.4 s +19.46%
benchmark_execute_metered[keccak256_iter] 4.1 s 3.5 s +16.67%
benchmark_execute_metered[quicksort] 2.9 s 2.4 s +19.08%
benchmark_execute_metered[revm_snailtracer] 925.9 ms 540.7 ms +71.25%
benchmark_execute_metered[sha256] 2.9 s 2.4 s +19.22%
benchmark_execute_metered[sha256_iter] 4.5 s 3.9 s +14.86%

@github-actions

This comment has been minimized.

@pjabbarzade pjabbarzade force-pushed the feat/new-execution-mmap branch from dde8c9e to a5f3b04 Compare June 16, 2025 00:46
@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.

@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.

@github-actions

This comment has been minimized.

@pjabbarzade pjabbarzade force-pushed the feat/new-execution-mmap branch from 59b5653 to c4dbe6d Compare June 17, 2025 15:32
@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.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@jonathanpwang jonathanpwang added run-benchmark triggers benchmark workflows on the pr run-benchmark-e2e labels Jun 17, 2025
@pjabbarzade pjabbarzade force-pushed the feat/new-execution-mmap branch from 7ad7a35 to fa49d91 Compare June 17, 2025 23:34
Comment thread crates/continuations/src/verifier/leaf/mod.rs Outdated
Comment thread crates/vm/Cargo.toml Outdated
Comment thread .github/workflows/cli.yml Outdated
Comment thread crates/vm/src/arch/config.rs Outdated
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@jonathanpwang

Copy link
Copy Markdown
Contributor

The micro-benchmarks have a much higher tracegen time because the memory image to clone for the initial merkle tree is now bigger. This is only a significant factor because the microbenchmarks have such small memory allocated.

Introduce a `LinearMemory` trait to clarify the API of underlying memory
implementations:
- mmap based
- remove `PagedVec` and implement a simple `Vec` backed `BasicMemory`

The trait functions are chosen to mirror `core::ptr::*` functions. I
updated the safety documentation and also made some small optimizations
to use `core::ptr::read` and `core::ptr::swap` when appropriate. One
side-effect is that `write` functions should now take the data by value
and not reference once again.

@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

The sdk and cli tests are now very slow, maybe we can increase the test-threads a bit if the OOM is not a concern.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

For each address space, find where the last nonzero value is and only
use that prefix in `memory_to_vec_partition`
@github-actions

This comment was marked as outdated.

Use the new `MerkleTree` struct instead.

Note the construction of the initial memory image and also the user
public values proof both reconstructs the Merkle Tree from scratch --
this is slow.
@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@github-actions

This comment was marked as outdated.

@jonathanpwang

Copy link
Copy Markdown
Contributor

The merkle memory finalization is slower in micro-benchmarks, and there are ways to address this (notably the merkle tree construction can be updated to directly use a segment tree now). However to avoid making this PR balloon even more and also to prevent merge conflicts, we will merge it first.

@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 (+171 [+13.6%]) 1,426 322,699 17,340,154 - - -
fibonacci (+395 [+18.2%]) 2,565 1,500,277 50,589,503 3,604 1,248,092 69,834,746
regex (+674 [+9.9%]) 7,489 4,165,432 166,519,456 10,659 3,349,040 228,918,339
ecrecover (+542 [+48.2%]) 1,666 137,260 8,151,353 11,193 2,934,925 241,888,862
pairing (+595 [+16.1%]) 4,302 1,862,964 97,508,739 5,515 2,010,485 134,810,861

Commit: bb09764

Benchmark Workflow

@jonathanpwang jonathanpwang merged commit 77983f5 into feat/new-execution Jun 25, 2025
34 checks passed
@jonathanpwang jonathanpwang deleted the feat/new-execution-mmap branch June 25, 2025 01:19
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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants