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

stategen: Pre-populate bls pubkey cache as part of stategen's Resume function #11482

Merged
merged 50 commits into from
May 10, 2023

Conversation

prestonvanloon
Copy link
Member

What type of PR is this?

Other

What does this PR do? Why is it needed?

At the start of initial sync, much of the work is converting bytes to blst pubkeys. This work of turning []byte into blst.PubKey is a significant part of the initial sync pprof flame.
So this PR introduces a one time routine to iterate over the finalized state validator list to convert / insert all of the pubkeys into the cache.
This allows Prysm to sync at it's max sync speed from the start, although it does not reduce the total time to sync.

Which issues(s) does this PR fix?

Other notes for review

Needs a bit more testing.

… This adds some helpers and a benchmark to blst
var maxKeys = 1000000
var maxKeys = 1_000_000
Copy link
Member Author

Choose a reason for hiding this comment

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

This is cosmetic only. Easier to read this way.

Comment on lines +107 to +121
b.Run("cache on", func(b *testing.B) {
blst.EnableCaches()
for i := 0; i < b.N; i++ {
_, err := blst.PublicKeyFromBytes(pubkeyBytes)
require.NoError(b, err)
}
})

b.Run("cache off", func(b *testing.B) {
blst.DisableCaches()
for i := 0; i < b.N; i++ {
_, err := blst.PublicKeyFromBytes(pubkeyBytes)
require.NoError(b, err)
}
})
Copy link
Member Author

Choose a reason for hiding this comment

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

goos: linux
goarch: amd64
cpu: Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
BenchmarkPublicKeyFromBytes/cache_on-8          12787650               101.9 ns/op
BenchmarkPublicKeyFromBytes/cache_off-8            16531             73187 ns/op
PASS

@prestonvanloon prestonvanloon marked this pull request as ready for review March 7, 2023 18:04
@prestonvanloon prestonvanloon requested a review from a team as a code owner March 7, 2023 18:04
rauljordan
rauljordan previously approved these changes May 7, 2023
@prylabs-bulldozer prylabs-bulldozer bot merged commit 4b4e213 into develop May 10, 2023
@prylabs-bulldozer prylabs-bulldozer bot deleted the populate-pubkey-cache branch May 10, 2023 10: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.

2 participants