-
-
Notifications
You must be signed in to change notification settings - Fork 300
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
fix: improve forkchoice updateHead() time #5867
Conversation
Performance Report✔️ no performance regression detected 🚀🚀 Significant benchmark improvement detected
Full benchmark results
|
@@ -21,33 +21,38 @@ export function computeDeltas( | |||
): number[] { | |||
const deltas = Array.from({length: indices.size}, () => 0); |
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.
This can also be improved, it's faster to do a regular for loop than array.from
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.
What about Array.fill performance?
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.
Last time i checked regular for loop in the fastest way to populate an array. There should be benchmarks in the state transition package
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.
array creation
Array.from(() => 0): 9.6100125 ms
✔ Array.from(() => 0)
Array.from().fill(0): 8.389225 ms
✔ Array.from().fill(0)
Array.from(): 15.170741699999999 ms
✔ Array.from()
new Array(): 0.8613583 ms
✔ new Array()
new Array(); for loop: 1.2474166 ms
✔ new Array(); for loop
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.
Have you benchmark just pushing to an empty array?
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.
not yet, how important is it? in this case there are always more than 0 protonodes in forkchoice
with 0aa5224 the |
The root cause of this slow down is we call The complexity of a function to check if all nodes are ancestor of finalized node (naive way, not the improvement in this PR) is We need to review:
|
Motivation
forkChoice updateHead vc 600000 bc 7200 eq 0
testDescription
part of #5852