Skip to content

perf(levm): Replace kzg-rs for ark-bls12-381 in point evaluation precompile #3414

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from

Conversation

gianbelinche
Copy link

@gianbelinche gianbelinche commented Jun 30, 2025

Motivation

Currently the point evaluation precompile is x4 worse than revm

Description

Replace the use of the kzg-rs crate for ark-bls12-381 to improve performance on the point evaluation precompile

Closes #3419

Copy link

Lines of code report

Total lines added: 16
Total lines removed: 0
Total lines changed: 16

Detailed view
+------------------------------------------+-------+------+
| File                                     | Lines | Diff |
+------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/precompiles.rs | 1195  | +16  |
+------------------------------------------+-------+------+

Copy link

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 3.171 ± 0.039 3.144 3.273 1.00
main_levm_BubbleSort 4.494 ± 0.006 4.482 4.501 1.42 ± 0.02
pr_revm_BubbleSort 3.195 ± 0.023 3.166 3.236 1.01 ± 0.01
pr_levm_BubbleSort 4.427 ± 0.025 4.391 4.474 1.40 ± 0.02

Benchmark Results: ERC20Approval

Command Mean [s] Min [s] Max [s] Relative
main_revm_ERC20Approval 1.055 ± 0.036 1.035 1.155 1.00
main_levm_ERC20Approval 1.586 ± 0.034 1.562 1.663 1.50 ± 0.06
pr_revm_ERC20Approval 1.057 ± 0.012 1.048 1.087 1.00 ± 0.04
pr_levm_ERC20Approval 1.543 ± 0.020 1.530 1.597 1.46 ± 0.05

Benchmark Results: ERC20Mint

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Mint 139.8 ± 1.4 138.8 143.2 1.00
main_levm_ERC20Mint 263.3 ± 2.3 259.7 266.2 1.88 ± 0.02
pr_revm_ERC20Mint 140.2 ± 1.2 139.0 142.5 1.00 ± 0.01
pr_levm_ERC20Mint 261.5 ± 2.8 258.3 266.4 1.87 ± 0.03

Benchmark Results: ERC20Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Transfer 244.0 ± 1.5 242.5 246.9 1.00
main_levm_ERC20Transfer 407.7 ± 1.6 405.6 410.9 1.67 ± 0.01
pr_revm_ERC20Transfer 249.0 ± 2.0 247.6 254.6 1.02 ± 0.01
pr_levm_ERC20Transfer 414.6 ± 10.8 403.0 435.1 1.70 ± 0.05

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Factorial 231.0 ± 1.1 229.8 233.1 1.00
main_levm_Factorial 447.5 ± 7.3 443.9 468.0 1.94 ± 0.03
pr_revm_Factorial 250.5 ± 24.4 237.7 317.1 1.08 ± 0.11
pr_levm_Factorial 451.5 ± 1.2 450.4 454.7 1.95 ± 0.01

Benchmark Results: FactorialRecursive

Command Mean [s] Min [s] Max [s] Relative
main_revm_FactorialRecursive 1.625 ± 0.020 1.583 1.642 1.00
main_levm_FactorialRecursive 2.769 ± 0.015 2.741 2.791 1.70 ± 0.02
pr_revm_FactorialRecursive 1.716 ± 0.037 1.657 1.804 1.06 ± 0.03
pr_levm_FactorialRecursive 2.760 ± 0.046 2.721 2.875 1.70 ± 0.03

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Fibonacci 206.8 ± 1.9 205.6 211.9 1.00
main_levm_Fibonacci 440.0 ± 5.4 435.1 450.0 2.13 ± 0.03
pr_revm_Fibonacci 211.4 ± 1.4 210.5 215.2 1.02 ± 0.01
pr_levm_Fibonacci 442.4 ± 3.5 439.3 451.7 2.14 ± 0.03

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ManyHashes 8.9 ± 0.1 8.8 9.0 1.00
main_levm_ManyHashes 13.7 ± 0.1 13.4 13.9 1.54 ± 0.02
pr_revm_ManyHashes 8.9 ± 0.1 8.9 9.1 1.01 ± 0.01
pr_levm_ManyHashes 13.4 ± 0.1 13.2 13.6 1.51 ± 0.02

Benchmark Results: Push

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Push 293.7 ± 0.9 292.5 295.4 1.00
main_levm_Push 1028.8 ± 3.3 1025.7 1035.8 3.50 ± 0.02
pr_revm_Push 301.5 ± 2.4 297.4 305.8 1.03 ± 0.01
pr_levm_Push 1032.8 ± 9.8 1027.5 1060.2 3.52 ± 0.04

@gianbelinche
Copy link
Author

Closing this in favor of #3172, since it has all the needed changes

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

Successfully merging this pull request may close these issues.

point evaluation precompile is slow
2 participants