Skip to content

Conversation

edg-l
Copy link
Contributor

@edg-l edg-l commented Sep 29, 2025

Motivation

Description

Closes #issue_number

image

@edg-l edg-l changed the title simple signed remaining gas perf(levm): simple signed remaining gas Sep 29, 2025
@github-actions github-actions bot added levm Lambda EVM implementation performance labels Sep 29, 2025
Copy link

github-actions bot commented Sep 29, 2025

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/call_frame.rs             | 354   | +4   |
+-----------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/execution_handlers.rs     | 123   | +3   |
+-----------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/opcode_handlers/system.rs | 802   | +5   |
+-----------------------------------------------------+-------+------+
| ethrex/crates/vm/levm/src/vm.rs                     | 456   | +4   |
+-----------------------------------------------------+-------+------+

Copy link

github-actions bot commented Sep 29, 2025

Benchmark Block Execution Results Comparison Against Main

Command Mean [s] Min [s] Max [s] Relative
base 87.833 ± 0.710 86.865 89.181 1.01 ± 0.01
head 87.289 ± 0.405 86.745 87.993 1.00

// EIP-2200
let gas_left = self.current_call_frame.gas_remaining;
if gas_left <= SSTORE_STIPEND {
if gas_left as u64 <= SSTORE_STIPEND {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe just change SSTORE_STIPEND to be i64.

Copy link
Contributor

@JereSalo JereSalo left a comment

Choose a reason for hiding this comment

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

This will work for real use cases but gas should theoretically be 64 bits according to the protocol, so we have to decide whether to stop supporting cases in which gas is larger than 63 bits or not.

@edg-l
Copy link
Contributor Author

edg-l commented Sep 30, 2025

This will work for real use cases but gas should theoretically be 64 bits according to the protocol, so we have to decide whether to stop supporting cases in which gas is larger than 32 bits or not.

Agree, thats why the pr is in draft yet, we need to. decide for example whether we enforce a maximum gas limit below i64::max

@MegaRedHand
Copy link
Collaborator

EIP-7825 comes in Fusaka, limiting the gas limit per transaction to 2^24. I think it's safe to use i64 here, even i32, given that a tx with a bigger gas limit never happened before and won't happen after Fusaka.

@JereSalo
Copy link
Contributor

EIP-7825 comes in Fusaka, limiting the gas limit per transaction to 2^24. I think it's safe to use i64 here, even i32, given that a tx with a bigger gas limit never happened before and won't happen after Fusaka.

Yeah that's right, just have to make sure to skip related tests and comment why. We should also add a comment above the i64 variable definition justifying briefly why we use i64 and not u64 in case somebody doesn't know

@edg-l edg-l marked this pull request as ready for review October 1, 2025 10:16
@edg-l edg-l requested a review from a team as a code owner October 1, 2025 10:16
@edg-l edg-l moved this from Todo to In review in ethrex_performance Oct 1, 2025
Copy link

github-actions bot commented Oct 1, 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 4.788 ± 0.020 4.775 4.844 1.04 ± 0.01
main_levm_BubbleSort 4.610 ± 0.019 4.590 4.642 1.00
pr_revm_BubbleSort 4.842 ± 0.025 4.813 4.888 1.05 ± 0.01
pr_levm_BubbleSort 4.636 ± 0.028 4.601 4.678 1.01 ± 0.01

Benchmark Results: ERC20Approval

Command Mean [s] Min [s] Max [s] Relative
main_revm_ERC20Approval 1.551 ± 0.008 1.540 1.567 1.00
main_levm_ERC20Approval 1.660 ± 0.072 1.626 1.864 1.07 ± 0.05
pr_revm_ERC20Approval 1.561 ± 0.012 1.547 1.581 1.01 ± 0.01
pr_levm_ERC20Approval 1.638 ± 0.007 1.630 1.652 1.06 ± 0.01

Benchmark Results: ERC20Mint

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Mint 184.9 ± 0.9 183.9 186.8 1.00
main_levm_ERC20Mint 196.9 ± 3.7 194.5 205.4 1.07 ± 0.02
pr_revm_ERC20Mint 185.8 ± 0.7 185.2 187.4 1.01 ± 0.01
pr_levm_ERC20Mint 197.8 ± 3.2 195.0 203.3 1.07 ± 0.02

Benchmark Results: ERC20Transfer

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ERC20Transfer 351.3 ± 0.7 350.5 352.3 1.00
main_levm_ERC20Transfer 383.3 ± 2.6 380.8 387.2 1.09 ± 0.01
pr_revm_ERC20Transfer 352.9 ± 1.1 351.7 354.7 1.00 ± 0.00
pr_levm_ERC20Transfer 384.3 ± 2.1 381.6 388.3 1.09 ± 0.01

Benchmark Results: Factorial

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Factorial 241.2 ± 0.8 240.1 242.5 1.02 ± 0.01
main_levm_Factorial 276.4 ± 0.8 275.2 277.2 1.17 ± 0.01
pr_revm_Factorial 236.0 ± 1.1 234.9 238.4 1.00
pr_levm_Factorial 278.7 ± 0.9 277.9 280.8 1.18 ± 0.01

Benchmark Results: FactorialRecursive

Command Mean [s] Min [s] Max [s] Relative
main_revm_FactorialRecursive 1.628 ± 0.049 1.505 1.706 1.00 ± 0.04
main_levm_FactorialRecursive 8.810 ± 0.078 8.716 8.974 5.44 ± 0.11
pr_revm_FactorialRecursive 1.621 ± 0.028 1.556 1.655 1.00
pr_levm_FactorialRecursive 8.795 ± 0.080 8.652 8.927 5.43 ± 0.11

Benchmark Results: Fibonacci

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Fibonacci 218.5 ± 1.7 214.7 219.9 1.02 ± 0.01
main_levm_Fibonacci 262.7 ± 2.7 260.2 267.0 1.23 ± 0.01
pr_revm_Fibonacci 213.7 ± 1.3 210.5 215.5 1.00
pr_levm_Fibonacci 271.5 ± 22.6 259.7 332.6 1.27 ± 0.11

Benchmark Results: FibonacciRecursive

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_FibonacciRecursive 872.0 ± 11.6 851.0 886.9 1.01 ± 0.02
main_levm_FibonacciRecursive 1086.2 ± 4.9 1080.3 1097.3 1.26 ± 0.02
pr_revm_FibonacciRecursive 859.4 ± 13.4 843.8 884.9 1.00
pr_levm_FibonacciRecursive 1101.2 ± 4.4 1095.5 1107.7 1.28 ± 0.02

Benchmark Results: ManyHashes

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_ManyHashes 12.4 ± 0.1 12.4 12.5 1.00 ± 0.01
main_levm_ManyHashes 13.6 ± 0.1 13.5 14.0 1.10 ± 0.01
pr_revm_ManyHashes 12.4 ± 0.1 12.3 12.6 1.00
pr_levm_ManyHashes 13.6 ± 0.1 13.5 13.8 1.10 ± 0.01

Benchmark Results: MstoreBench

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_MstoreBench 268.6 ± 4.2 264.9 275.0 1.00
main_levm_MstoreBench 797.2 ± 5.8 793.0 807.9 2.97 ± 0.05
pr_revm_MstoreBench 270.6 ± 11.2 263.3 300.3 1.01 ± 0.04
pr_levm_MstoreBench 804.4 ± 29.5 792.8 888.1 2.99 ± 0.12

Benchmark Results: Push

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_Push 298.4 ± 2.2 293.4 301.7 1.00
main_levm_Push 889.6 ± 4.4 885.7 898.8 2.98 ± 0.03
pr_revm_Push 298.5 ± 0.5 297.4 299.1 1.00 ± 0.01
pr_levm_Push 886.8 ± 1.7 884.7 891.0 2.97 ± 0.02

Benchmark Results: SstoreBench_no_opt

Command Mean [ms] Min [ms] Max [ms] Relative
main_revm_SstoreBench_no_opt 220.2 ± 2.4 218.5 225.9 2.42 ± 0.05
main_levm_SstoreBench_no_opt 91.0 ± 1.5 89.2 92.9 1.00
pr_revm_SstoreBench_no_opt 219.3 ± 0.5 218.3 220.0 2.41 ± 0.04
pr_levm_SstoreBench_no_opt 91.8 ± 3.5 88.9 101.0 1.01 ± 0.04

@edg-l edg-l changed the title perf(levm): simple signed remaining gas perf(levm): use signed remaining gas, improving gas cost calculation perf Oct 1, 2025
@edg-l edg-l removed this from ethrex_l1 Oct 1, 2025
@edg-l edg-l requested a review from JereSalo October 1, 2025 10:47
@edg-l edg-l requested a review from Oppen October 1, 2025 10:47
Copy link
Contributor

@JereSalo JereSalo left a comment

Choose a reason for hiding this comment

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

Good
What if we change the rest of the gas variables to i64 too? Would that make more sense instead of converting types every time? Just wanted to know your opinion, it's not necessary to do it in this PR

@edg-l
Copy link
Contributor Author

edg-l commented Oct 1, 2025

Good What if we change the rest of the gas variables to i64 too? Would that make more sense instead of converting types every time? Just wanted to know your opinion, it's not necessary to do it in this PR

we would need to see if its worth it

@edg-l edg-l added this pull request to the merge queue Oct 1, 2025
Merged via the queue into main with commit eedb9dd Oct 1, 2025
63 checks passed
@edg-l edg-l deleted the signed_gas branch October 1, 2025 13:36
@github-project-automation github-project-automation bot moved this from In review to Done in ethrex_performance Oct 1, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
levm Lambda EVM implementation performance
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants