Skip to content

Refactor EVM interpreter loop for better branch predictability #32082

Open
@omerfirmak

Description

@omerfirmak

Currently (even during vanilla block execution) there are a couple of branches that are almost impossible for the processor to predict.

  • Main loop potentially makes 3 function calls thru function pointers

https://github.com/ethereum/go-ethereum/blob/master/core/vm/interpreter.go#L273
https://github.com/ethereum/go-ethereum/blob/master/core/vm/interpreter.go#L286
https://github.com/ethereum/go-ethereum/blob/master/core/vm/interpreter.go#L314

  • also potentially branches internally on 2 conditionals

https://github.com/ethereum/go-ethereum/blob/master/core/vm/interpreter.go#L267
https://github.com/ethereum/go-ethereum/blob/master/core/vm/interpreter.go#L272

We could first try to minimize the number of branches by combining memory resize/dynamic gas handling and actual opcode execution in a single handler and then potentially also implement some flavor of direct threading to get rid of the main interpreter loop entirely.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions