Skip to content

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

@lmittmann

Description

@lmittmann

Rationale

codeBitmap is consuming ~20% of CPU time when the EVM is used in simulation heavy workloads. Currently the result of codeBitmap is cached in a map for each distinct codeHash for the lifetime of the core.EVM struct.

Example Benchmark

Image

Implementation

I propose to abstract map[common.Hash]bitvec in vm.EVM to an interface type:

type JumpDests interface {
    Load(codeHash common.Hash) (BitVec, bool)
    Store(codeHash commonHash, vec BitVec)
}

And to give the EVM an option to set jumpDests in vm.NewEVM.

This abstraction gives the flexibility to both keep the current logic of creating a separate store for each EVM instance, as well as using a global thread safe store (e.g. lru-cache).

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions