Skip to content

core/vm: add configurable jumpdest analysis cache#32143

Merged
fjl merged 4 commits into
ethereum:masterfrom
lmittmann:feat/32137
Aug 1, 2025
Merged

core/vm: add configurable jumpdest analysis cache#32143
fjl merged 4 commits into
ethereum:masterfrom
lmittmann:feat/32137

Conversation

@lmittmann
Copy link
Copy Markdown
Contributor

resolves #32137

This PR replaces jumpDests map[common.Hash]bitvec with jumpDests JumpDests in the EVM. The JumpDests allows custom jumpdest analysis caches.

I did not update the signature of vm.NewEVM to keep the diff smaller. Instead I added EVM.SetJumpDests which can be used directly after construction to set a custom JumpDests implementation. If SetJumpDests is not called a mapJumpDests is set lazily within the EVM.
Additionally I exported bitvec, now BitVec. This is necessary to support third-party JumpDests implementations.

lmittmann added 2 commits July 3, 2025 14:13
- renamed `bitvec` to `BitVec`
- `BitVec` needs to be exported to support thirdparty `JumpDests` implementations
@lmittmann lmittmann requested a review from rjl493456442 as a code owner July 3, 2025 12:23
Comment thread core/vm/evm.go Outdated
chainConfig: chainConfig,
chainRules: chainConfig.Rules(blockCtx.BlockNumber, blockCtx.Random != nil, blockCtx.Time),
jumpDests: make(map[common.Hash]bitvec),
jumpDests: nil,
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.

Please put this back, i.e. put make(mapJumpDests) here and remove the lazy init. Yes, there will be an extra allocation in case it's not used, but I feel it's preferable to having to init everywhere.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Okay, updated the PR.

@rjl493456442 rjl493456442 added this to the 1.16.2 milestone Aug 1, 2025
@fjl fjl changed the title core/vm: added JumpDests type to abstract jumpdest analysis caching core/vm: add configurable jumpdest analysis cache Aug 1, 2025
@fjl fjl merged commit 17d65e9 into ethereum:master Aug 1, 2025
4 of 5 checks passed
howjmay pushed a commit to iotaledger/go-ethereum that referenced this pull request Aug 27, 2025
This adds a method on vm.EVM to set the jumpdest cache implementation.
It can be used to maintain an analysis cache across VM invocations, to improve
performance by skipping the analysis for already known contracts.

---------

Co-authored-by: lmittmann <lmittmann@users.noreply.github.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
gballet pushed a commit to gballet/go-ethereum that referenced this pull request Sep 11, 2025
This adds a method on vm.EVM to set the jumpdest cache implementation.
It can be used to maintain an analysis cache across VM invocations, to improve
performance by skipping the analysis for already known contracts.

---------

Co-authored-by: lmittmann <lmittmann@users.noreply.github.com>
Co-authored-by: Felix Lange <fjl@twurst.com>
gzliudan added a commit to gzliudan/XDPoSChain that referenced this pull request Apr 20, 2026
AnilChinchawale pushed a commit to XinFinOrg/XDPoSChain that referenced this pull request May 11, 2026
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.

core/vm: codeBitmap is consuming ~20% of CPU time in simulation heavy workloads

3 participants