Skip to content

Conversation

@xqft
Copy link
Contributor

@xqft xqft commented Dec 4, 2025

Motivation

Changing to a preallocated bitmap should:

  1. Remove reallocations due to pushing into a vec
  2. Reduce memory usage in cases of code dense in JUMPDESTs
  3. Replace the binary search (for each instruction in a bytecode) with a memory read

NOTE: This changes how bytecode is encoded, which can invalidate database stores and require resync.

before:

| Block    | Gas Used    | Steps       | Duration (s) | TP (Msteps/s) | Freq (MHz) | Clocks/step |
|----------|-------------|-------------|--------------|----------------|------------|--------------|
| 23919400 | 41,075,722  | 760,022,264 | 18.4439      | 41.2072        | 1999.0000  | 48.5109      |
| 23919500 | 40,237,085  | 798,604,814 | 18.8685      | 42.3247        | 1999.0000  | 47.2301      |
| 23919600 | 24,064,259  | 512,165,934 | 12.0746      | 42.4168        | 1999.0000  | 47.1276      |
| 23919700 | 20,862,238  | 445,582,906 | 10.5385      | 42.2815        | 1999.0000  | 47.2784      |
| 23919800 | 31,813,109  | 596,446,973 | 14.4148      | 41.3774        | 1999.0000  | 48.3114      |
| 23919900 | 22,917,739  | 428,983,514 | 10.6816      | 40.1612        | 1999.0000  | 49.7745      |
| 23920000 | 37,256,487  | 695,820,714 | 16.3619      | 42.5268        | 1999.0000  | 47.0056      |
| 23920100 | 33,542,307  | 598,535,326 | 14.1889      | 42.1834        | 1999.0000  | 47.3883      |
| 23920200 | 22,994,047  | 416,578,732 | 9.9036       | 42.0633        | 1999.0000  | 47.5236      |
| 23920300 | 53,950,967  | 986,179,450 | 23.7537      | 41.5169        | 1999.0000  | 48.1490      |

after:

| Block    | Gas Used     | Steps         | Duration (s) | TP (Msteps/s) | Freq (MHz) | Clocks/step |
|----------|--------------|---------------|--------------|----------------|------------|--------------|
| 23919400 |   41,075,722 |   756,342,305 |      18.2200 |        41.5117 |  1999.0000 |      48.1551 |
| 23919500 |   40,237,085 |   794,871,399 |      18.6598 |        42.5980 |  1999.0000 |      46.9271 |
| 23919600 |   24,064,259 |   511,850,815 |      12.2012 |        41.9510 |  1999.0000 |      47.6508 |
| 23919700 |   20,862,238 |   444,937,956 |      10.4085 |        42.7476 |  1999.0000 |      46.7629 |
| 23919800 |   31,813,109 |   595,995,687 |      14.2578 |        41.8014 |  1999.0000 |      47.8213 |
| 23919900 |   22,917,739 |   428,230,210 |      10.2245 |        41.8826 |  1999.0000 |      47.7286 |
| 23920000 |   37,256,487 |   694,857,345 |      16.3097 |        42.6039 |  1999.0000 |      46.9206 |
| 23920100 |   33,542,307 |   594,404,599 |      14.0890 |        42.1891 |  1999.0000 |      47.3819 |
| 23920200 |   22,994,047 |   415,996,975 |      10.0756 |        41.2877 |  1999.0000 |      48.4164 |
| 23920300 |   53,950,967 |   985,575,492 |      23.4603 |        42.0104 |  1999.0000 |      47.5835 |

diff in steps:

23919400: -0.4842%
23919500: -0.4675%
23919600: -0.0615%
23919700: -0.1447%
23919800: -0.0757%
23919900: -0.1756%
23920000: -0.1385%
23920100: -0.6901%
23920200: -0.1397%
23920300: -0.0612%

@github-actions github-actions bot added the L2 Rollup client label Dec 4, 2025
@github-actions
Copy link

github-actions bot commented Dec 4, 2025

Lines of code report

Total lines added: 20
Total lines removed: 0
Total lines changed: 20

Detailed view
+-------------------------------------------+-------+------+
| File                                      | Lines | Diff |
+-------------------------------------------+-------+------+
| ethrex/crates/common/rlp/decode.rs        | 660   | +7   |
+-------------------------------------------+-------+------+
| ethrex/crates/common/rlp/encode.rs        | 790   | +9   |
+-------------------------------------------+-------+------+
| ethrex/crates/common/types/account.rs     | 238   | +1   |
+-------------------------------------------+-------+------+
| ethrex/crates/storage/store_db/rocksdb.rs | 1739  | +3   |
+-------------------------------------------+-------+------+

@github-actions
Copy link

github-actions bot commented Dec 4, 2025

Benchmark Results Comparison

No significant difference was registered for any benchmark run.

Detailed Results

Benchmark Results: BubbleSort

Command Mean [s] Min [s] Max [s] Relative
main_revm_BubbleSort 2.974 ± 0.028 2.943 3.038 1.00
main_levm_BubbleSort 3.049 ± 0.077 2.980 3.249 1.03 ± 0.03
pr_revm_BubbleSort 2.978 ± 0.036 2.943 3.050 1.00 ± 0.02
pr_levm_BubbleSort 3.044 ± 0.017 3.018 3.071 1.02 ± 0.01

Benchmark Results: ERC20Approval

Command Mean [s] Min [s] Max [s] Relative
main_revm_ERC20Approval 1.001 ± 0.005 0.993 1.007 1.03 ± 0.01
main_levm_ERC20Approval 1.035 ± 0.006 1.029 1.046 1.07 ± 0.01
pr_revm_ERC20Approval 0.971 ± 0.004 0.966 0.977 1.00
pr_levm_ERC20Approval 1.071 ± 0.010 1.062 1.095 1.10 ± 0.01

Benchmark Results: ERC20Mint

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Mint 137.0 ± 1.2 135.3 138.8 1.04 ± 0.01
main_levm_ERC20Mint 153.2 ± 0.4 152.7 153.9 1.16 ± 0.01
pr_revm_ERC20Mint 131.8 ± 0.9 130.9 133.9 1.00
pr_levm_ERC20Mint 160.1 ± 1.1 158.7 162.2 1.21 ± 0.01

Benchmark Results: ERC20Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Transfer 237.2 ± 1.0 235.6 238.6 1.03 ± 0.01
main_levm_ERC20Transfer 266.8 ± 1.9 264.9 270.9 1.16 ± 0.01
pr_revm_ERC20Transfer 230.7 ± 1.1 229.9 233.9 1.00
pr_levm_ERC20Transfer 273.9 ± 2.3 269.8 277.1 1.19 ± 0.01

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Factorial 228.3 ± 1.5 225.6 229.9 1.01 ± 0.01
main_levm_Factorial 266.2 ± 21.3 254.8 318.6 1.17 ± 0.09
pr_revm_Factorial 227.0 ± 0.9 226.1 229.2 1.00
pr_levm_Factorial 252.1 ± 1.0 250.5 253.3 1.11 ± 0.01

Benchmark Results: FactorialRecursive

Command Mean [s] Min [s] Max [s] Relative
main_revm_FactorialRecursive 1.674 ± 0.040 1.606 1.735 1.00
main_levm_FactorialRecursive 8.479 ± 0.067 8.335 8.555 5.06 ± 0.13
pr_revm_FactorialRecursive 1.681 ± 0.027 1.644 1.723 1.00 ± 0.03
pr_levm_FactorialRecursive 8.449 ± 0.048 8.389 8.541 5.05 ± 0.13

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Fibonacci 206.0 ± 1.1 204.6 208.5 1.00 ± 0.01
main_levm_Fibonacci 237.5 ± 15.0 221.0 274.4 1.16 ± 0.07
pr_revm_Fibonacci 205.6 ± 1.0 204.6 207.4 1.00
pr_levm_Fibonacci 236.1 ± 13.7 224.5 273.7 1.15 ± 0.07

Benchmark Results: FibonacciRecursive

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_FibonacciRecursive 894.7 ± 9.1 885.8 908.4 1.23 ± 0.02
main_levm_FibonacciRecursive 729.0 ± 6.8 720.9 745.8 1.00 ± 0.01
pr_revm_FibonacciRecursive 907.1 ± 10.3 892.8 928.8 1.25 ± 0.02
pr_levm_FibonacciRecursive 727.9 ± 7.3 710.1 735.2 1.00

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ManyHashes 8.3 ± 0.0 8.3 8.4 1.00 ± 0.01
main_levm_ManyHashes 8.9 ± 0.1 8.8 9.1 1.07 ± 0.02
pr_revm_ManyHashes 8.3 ± 0.1 8.3 8.5 1.00
pr_levm_ManyHashes 8.9 ± 0.1 8.8 9.2 1.07 ± 0.01

Benchmark Results: MstoreBench

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_MstoreBench 258.5 ± 1.4 257.2 261.6 1.04 ± 0.01
main_levm_MstoreBench 249.9 ± 1.6 247.7 252.0 1.00 ± 0.01
pr_revm_MstoreBench 260.6 ± 5.2 256.3 272.4 1.04 ± 0.02
pr_levm_MstoreBench 249.6 ± 1.0 248.4 251.7 1.00

Benchmark Results: Push

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Push 290.6 ± 1.9 289.1 295.3 1.00 ± 0.01
main_levm_Push 307.4 ± 6.8 303.4 326.3 1.06 ± 0.02
pr_revm_Push 290.6 ± 0.7 289.6 291.9 1.00
pr_levm_Push 306.2 ± 1.8 304.5 309.6 1.05 ± 0.01

Benchmark Results: SstoreBench_no_opt

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_SstoreBench_no_opt 169.0 ± 2.1 165.9 171.6 1.87 ± 0.05
main_levm_SstoreBench_no_opt 90.7 ± 1.6 88.7 94.2 1.00 ± 0.03
pr_revm_SstoreBench_no_opt 168.5 ± 1.8 166.2 171.8 1.86 ± 0.05
pr_levm_SstoreBench_no_opt 90.5 ± 2.0 88.2 95.0 1.00

Copy link
Contributor

@Oppen Oppen left a comment

Choose a reason for hiding this comment

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

This needs to be validated in L1 too to check it doesn't regress due to increased DB IO.
It also needs to bump the schema version so users know to resync, as their DB is invalidated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

L2 Rollup client

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

3 participants