Skip to content
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

feat: add runtime metric the vm interpreter's Run method #16

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions core/vm/interpreter.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,20 @@
package vm

import (
"time"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
)

const (
// vmInterpreterRunExecutionTime is the name of a metric to capture the
// elapsed execution time (in nanoseconds) of the vm interpreter's Run
// method.
vmInterpreterRunExecutionTime = "vm/interpreter_run_execution_time"
)

// Config are the configuration options for the Interpreter
Expand Down Expand Up @@ -105,6 +115,12 @@ func NewEVMInterpreter(evm *EVM) *EVMInterpreter {
// considered a revert-and-consume-all-gas operation except for
// ErrExecutionReverted which means revert-and-keep-gas-left.
func (in *EVMInterpreter) Run(contract *Contract, input []byte, readOnly bool) (ret []byte, err error) {
if metrics.Enabled {
defer func(start time.Time) {
metrics.GetOrRegisterTimer(vmInterpreterRunExecutionTime, nil).UpdateSince(start)
}(time.Now())
}

// Increment the call depth which is restricted to 1024
in.evm.depth++
defer func() { in.evm.depth-- }()
Expand Down
3 changes: 3 additions & 0 deletions geth-poa/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ services:
"eth*",
"chain*",
"clique*"
"vm*"
]
}
]
Expand Down Expand Up @@ -120,6 +121,7 @@ services:
"eth*",
"chain*",
"clique*"
"vm*"
]
}
]
Expand Down Expand Up @@ -158,6 +160,7 @@ services:
"eth*",
"chain*",
"clique*"
"vm*"
]
}
]
Expand Down
Loading