-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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: modify DelegatorSharesInvariant for better performance #12170
perf: modify DelegatorSharesInvariant for better performance #12170
Conversation
I did profiling on importing genesis. I imported a 1.8G genesis file ( exported from an osmosis mainet node ), it takes 241 sec while the |
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.
LGTM. @ValarDragon mind taking a quick look?
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.
Logic lgtm! Needs comment specifying that were iterating this way / what's happening in these lines
(cherry picked from commit f052877)
(cherry picked from commit f052877)
Description
Closes: #XXXX
The code in
DelegatorSharesInvariant
is inefficient as it usesk.GetValidatorDelegations
for each validator in valset,k.GetValidatorDelegations
iterates through all the delegations and return all delegations that hasvalidator address
equal to thevalidator address
passed in. This mean we havelen(valset)
number of all delegations iterations.Proposal
Change the code in
DelegatorSharesInvariant
so that it iterate all delegations once, reduce genesis import time quite a bit.Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking change