Skip to content

Conversation

@hexfusion
Copy link
Contributor

@hexfusion hexfusion commented Apr 11, 2023

Why this should be merged

It is important to understand the cost of requesting a large validator set over gRPC. Even though the call is local there is a cost for serialization. The wire cost for the RPC is only about 1.6ms. The rest of the time is spent converting bytes to BLS keys (cgo).

ref

publicKey, err = bls.PublicKeyFromBytes(validator.PublicKey)

$ go test -benchmem -run=^$ -bench ^BenchmarkGetValidatorSet$ github.com/ava-labs/avalanchego/snow/validators/gvalidators -memprofile benchvset.mem -cpuprofile benchvset.cpu

goos: linux
goarch: amd64
pkg: github.com/ava-labs/avalanchego/snow/validators/gvalidators
cpu: Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz
BenchmarkGetValidatorSet/get_validator_set_1_validators-12                 12841            106797 ns/op            9913 B/op        194 allocs/op
BenchmarkGetValidatorSet/get_validator_set_10_validators-12                 1710            670164 ns/op           16391 B/op        266 allocs/op
BenchmarkGetValidatorSet/get_validator_set_500_validators-12                  37          28670401 ns/op          386569 B/op       3744 allocs/op
BenchmarkGetValidatorSet/get_validator_set_1000_validators-12                 19          56178525 ns/op          763855 B/op       7269 allocs/op
BenchmarkGetValidatorSet/get_validator_set_2000_validators-12                  9         111610799 ns/op         1503906 B/op      14323 allocs/op

profiles

benchvset.cpu
benchvset.mem

How this works

Uses golang native benchmark tooling

How this was tested

manual

Signed-off-by: Sam Batschelet <sam.batschelet@avalabs.org>
Signed-off-by: Sam Batschelet <sam.batschelet@avalabs.org>
@hexfusion hexfusion requested a review from gyuho as a code owner April 11, 2023 18:40
@hexfusion hexfusion self-assigned this Apr 11, 2023
@hexfusion hexfusion linked an issue Apr 11, 2023 that may be closed by this pull request
Signed-off-by: Sam Batschelet <sam.batschelet@avalabs.org>
Copy link
Collaborator

@aaronbuchwald aaronbuchwald left a comment

Choose a reason for hiding this comment

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

LGTM - thanks for putting this up!

Signed-off-by: Sam Batschelet <sam.batschelet@avalabs.org>
@hexfusion
Copy link
Contributor Author

used fork by mistake closing in favor of #1326

@hexfusion hexfusion closed this Apr 11, 2023
@hexfusion hexfusion deleted the obs branch April 11, 2023 21:26
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.

Benchmarking for RPCChainVM Latency

3 participants