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

Improve recomputeForkChoiceHead #5852

Closed
twoeths opened this issue Aug 6, 2023 · 5 comments · Fixed by #5882
Closed

Improve recomputeForkChoiceHead #5852

twoeths opened this issue Aug 6, 2023 · 5 comments · Fixed by #5882
Assignees
Labels
meta-bug Issues that identify a bug and require a fix. scope-performance Performance issue and ideas to improve performance.

Comments

@twoeths
Copy link
Contributor

twoeths commented Aug 6, 2023

Describe the bug

In mainnet node it could take up to 0.5s to recomputeForkChoiceHead

Screenshot 2023-08-06 at 15 10 27

and it takes 6% of cpu in total

Screenshot 2023-08-06 at 15 22 50

while out benchmark says <= 100ms

see #5836 (comment)

Expected behavior

Get back to the level of v1.9.x

Screenshot 2023-08-06 at 15 12 01

Steps to reproduce

No response

Additional context

No response

Operating system

Linux

Lodestar version or commit hash

v1.10.0

@twoeths twoeths added the meta-bug Issues that identify a bug and require a fix. label Aug 6, 2023
@twoeths
Copy link
Contributor Author

twoeths commented Aug 6, 2023

this could be because we processed so many attestations in v1.10.0 compared to v1.9.2

Screenshot 2023-08-06 at 15 15 45

also looks like the benchmark test does not go with this number, need to update it

@twoeths
Copy link
Contributor Author

twoeths commented Aug 8, 2023

this is part of the effort to handle more validators coming to ethereum, see #5855

@philknows philknows added the scope-performance Performance issue and ideas to improve performance. label Aug 8, 2023
@twoeths
Copy link
Contributor Author

twoeths commented Aug 9, 2023

for 2M validator network, this could be up to 8s on 2M validator devnet

Screenshot 2023-08-09 at 10 15 40

@twoeths
Copy link
Contributor Author

twoeths commented Aug 10, 2023

0810_updateHead_perf_test.cpuprofile.zip

this issue is caused by getAncestor() call, we iterate too much from a node until finalized node to check if a node is descendant of finalized node

Screenshot 2023-08-10 at 10 03 03

@dapplion
Copy link
Contributor

@tuyennhv please research the following:

  • when changing finalized create a new nodes vector that includes only descendant of finalized
  • keep a mapping of the node index changes and update all indexes

With this we pay a higher ocassional cost, but then we never have to check if descedant of finalized. My concern is that finalized checkpoint can change at times where the node is hot. But it should be worth it to benchmark how expensive this remapping operation is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
meta-bug Issues that identify a bug and require a fix. scope-performance Performance issue and ideas to improve performance.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants