Skip to content

Add benchmark for gRPC GetValidatorSet #1326

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

Merged
merged 3 commits into from
Apr 12, 2023
Merged

Add benchmark for gRPC GetValidatorSet #1326

merged 3 commits into from
Apr 12, 2023

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 round trip serialization. The server + wire cost for serving 2000 records is only about 1.6ms. The rest of the time is spent converting bytes to BLS keys (cgo) client side.

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>
@hexfusion hexfusion changed the title Obs Add benchmark for gRPC GetValidatorSet Apr 11, 2023
@StephenButtolph StephenButtolph added benchmarking sdk This involves SDK tooling or frameworks labels Apr 11, 2023
@StephenButtolph StephenButtolph changed the base branch from master to dev April 12, 2023 16:04
Copy link
Contributor

@StephenButtolph StephenButtolph left a comment

Choose a reason for hiding this comment

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

nits

Signed-off-by: Sam Batschelet <sam.batschelet@avalabs.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
sdk This involves SDK tooling or frameworks
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants