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

refactor!: simplify discv5 initialization #5456

Merged
merged 5 commits into from
May 8, 2023
Merged

Conversation

wemeetagain
Copy link
Member

Motivation

Simplification of initialization of discv5 for the purpose of simplifying passing the enr across a thread boundary

@wemeetagain wemeetagain requested a review from a team as a code owner May 2, 2023 21:50
@github-actions
Copy link
Contributor

github-actions bot commented May 2, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 19432e7 Previous: c4f5f05 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 891.03 us/op 754.03 us/op 1.18
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 46.619 us/op 57.642 us/op 0.81
BLS verify - blst-native 1.2341 ms/op 1.2706 ms/op 0.97
BLS verifyMultipleSignatures 3 - blst-native 2.5077 ms/op 2.5771 ms/op 0.97
BLS verifyMultipleSignatures 8 - blst-native 5.3840 ms/op 5.5473 ms/op 0.97
BLS verifyMultipleSignatures 32 - blst-native 19.700 ms/op 20.169 ms/op 0.98
BLS aggregatePubkeys 32 - blst-native 26.186 us/op 27.011 us/op 0.97
BLS aggregatePubkeys 128 - blst-native 101.62 us/op 105.59 us/op 0.96
getAttestationsForBlock 55.850 ms/op 66.165 ms/op 0.84
isKnown best case - 1 super set check 260.00 ns/op 276.00 ns/op 0.94
isKnown normal case - 2 super set checks 251.00 ns/op 269.00 ns/op 0.93
isKnown worse case - 16 super set checks 254.00 ns/op 272.00 ns/op 0.93
CheckpointStateCache - add get delete 5.0290 us/op 5.8660 us/op 0.86
validate gossip signedAggregateAndProof - struct 2.8144 ms/op 2.9038 ms/op 0.97
validate gossip attestation - struct 1.3710 ms/op 1.3965 ms/op 0.98
pickEth1Vote - no votes 1.2231 ms/op 1.3988 ms/op 0.87
pickEth1Vote - max votes 9.8565 ms/op 12.308 ms/op 0.80
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.8486 ms/op 10.493 ms/op 0.84
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 13.827 ms/op 22.242 ms/op 0.62
pickEth1Vote - Eth1Data fastSerialize value x2048 651.80 us/op 808.32 us/op 0.81
pickEth1Vote - Eth1Data fastSerialize tree x2048 5.9494 ms/op 10.338 ms/op 0.58
bytes32 toHexString 510.00 ns/op 789.00 ns/op 0.65
bytes32 Buffer.toString(hex) 365.00 ns/op 479.00 ns/op 0.76
bytes32 Buffer.toString(hex) from Uint8Array 549.00 ns/op 664.00 ns/op 0.83
bytes32 Buffer.toString(hex) + 0x 351.00 ns/op 460.00 ns/op 0.76
Object access 1 prop 0.18200 ns/op 0.22300 ns/op 0.82
Map access 1 prop 0.16400 ns/op 0.17800 ns/op 0.92
Object get x1000 6.9730 ns/op 7.3580 ns/op 0.95
Map get x1000 0.71700 ns/op 0.70300 ns/op 1.02
Object set x1000 55.215 ns/op 79.090 ns/op 0.70
Map set x1000 45.698 ns/op 55.197 ns/op 0.83
Return object 10000 times 0.24100 ns/op 0.25750 ns/op 0.94
Throw Error 10000 times 4.2519 us/op 4.4372 us/op 0.96
fastMsgIdFn sha256 / 200 bytes 3.5080 us/op 3.7060 us/op 0.95
fastMsgIdFn h32 xxhash / 200 bytes 279.00 ns/op 349.00 ns/op 0.80
fastMsgIdFn h64 xxhash / 200 bytes 428.00 ns/op 500.00 ns/op 0.86
fastMsgIdFn sha256 / 1000 bytes 11.924 us/op 12.298 us/op 0.97
fastMsgIdFn h32 xxhash / 1000 bytes 421.00 ns/op 474.00 ns/op 0.89
fastMsgIdFn h64 xxhash / 1000 bytes 490.00 ns/op 593.00 ns/op 0.83
fastMsgIdFn sha256 / 10000 bytes 104.63 us/op 113.46 us/op 0.92
fastMsgIdFn h32 xxhash / 10000 bytes 1.9110 us/op 2.0890 us/op 0.91
fastMsgIdFn h64 xxhash / 10000 bytes 1.3540 us/op 1.4750 us/op 0.92
enrSubnets - fastDeserialize 64 bits 1.3040 us/op 1.8830 us/op 0.69
enrSubnets - ssz BitVector 64 bits 563.00 ns/op 625.00 ns/op 0.90
enrSubnets - fastDeserialize 4 bits 185.00 ns/op 219.00 ns/op 0.84
enrSubnets - ssz BitVector 4 bits 497.00 ns/op 647.00 ns/op 0.77
prioritizePeers score -10:0 att 32-0.1 sync 2-0 103.69 us/op 120.92 us/op 0.86
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 133.99 us/op 157.56 us/op 0.85
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 175.43 us/op 207.92 us/op 0.84
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 305.93 us/op 383.24 us/op 0.80
prioritizePeers score 0:0 att 64-1 sync 4-1 365.81 us/op 450.44 us/op 0.81
array of 16000 items push then shift 1.6615 us/op 1.7264 us/op 0.96
LinkedList of 16000 items push then shift 8.9360 ns/op 9.5670 ns/op 0.93
array of 16000 items push then pop 77.874 ns/op 121.97 ns/op 0.64
LinkedList of 16000 items push then pop 8.6520 ns/op 9.1470 ns/op 0.95
array of 24000 items push then shift 2.3994 us/op 2.4980 us/op 0.96
LinkedList of 24000 items push then shift 9.1230 ns/op 9.6520 ns/op 0.95
array of 24000 items push then pop 74.222 ns/op 90.201 ns/op 0.82
LinkedList of 24000 items push then pop 8.6350 ns/op 9.6310 ns/op 0.90
intersect bitArray bitLen 8 13.591 ns/op 14.603 ns/op 0.93
intersect array and set length 8 79.985 ns/op 90.199 ns/op 0.89
intersect bitArray bitLen 128 45.132 ns/op 45.894 ns/op 0.98
intersect array and set length 128 1.2261 us/op 1.2808 us/op 0.96
Buffer.concat 32 items 3.0190 us/op 3.1200 us/op 0.97
Uint8Array.set 32 items 3.1530 us/op 2.4080 us/op 1.31
pass gossip attestations to forkchoice per slot 2.9776 ms/op 3.4576 ms/op 0.86
computeDeltas 2.9145 ms/op 3.2622 ms/op 0.89
computeProposerBoostScoreFromBalances 1.7908 ms/op 1.8711 ms/op 0.96
altair processAttestation - 250000 vs - 7PWei normalcase 2.3344 ms/op 3.4521 ms/op 0.68
altair processAttestation - 250000 vs - 7PWei worstcase 3.6404 ms/op 4.8280 ms/op 0.75
altair processAttestation - setStatus - 1/6 committees join 140.38 us/op 145.90 us/op 0.96
altair processAttestation - setStatus - 1/3 committees join 283.60 us/op 295.01 us/op 0.96
altair processAttestation - setStatus - 1/2 committees join 370.90 us/op 387.18 us/op 0.96
altair processAttestation - setStatus - 2/3 committees join 475.10 us/op 505.07 us/op 0.94
altair processAttestation - setStatus - 4/5 committees join 688.45 us/op 701.65 us/op 0.98
altair processAttestation - setStatus - 100% committees join 744.76 us/op 808.78 us/op 0.92
altair processBlock - 250000 vs - 7PWei normalcase 19.413 ms/op 19.469 ms/op 1.00
altair processBlock - 250000 vs - 7PWei normalcase hashState 24.739 ms/op 30.325 ms/op 0.82
altair processBlock - 250000 vs - 7PWei worstcase 55.726 ms/op 57.180 ms/op 0.97
altair processBlock - 250000 vs - 7PWei worstcase hashState 66.145 ms/op 77.276 ms/op 0.86
phase0 processBlock - 250000 vs - 7PWei normalcase 1.9426 ms/op 2.4259 ms/op 0.80
phase0 processBlock - 250000 vs - 7PWei worstcase 27.853 ms/op 32.603 ms/op 0.85
altair processEth1Data - 250000 vs - 7PWei normalcase 456.01 us/op 665.43 us/op 0.69
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 9.1720 us/op 10.680 us/op 0.86
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 24.261 us/op 32.637 us/op 0.74
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 9.8000 us/op 12.620 us/op 0.78
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 7.6700 us/op 9.9820 us/op 0.77
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 105.89 us/op 114.98 us/op 0.92
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 657.24 us/op 715.99 us/op 0.92
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 912.24 us/op 921.42 us/op 0.99
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 919.00 us/op 927.25 us/op 0.99
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 2.4078 ms/op 2.9928 ms/op 0.80
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 1.7121 ms/op 1.5713 ms/op 1.09
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 4.7517 ms/op 5.8192 ms/op 0.82
Tree 40 250000 create 345.71 ms/op 473.20 ms/op 0.73
Tree 40 250000 get(125000) 191.63 ns/op 200.97 ns/op 0.95
Tree 40 250000 set(125000) 983.89 ns/op 1.1292 us/op 0.87
Tree 40 250000 toArray() 21.984 ms/op 24.252 ms/op 0.91
Tree 40 250000 iterate all - toArray() + loop 20.509 ms/op 24.455 ms/op 0.84
Tree 40 250000 iterate all - get(i) 74.558 ms/op 79.394 ms/op 0.94
MutableVector 250000 create 11.677 ms/op 13.248 ms/op 0.88
MutableVector 250000 get(125000) 6.3440 ns/op 6.9400 ns/op 0.91
MutableVector 250000 set(125000) 271.97 ns/op 276.17 ns/op 0.98
MutableVector 250000 toArray() 3.2599 ms/op 4.0876 ms/op 0.80
MutableVector 250000 iterate all - toArray() + loop 3.3800 ms/op 4.1445 ms/op 0.82
MutableVector 250000 iterate all - get(i) 1.5306 ms/op 1.5733 ms/op 0.97
Array 250000 create 2.8744 ms/op 3.8693 ms/op 0.74
Array 250000 clone - spread 1.2110 ms/op 1.2424 ms/op 0.97
Array 250000 get(125000) 0.59100 ns/op 0.66300 ns/op 0.89
Array 250000 set(125000) 0.66600 ns/op 0.74500 ns/op 0.89
Array 250000 iterate all - loop 102.61 us/op 86.362 us/op 1.19
effectiveBalanceIncrements clone Uint8Array 300000 32.453 us/op 51.313 us/op 0.63
effectiveBalanceIncrements clone MutableVector 300000 387.00 ns/op 383.00 ns/op 1.01
effectiveBalanceIncrements rw all Uint8Array 300000 171.34 us/op 174.95 us/op 0.98
effectiveBalanceIncrements rw all MutableVector 300000 86.522 ms/op 99.326 ms/op 0.87
phase0 afterProcessEpoch - 250000 vs - 7PWei 116.25 ms/op 121.60 ms/op 0.96
phase0 beforeProcessEpoch - 250000 vs - 7PWei 36.350 ms/op 52.956 ms/op 0.69
altair processEpoch - mainnet_e81889 331.68 ms/op 352.10 ms/op 0.94
mainnet_e81889 - altair beforeProcessEpoch 71.368 ms/op 74.786 ms/op 0.95
mainnet_e81889 - altair processJustificationAndFinalization 17.306 us/op 17.395 us/op 0.99
mainnet_e81889 - altair processInactivityUpdates 6.2636 ms/op 6.0085 ms/op 1.04
mainnet_e81889 - altair processRewardsAndPenalties 52.226 ms/op 63.201 ms/op 0.83
mainnet_e81889 - altair processRegistryUpdates 2.5510 us/op 4.0920 us/op 0.62
mainnet_e81889 - altair processSlashings 556.00 ns/op 584.00 ns/op 0.95
mainnet_e81889 - altair processEth1DataReset 603.00 ns/op 758.00 ns/op 0.80
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2660 ms/op 1.2870 ms/op 0.98
mainnet_e81889 - altair processSlashingsReset 7.8720 us/op 5.7930 us/op 1.36
mainnet_e81889 - altair processRandaoMixesReset 6.7800 us/op 8.4430 us/op 0.80
mainnet_e81889 - altair processHistoricalRootsUpdate 669.00 ns/op 1.5330 us/op 0.44
mainnet_e81889 - altair processParticipationFlagUpdates 3.5080 us/op 3.6160 us/op 0.97
mainnet_e81889 - altair processSyncCommitteeUpdates 661.00 ns/op 1.0290 us/op 0.64
mainnet_e81889 - altair afterProcessEpoch 136.26 ms/op 131.77 ms/op 1.03
phase0 processEpoch - mainnet_e58758 372.07 ms/op 387.28 ms/op 0.96
mainnet_e58758 - phase0 beforeProcessEpoch 165.79 ms/op 127.90 ms/op 1.30
mainnet_e58758 - phase0 processJustificationAndFinalization 22.201 us/op 19.257 us/op 1.15
mainnet_e58758 - phase0 processRewardsAndPenalties 66.571 ms/op 65.042 ms/op 1.02
mainnet_e58758 - phase0 processRegistryUpdates 8.4300 us/op 10.199 us/op 0.83
mainnet_e58758 - phase0 processSlashings 645.00 ns/op 772.00 ns/op 0.84
mainnet_e58758 - phase0 processEth1DataReset 1.7080 us/op 762.00 ns/op 2.24
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.4567 ms/op 1.0704 ms/op 2.30
mainnet_e58758 - phase0 processSlashingsReset 12.921 us/op 4.5090 us/op 2.87
mainnet_e58758 - phase0 processRandaoMixesReset 13.433 us/op 5.5930 us/op 2.40
mainnet_e58758 - phase0 processHistoricalRootsUpdate 2.8210 us/op 787.00 ns/op 3.58
mainnet_e58758 - phase0 processParticipationRecordUpdates 16.060 us/op 4.2950 us/op 3.74
mainnet_e58758 - phase0 afterProcessEpoch 137.32 ms/op 101.11 ms/op 1.36
phase0 processEffectiveBalanceUpdates - 250000 normalcase 3.2561 ms/op 1.2809 ms/op 2.54
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 4.2930 ms/op 1.6275 ms/op 2.64
altair processInactivityUpdates - 250000 normalcase 36.690 ms/op 26.589 ms/op 1.38
altair processInactivityUpdates - 250000 worstcase 33.163 ms/op 25.824 ms/op 1.28
phase0 processRegistryUpdates - 250000 normalcase 11.311 us/op 8.3950 us/op 1.35
phase0 processRegistryUpdates - 250000 badcase_full_deposits 279.37 us/op 301.03 us/op 0.93
phase0 processRegistryUpdates - 250000 worstcase 0.5 139.44 ms/op 121.84 ms/op 1.14
altair processRewardsAndPenalties - 250000 normalcase 71.345 ms/op 70.190 ms/op 1.02
altair processRewardsAndPenalties - 250000 worstcase 67.565 ms/op 68.454 ms/op 0.99
phase0 getAttestationDeltas - 250000 normalcase 9.5536 ms/op 6.6989 ms/op 1.43
phase0 getAttestationDeltas - 250000 worstcase 7.1212 ms/op 6.9505 ms/op 1.02
phase0 processSlashings - 250000 worstcase 3.8747 ms/op 3.7381 ms/op 1.04
altair processSyncCommitteeUpdates - 250000 194.03 ms/op 179.75 ms/op 1.08
BeaconState.hashTreeRoot - No change 380.00 ns/op 309.00 ns/op 1.23
BeaconState.hashTreeRoot - 1 full validator 54.938 us/op 55.365 us/op 0.99
BeaconState.hashTreeRoot - 32 full validator 573.43 us/op 515.54 us/op 1.11
BeaconState.hashTreeRoot - 512 full validator 5.2268 ms/op 5.0992 ms/op 1.03
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 64.101 us/op 69.823 us/op 0.92
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 909.47 us/op 884.36 us/op 1.03
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 12.827 ms/op 11.134 ms/op 1.15
BeaconState.hashTreeRoot - 1 balances 49.874 us/op 50.632 us/op 0.99
BeaconState.hashTreeRoot - 32 balances 480.15 us/op 458.93 us/op 1.05
BeaconState.hashTreeRoot - 512 balances 4.7263 ms/op 4.4218 ms/op 1.07
BeaconState.hashTreeRoot - 250000 balances 77.540 ms/op 75.272 ms/op 1.03
aggregationBits - 2048 els - zipIndexesInBitList 16.210 us/op 16.717 us/op 0.97
regular array get 100000 times 32.897 us/op 33.470 us/op 0.98
wrappedArray get 100000 times 33.092 us/op 33.886 us/op 0.98
arrayWithProxy get 100000 times 17.165 ms/op 16.155 ms/op 1.06
ssz.Root.equals 571.00 ns/op 588.00 ns/op 0.97
byteArrayEquals 557.00 ns/op 577.00 ns/op 0.97
shuffle list - 16384 els 6.8774 ms/op 7.1900 ms/op 0.96
shuffle list - 250000 els 101.26 ms/op 107.33 ms/op 0.94
processSlot - 1 slots 8.3350 us/op 9.2830 us/op 0.90
processSlot - 32 slots 1.3291 ms/op 1.4533 ms/op 0.91
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 35.294 ms/op 38.425 ms/op 0.92
getCommitteeAssignments - req 1 vs - 250000 vc 2.9877 ms/op 3.0020 ms/op 1.00
getCommitteeAssignments - req 100 vs - 250000 vc 4.1723 ms/op 4.2973 ms/op 0.97
getCommitteeAssignments - req 1000 vs - 250000 vc 4.5178 ms/op 4.6193 ms/op 0.98
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.0200 ns/op 5.3300 ns/op 0.94
state getBlockRootAtSlot - 250000 vs - 7PWei 614.53 ns/op 745.32 ns/op 0.82
computeProposers - vc 250000 10.784 ms/op 11.584 ms/op 0.93
computeEpochShuffling - vc 250000 104.67 ms/op 110.60 ms/op 0.95
getNextSyncCommittee - vc 250000 176.52 ms/op 182.52 ms/op 0.97
computeSigningRoot for AttestationData 13.969 us/op 14.355 us/op 0.97
hash AttestationData serialized data then Buffer.toString(base64) 2.4809 us/op 2.6312 us/op 0.94
toHexString serialized data 1.0787 us/op 1.4499 us/op 0.74
Buffer.toString(base64) 322.32 ns/op 373.00 ns/op 0.86

by benchmarkbot/action

@wemeetagain
Copy link
Member Author

@dapplion ready for re-review

@wemeetagain wemeetagain merged commit 8c98c0f into unstable May 8, 2023
@wemeetagain wemeetagain deleted the cayman/discv5-init branch May 8, 2023 13:55
@wemeetagain
Copy link
Member Author

🎉 This PR is included in v1.9.0 🎉

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.

2 participants