-
Notifications
You must be signed in to change notification settings - Fork 40
fix: recompute head was taking more than 20s in mainnet #1380
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
Conversation
Is possible that #1321 stop happening as usually as today, get_weight was called every time before, now is just used on a fork choice as it should. |
|> then(fn | ||
[] -> {:halt, head} | ||
c -> {:cont, Enum.max_by(c, &get_weight(store, &1, justified_state))} |
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.
As we discussed with @ElFantasma this could have been just 1 line change like:
|> then(fn
[] -> {:halt, head}
[single_child] -> {:cont, single_child}
c -> {:cont, Enum.max_by(c, &get_weight(store, &1, justified_state))}
most of the changes are just for readability
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.
It looks good to me.
I also think that your version has improved readability but I'd like some of the code authors' to take a look on the style change, to ensure they agree on that. Maybe @mpaulucci or @Arkenan ?
Recompute head has been reduced from 20~30s to less than 1s Before:
After:
|
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
Motivation
Running the node for more than an epoch and just after block processing, 20+ seconds were taken before finishing the fork choice step, which made it impossible to execute sequentially inside the slot range (12s)
Description
After extensive debugging, the issue was found in the recompute head calculation, specially in the repeatedly call of get_weight where it wasn't really needed (outside of forks). The solution was taking into account this cases and stop calculating get_weight when encountered.
Resolves #1381