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

perf: improved func ValidateNodeForTxn node id parsing #1578

Conversation

denis-gudim
Copy link
Contributor

@denis-gudim denis-gudim commented Dec 1, 2022

Enhanced permission ValidateNodeForTxn function contains repeating parsing of enode identifier from NodeInfo.Url field. This fix stores parsed enode id value to cached NodeInfo object and reuse stored value on each ValidateNodeForTxn function call.

In our EOA transactions performance test with enabled enhanced permission, this fix decrease CPU usage on ~10% in collected pprof report.

Benchmark source:

goos: linux
goarch: amd64
pkg: github.com/ethereum/go-ethereum/permission/core
cpu: Intel(R) Xeon(R) CPU E5-2696 v3 @ 2.30GHz
BenchmarkValidateNodeForTxn-8             100000             17177 ns/op           11911 B/op        181 allocs/op
BenchmarkValidateNodeForTxn-8             100000             16033 ns/op           11914 B/op        181 allocs/op
BenchmarkValidateNodeForTxn-8             100000             16371 ns/op           11886 B/op        181 allocs/op
BenchmarkValidateNodeForTxn-8             100000             16227 ns/op           11915 B/op        181 allocs/op
BenchmarkValidateNodeForTxn-8             100000             15923 ns/op           11870 B/op        181 allocs/op
PASS
ok      github.com/ethereum/go-ethereum/permission/core 8.204s

Benchmark fix:

goos: linux
goarch: amd64
pkg: github.com/ethereum/go-ethereum/permission/core
cpu: Intel(R) Xeon(R) CPU E5-2696 v3 @ 2.30GHz
BenchmarkValidateNodeForTxn-8             100000              1104 ns/op              40 B/op          3 allocs/op
BenchmarkValidateNodeForTxn-8             100000              1750 ns/op              40 B/op          3 allocs/op
BenchmarkValidateNodeForTxn-8             100000              1584 ns/op              41 B/op          3 allocs/op
BenchmarkValidateNodeForTxn-8             100000              1467 ns/op              41 B/op          3 allocs/op
BenchmarkValidateNodeForTxn-8             100000              1631 ns/op              42 B/op          3 allocs/op
PASS
ok      github.com/ethereum/go-ethereum/permission/core 0.789s

@denis-gudim denis-gudim marked this pull request as ready for review December 1, 2022 20:35
Copy link
Contributor

@baptiste-b-pegasys baptiste-b-pegasys left a comment

Choose a reason for hiding this comment

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

LGTM, I raise few small remarks as I don't entirely master the subject with errors handling and go types

eth/api_backend.go Outdated Show resolved Hide resolved
permission/core/cache.go Show resolved Hide resolved
permission/core/cache.go Outdated Show resolved Hide resolved
permission/core/cache.go Outdated Show resolved Hide resolved
@antonydenyer antonydenyer merged commit 6702b2b into Consensys:master Dec 4, 2022
@denis-gudim denis-gudim deleted the fix/permissioning-validate-node-perf branch December 4, 2022 19:44
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.

3 participants