-
Notifications
You must be signed in to change notification settings - Fork 761
Cache BLS Keys #1445
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
Cache BLS Keys #1445
Conversation
109bec9
to
7dd0d54
Compare
7dd0d54
to
3747a44
Compare
3747a44
to
1b346c1
Compare
vms/platformvm/vm.go
Outdated
PublicKey: primaryVdr.PublicKey, | ||
Weight: vdr.Weight, | ||
NodeID: vdr.NodeID, | ||
PublicKey: validators.PublicKey{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We're probably going to want to do a followup here where we keep the serialized bytes of the keys in memory as well. Will enable us to avoid re-serializing on every call to GetValidatorSet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created a followup ticket - #1508
Some more benchmarks here #1467 |
0e443a8
to
83b0a77
Compare
83b0a77
to
042792d
Compare
This PR has become stale because it has been open for 30 days with no activity. Adding the |
I made an issue to track this optimization in a broader context across the whole node: #3902 |
Why this should be merged
Since the P-Chain communicates with the
warp
contract over GRPC, we can re-use the bytes that are coming out of grpc to pre-populate the serialized form of a bls key, avoiding re-calculating it later which turns out to be roughly half of the cpu cycles spent inGetCanonicalValidatorSet
(aside from sorting).How this works
Pre-populates a new field that holds the cached representation of the bls key.
How this was tested
Added a benchmark test. Seeing roughly a 20% performance boost:
Before:
After: