Skip to content

core/vm: port GEVM performance optimisations#2143

Merged
kamuikatsurgi merged 36 commits into
developfrom
kamui/port-gevm-perf-optimisations
Mar 27, 2026
Merged

core/vm: port GEVM performance optimisations#2143
kamuikatsurgi merged 36 commits into
developfrom
kamui/port-gevm-perf-optimisations

Conversation

@kamuikatsurgi

@kamuikatsurgi kamuikatsurgi commented Mar 17, 2026

Copy link
Copy Markdown
Member

Description

  • Fixed-size [1024]uint256.Int array stack replacing slice-based stack, eliminating append/slice-header overhead on push/pop
  • Switch-dispatch fast path (runSwitch) with inlined hot opcodes and gas accumulation, gated behind --switch-dispatch flag
  • Code generator (gen_dispatch/) to produce interpreter_dispatch.go
  • Wire EnableSwitchDispatch through CLI, ethconfig, and blockchain to both block import and block production paths

@codecov

codecov Bot commented Mar 17, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 66.15253% with 395 lines in your changes missing coverage. Please review.
✅ Project coverage is 51.88%. Comparing base (204ebc9) to head (1deddc0).
⚠️ Report is 1 commits behind head on develop.

Files with missing lines Patch % Lines
core/vm/gen_dispatch/main.go 0.00% 277 Missing ⚠️
eth/ethconfig/gen_config.go 0.00% 106 Missing ⚠️
core/vm/interpreter_dispatch.go 98.75% 6 Missing and 3 partials ⚠️
miner/worker.go 75.00% 2 Missing ⚠️
core/vm/stack.go 96.55% 1 Missing ⚠️

❌ Your patch status has failed because the patch coverage (66.15%) is below the target coverage (90.00%). You can increase the patch coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff             @@
##           develop    #2143      +/-   ##
===========================================
+ Coverage    51.33%   51.88%   +0.55%     
===========================================
  Files          882      884       +2     
  Lines       154236   155357    +1121     
===========================================
+ Hits         79178    80614    +1436     
+ Misses       69908    69528     -380     
- Partials      5150     5215      +65     
Files with missing lines Coverage Δ
core/vm/interpreter.go 67.45% <100.00%> (+12.51%) ⬆️
eth/backend.go 52.53% <100.00%> (+0.06%) ⬆️
eth/ethconfig/config.go 78.94% <ø> (ø)
internal/cli/server/config.go 63.84% <100.00%> (+0.05%) ⬆️
internal/cli/server/flags.go 100.00% <100.00%> (ø)
core/vm/stack.go 96.61% <96.55%> (+55.23%) ⬆️
miner/worker.go 72.49% <75.00%> (+0.68%) ⬆️
core/vm/interpreter_dispatch.go 98.75% <98.75%> (ø)
eth/ethconfig/gen_config.go 0.00% <0.00%> (ø)
core/vm/gen_dispatch/main.go 0.00% <0.00%> (ø)

... and 29 files with indirect coverage changes

Files with missing lines Coverage Δ
core/vm/interpreter.go 67.45% <100.00%> (+12.51%) ⬆️
eth/backend.go 52.53% <100.00%> (+0.06%) ⬆️
eth/ethconfig/config.go 78.94% <ø> (ø)
internal/cli/server/config.go 63.84% <100.00%> (+0.05%) ⬆️
internal/cli/server/flags.go 100.00% <100.00%> (ø)
core/vm/stack.go 96.61% <96.55%> (+55.23%) ⬆️
miner/worker.go 72.49% <75.00%> (+0.68%) ⬆️
core/vm/interpreter_dispatch.go 98.75% <98.75%> (ø)
eth/ethconfig/gen_config.go 0.00% <0.00%> (ø)
core/vm/gen_dispatch/main.go 0.00% <0.00%> (ø)

... and 29 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@0xPolygon 0xPolygon deleted a comment from claude Bot Mar 17, 2026
@0xPolygon 0xPolygon deleted a comment from claude Bot Mar 17, 2026
@claude

claude Bot commented Mar 17, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@claude

claude Bot commented Mar 19, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@adamdossa adamdossa requested review from cffls and marcello33 March 23, 2026 10:13

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

Looks good overall. The patch coverage is 66%. Any ideas if we can bump it up?

Comment thread core/vm/gen_dispatch/main.go
Comment thread internal/cli/server/config.go Outdated

@marcello33 marcello33 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

LGTM, 2 minor comments

Comment thread eth/ethconfig/config.go Outdated
Comment thread core/vm/stack.go
Copilot AI review requested due to automatic review settings March 24, 2026 09:31
@kamuikatsurgi

Copy link
Copy Markdown
Member Author

The patch coverage is 66%. Any ideas if we can bump it up?

The test coverage for runSwitch is now 99.4%. And the test coverage for Run (the standard path) is 76%.

Copilot AI 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.

Pull request overview

Ports GEVM-style EVM execution performance optimizations into core/vm, introducing a fixed-size stack and an optional switch-dispatch fast interpreter, and wires the new toggle through config/CLI so it can be enabled for both block import and block production.

Changes:

  • Replace slice-based EVM stack with a fixed-size [1024]uint256.Int + top counter and add stack microbenchmarks.
  • Add a generated runSwitch interpreter fast path (behind EnableEVMSwitchDispatch) plus differential tests and a benchmark harness.
  • Plumb evm-switch-dispatch through CLI/config → eth backend VM config → miner usage.

Reviewed changes

Copilot reviewed 16 out of 16 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
miner/worker.go Uses chain VM config when constructing EVM instances in mining/prefetch paths.
internal/cli/server/flags.go Adds --evm-switch-dispatch CLI flag wired into server config.
internal/cli/server/config.go Adds config field + defaults + wiring into ethconfig.
eth/backend.go Propagates EnableEVMSwitchDispatch into core.BlockChainConfig.VmConfig.
docs/cli/server.md Documents the new CLI flag.
docs/cli/default_config.toml Adds default evm-switch-dispatch = false.
core/vm/stack.go Implements fixed-size stack representation.
core/vm/stack_test.go Adds stack benchmarks for common operations/workloads.
core/vm/interpreter.go Adds EnableEVMSwitchDispatch config and gates fast-path entry.
core/vm/interpreter_dispatch.go Generated switch-dispatch interpreter loop (runSwitch).
core/vm/gen_dispatch/main.go Generator that emits interpreter_dispatch.go.
core/vm/gen_dispatch/CLAUDE.md Internal documentation for generator/fast-path invariants.
core/vm/dispatch_test.go Differential test suite comparing runSwitch vs standard interpreter.
core/vm/dispatch_bench_test.go Benchmark harness using embedded bytecode workload.
core/vm/instructions_test.go Adjusts tests/benchmarks for new stack internals.
core/vm/testdata/snailtracer.hex Embedded benchmark bytecode payload.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/cli/server/flags.go
Comment thread core/vm/stack.go
Comment thread core/vm/dispatch_bench_test.go Outdated
Comment thread core/vm/gen_dispatch/main.go
@claude

claude Bot commented Mar 24, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

Comment thread core/vm/gen_dispatch/CLAUDE.md
Copilot AI review requested due to automatic review settings March 25, 2026 09:50

Copilot AI 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.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread core/vm/gen_dispatch/main.go Outdated
Comment thread core/vm/dispatch_test.go Outdated
Comment thread core/vm/dispatch_test.go Outdated
Copilot AI review requested due to automatic review settings March 27, 2026 05:48

Copilot AI 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.

Pull request overview

Copilot reviewed 18 out of 18 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
1 Security Hotspot
4.3% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

@claude

claude Bot commented Mar 27, 2026

Copy link
Copy Markdown

Code review

No issues found. Checked for bugs and CLAUDE.md compliance.

@kamuikatsurgi kamuikatsurgi merged commit d1cf761 into develop Mar 27, 2026
17 of 19 checks passed
@kamuikatsurgi kamuikatsurgi deleted the kamui/port-gevm-perf-optimisations branch March 27, 2026 07:36
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.

5 participants