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

altair processAttestations performance issue #3080

Closed
dapplion opened this issue Sep 3, 2021 · 2 comments · Fixed by #3760
Closed

altair processAttestations performance issue #3080

dapplion opened this issue Sep 3, 2021 · 2 comments · Fixed by #3760
Assignees
Labels
prio-high Resolve issues as soon as possible. scope-performance Performance issue and ideas to improve performance. spec-altair Issues targeting the Altair spec version.

Comments

@dapplion
Copy link
Contributor

dapplion commented Sep 3, 2021

Describe the bug

Looking at the metrics for our altair nodes processing a block takes way longer (300ms) than what the performance tests say (100ms).

Taking a profile shows that all the time is spent on processing attestations

Screenshot from 2021-09-03 18-40-18

Expected behavior

Should not take so long


Note: this CPU profile was taken in an overloaded contabo node.

Running the altair block performance benchmarks in my laptop do

  altair processBlock
    ✓ altair processBlock - 250000 vs - 7PWei normalcase                  10.01820 ops/s    99.81831 ms/op        -         33 runs   17.2 s
    ✓ altair processBlock - 250000 vs - 7PWei worstcase                   4.261845 ops/s    234.6401 ms/op        -         26 runs   7.50 s

While running the same in that contabo's host

  altair processBlock
    ✓ altair processBlock - 250000 vs - 7PWei normalcase                  7.083636 ops/s    141.1704 ms/op   x0.601         14 runs   20.8 s
    ✓ altair processBlock - 250000 vs - 7PWei worstcase                   2.356299 ops/s    424.3943 ms/op   x0.629         24 runs   12.1 s

And Github CI does

altair processBlock - 250000 vs - 7PWei normalcase | 103.91 ms/op | 97.787 ms/op | 1.06
altair processBlock - 250000 vs - 7PWei worstcase  | 261.36 ms/op | 265.06 ms/op | 0.99
@dapplion dapplion added the scope-performance Performance issue and ideas to improve performance. label Sep 3, 2021
@dapplion
Copy link
Contributor Author

dapplion commented Sep 3, 2021

The performance issue comes from having to traverse the tree many times to persist each single new status. If I comment this line out

epochParticipation.setStatus(index, newStatus);

the cost of processing the entire block goes from 100ms -> 23.1ms.

We must apply all the changes in batch at the end of processAttestations(). Maybe with ChainSafe/persistent-merkle-tree#53 ? Also do some pre-aggregate the statuses that will end-up in the same chunk or some bit manipulation magic.

@twoeths twoeths self-assigned this Sep 8, 2021
@q9f q9f added mod1-beaconchain spec-altair Issues targeting the Altair spec version. and removed mod1-beaconchain labels Sep 14, 2021
@philknows philknows added the prio-high Resolve issues as soon as possible. label Nov 29, 2021
@philknows
Copy link
Member

Note to tag this issue with SSZ refactor PR when it's ready.

@dapplion dapplion mentioned this issue May 16, 2022
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
prio-high Resolve issues as soon as possible. scope-performance Performance issue and ideas to improve performance. spec-altair Issues targeting the Altair spec version.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants