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 processEffectiveBalanceUpdates #2902

Merged
merged 3 commits into from
Jul 29, 2021

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Jul 29, 2021

Motivation

  • It takes so long to process epoch on mainnet (5.4s in my environment)
  • I added some log, it showed that it updates around 75000 effective balance of validators per epoch

Description

  • Since we have MAX_EFFECTIVE_BALANCE, it turns out that we waste our time to update effective balance for most/all of validators
  • We should NOT update if we see that the effective balance is too small to balance, but it's already MAX_EFFECTIVE_BALANCE. New log shows that we have to update 0 effective balance.
  • Epoch transition is reduced from 5.4s to ~650ms

Screen Shot 2021-07-29 at 09 00 22

Closes #2901

Steps to test or reproduce

  • Sync mainnet

@codeclimate
Copy link

codeclimate bot commented Jul 29, 2021

Code Climate has analyzed commit aa53fed and detected 0 issues on this pull request.

View more on Code Climate.

@github-actions
Copy link
Contributor

github-actions bot commented Jul 29, 2021

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 88e23bc Previous: 940404e Ratio
getCommitteeAssignments - req 1000 vs - 250000 vc 8.2858 ms/op 8.2731 ms/op 1.00
epoch altair - 250000 vs - 7PWei - processJustificationAndFinalization 222.12 us/op 192.44 us/op 1.15
epoch altair - 250000 vs - 7PWei - processInactivityUpdates 2.3113 s/op 2.0562 s/op 1.12
epoch altair - 250000 vs - 7PWei - processRewardsAndPenalties 847.13 ms/op 839.28 ms/op 1.01
epoch altair - 250000 vs - 7PWei - processRegistryUpdates 16.488 us/op 16.675 us/op 0.99
epoch altair - 250000 vs - 7PWei - processSlashings 88.551 us/op 96.477 us/op 0.92
epoch altair - 250000 vs - 7PWei - processEffectiveBalanceUpdates 120.37 ms/op 98.628 ms/op 1.22
epoch altair - 250000 vs - 7PWei - processParticipationFlagUpdates 250.83 ms/op 238.27 ms/op 1.05
epoch altair - 250000 vs - 7PWei - prepareEpochProcessState 529.20 ms/op 501.87 ms/op 1.05
Process block - 250000 vs - 7PWei - with 0 validator exit 340.88 us/op 346.07 us/op 0.99
Process block - 250000 vs - 7PWei - with 1 validator exit 41.578 ms/op 38.919 ms/op 1.07
Process block - 250000 vs - 7PWei - with 16 validator exits 29.300 ms/op 21.255 ms/op 1.38
epoch phase0 - 250000 vs - 7PWei - processJustificationAndFinalization 78.186 us/op 90.898 us/op 0.86
epoch phase0 - 250000 vs - 7PWei - processRewardsAndPenalties 424.64 ms/op 470.24 ms/op 0.90
epoch phase0 - 250000 vs - 7PWei - processRegistryUpdates 11.734 us/op 18.627 us/op 0.63
epoch phase0 - 250000 vs - 7PWei - processSlashings 42.152 us/op 34.352 us/op 1.23
epoch phase0 - 250000 vs - 7PWei - processFinalUpdates 50.700 ms/op 39.521 ms/op 1.28
epoch phase0 - 250000 vs - 7PWei - prepareEpochProcessState 856.01 ms/op 825.18 ms/op 1.04
getAttestationDeltas - 250000 vs - 7PWei 87.323 ms/op 88.300 ms/op 0.99
processSlots - 250000 vs - 7PWei - 32 empty slots 5.7464 s/op 5.5973 s/op 1.03
shuffle list - 16384 els 1.6772 ms/op 2.5192 ms/op 0.67
shuffle list - 250000 els 23.935 ms/op 35.786 ms/op 0.67
getPubkeys - persistent - req 1000 vs - 250000 vc 17.274 us/op 19.053 us/op 0.91
BLS verify - blst-native 1.8566 ms/op 1.8660 ms/op 0.99
BLS verifyMultipleSignatures 3 - blst-native 3.8087 ms/op 3.8324 ms/op 0.99
BLS verifyMultipleSignatures 8 - blst-native 8.2063 ms/op 8.2275 ms/op 1.00
BLS verifyMultipleSignatures 32 - blst-native 29.834 ms/op 29.836 ms/op 1.00
BLS aggregatePubkeys 32 - blst-native 40.419 us/op 41.447 us/op 0.98
BLS aggregatePubkeys 128 - blst-native 155.26 us/op 155.46 us/op 1.00
getAttestationsForBlock 140.15 ms/op 126.80 ms/op 1.11
validate gossip signedAggregateAndProof - struct 4.5169 ms/op 4.5062 ms/op 1.00
validate gossip signedAggregateAndProof - treeBacked 4.4688 ms/op 4.4608 ms/op 1.00
validate gossip attestation - struct 2.0976 ms/op 2.0976 ms/op 1.00
validate gossip attestation - treeBacked 2.1331 ms/op 2.1298 ms/op 1.00

by benchmarkbot/action

@dapplion dapplion merged commit 699e3d5 into master Jul 29, 2021
@dapplion dapplion deleted the tuyen/improve-processEffectiveBalanceUpdates branch July 29, 2021 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Improve processEffectiveBalanceUpdates
2 participants