Skip to content

core/vm: hoist jumptable nil-check out of the interpreter loop #32068

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

omerfirmak
Copy link
Contributor

@omerfirmak omerfirmak commented Jun 20, 2025

simple enough. benchmark of a dummy EVM loop shows ~%2 speed up on my machine.

@omerfirmak omerfirmak requested a review from rjl493456442 as a code owner June 20, 2025 11:46
stack = newstack() // local stack
callContext = &ScopeContext{
op OpCode // current opcode
jumpTable *JumpTable = in.table
Copy link
Contributor

Choose a reason for hiding this comment

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

I wonder why it's a pointer at all

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I guess to avoid 2KB copies on each interpreter creation.

@fjl
Copy link
Contributor

fjl commented Jun 20, 2025

Please post benchstat comparison.

@omerfirmak
Copy link
Contributor Author

omerfirmak commented Jun 20, 2025

goos: linux
goarch: amd64
pkg: github.com/ethereum/go-ethereum/core/vm
cpu: AMD Ryzen 7 5700U with Radeon Graphics         
        │   old.txt   │              new.txt               │
        │   sec/op    │   sec/op     vs base               │
Loop-16   193.9n ± 4%   184.3n ± 2%  -4.95% (p=0.000 n=10)

        │  old.txt   │            new.txt             │
        │    B/op    │    B/op     vs base            │
Loop-16   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

        │  old.txt   │            new.txt             │
        │ allocs/op  │ allocs/op   vs base            │
Loop-16   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal

"op" here is a 100 gas worth of execution.

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