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(network)!: use StatusCache in PeerManager #5451

Merged
merged 1 commit into from
May 2, 2023

Conversation

wemeetagain
Copy link
Member

@wemeetagain wemeetagain commented May 1, 2023

Motivation

Description

Use StatusCache (and clock) in PeerManager instead of using the entire chain as a module dependency.
Note: this relaxes our peer relevance calculation by removing the check in the case that a peer is on an old finalized chain.

@github-actions
Copy link
Contributor

github-actions bot commented May 1, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 2a67adf Previous: 1e4ca97 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.0041 ms/op 894.83 us/op 1.12
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 50.028 us/op 44.598 us/op 1.12
BLS verify - blst-native 1.2280 ms/op 1.1982 ms/op 1.02
BLS verifyMultipleSignatures 3 - blst-native 2.5091 ms/op 2.4450 ms/op 1.03
BLS verifyMultipleSignatures 8 - blst-native 5.4488 ms/op 5.2211 ms/op 1.04
BLS verifyMultipleSignatures 32 - blst-native 19.429 ms/op 18.987 ms/op 1.02
BLS aggregatePubkeys 32 - blst-native 26.279 us/op 25.295 us/op 1.04
BLS aggregatePubkeys 128 - blst-native 102.19 us/op 99.295 us/op 1.03
getAttestationsForBlock 49.789 ms/op 56.081 ms/op 0.89
isKnown best case - 1 super set check 249.00 ns/op 252.00 ns/op 0.99
isKnown normal case - 2 super set checks 242.00 ns/op 241.00 ns/op 1.00
isKnown worse case - 16 super set checks 241.00 ns/op 245.00 ns/op 0.98
CheckpointStateCache - add get delete 4.8550 us/op 4.9000 us/op 0.99
validate gossip signedAggregateAndProof - struct 2.7308 ms/op 2.7450 ms/op 0.99
validate gossip attestation - struct 1.2811 ms/op 1.3055 ms/op 0.98
pickEth1Vote - no votes 1.2736 ms/op 1.2312 ms/op 1.03
pickEth1Vote - max votes 10.527 ms/op 8.2321 ms/op 1.28
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.8998 ms/op 8.4206 ms/op 1.06
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 14.007 ms/op 13.374 ms/op 1.05
pickEth1Vote - Eth1Data fastSerialize value x2048 672.58 us/op 639.72 us/op 1.05
pickEth1Vote - Eth1Data fastSerialize tree x2048 4.6590 ms/op 4.5411 ms/op 1.03
bytes32 toHexString 483.00 ns/op 482.00 ns/op 1.00
bytes32 Buffer.toString(hex) 342.00 ns/op 341.00 ns/op 1.00
bytes32 Buffer.toString(hex) from Uint8Array 563.00 ns/op 558.00 ns/op 1.01
bytes32 Buffer.toString(hex) + 0x 357.00 ns/op 339.00 ns/op 1.05
Object access 1 prop 0.16100 ns/op 0.15900 ns/op 1.01
Map access 1 prop 0.15800 ns/op 0.16000 ns/op 0.99
Object get x1000 6.5020 ns/op 6.4060 ns/op 1.01
Map get x1000 0.59900 ns/op 0.61800 ns/op 0.97
Object set x1000 50.764 ns/op 52.405 ns/op 0.97
Map set x1000 43.061 ns/op 42.999 ns/op 1.00
Return object 10000 times 0.23250 ns/op 0.23450 ns/op 0.99
Throw Error 10000 times 4.1883 us/op 4.0879 us/op 1.02
fastMsgIdFn sha256 / 200 bytes 3.3680 us/op 3.4030 us/op 0.99
fastMsgIdFn h32 xxhash / 200 bytes 275.00 ns/op 307.00 ns/op 0.90
fastMsgIdFn h64 xxhash / 200 bytes 394.00 ns/op 391.00 ns/op 1.01
fastMsgIdFn sha256 / 1000 bytes 11.407 us/op 11.527 us/op 0.99
fastMsgIdFn h32 xxhash / 1000 bytes 406.00 ns/op 439.00 ns/op 0.92
fastMsgIdFn h64 xxhash / 1000 bytes 474.00 ns/op 468.00 ns/op 1.01
fastMsgIdFn sha256 / 10000 bytes 101.90 us/op 103.30 us/op 0.99
fastMsgIdFn h32 xxhash / 10000 bytes 1.9300 us/op 1.8970 us/op 1.02
fastMsgIdFn h64 xxhash / 10000 bytes 1.3960 us/op 1.3280 us/op 1.05
enrSubnets - fastDeserialize 64 bits 1.3390 us/op 1.2790 us/op 1.05
enrSubnets - ssz BitVector 64 bits 483.00 ns/op 487.00 ns/op 0.99
enrSubnets - fastDeserialize 4 bits 174.00 ns/op 162.00 ns/op 1.07
enrSubnets - ssz BitVector 4 bits 488.00 ns/op 486.00 ns/op 1.00
prioritizePeers score -10:0 att 32-0.1 sync 2-0 104.80 us/op 110.56 us/op 0.95
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 130.83 us/op 142.48 us/op 0.92
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 167.64 us/op 178.74 us/op 0.94
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 301.34 us/op 326.07 us/op 0.92
prioritizePeers score 0:0 att 64-1 sync 4-1 365.32 us/op 374.60 us/op 0.98
array of 16000 items push then shift 1.6412 us/op 1.6313 us/op 1.01
LinkedList of 16000 items push then shift 8.9870 ns/op 8.8990 ns/op 1.01
array of 16000 items push then pop 75.440 ns/op 100.94 ns/op 0.75
LinkedList of 16000 items push then pop 8.6150 ns/op 8.4600 ns/op 1.02
array of 24000 items push then shift 2.3918 us/op 2.3267 us/op 1.03
LinkedList of 24000 items push then shift 8.7870 ns/op 8.7320 ns/op 1.01
array of 24000 items push then pop 77.951 ns/op 82.961 ns/op 0.94
LinkedList of 24000 items push then pop 8.6050 ns/op 8.4950 ns/op 1.01
intersect bitArray bitLen 8 13.404 ns/op 13.154 ns/op 1.02
intersect array and set length 8 78.815 ns/op 74.705 ns/op 1.06
intersect bitArray bitLen 128 44.321 ns/op 43.787 ns/op 1.01
intersect array and set length 128 1.0626 us/op 1.0292 us/op 1.03
Buffer.concat 32 items 2.9320 us/op 2.6100 us/op 1.12
Uint8Array.set 32 items 2.1360 us/op 2.4510 us/op 0.87
pass gossip attestations to forkchoice per slot 2.5700 ms/op 2.7372 ms/op 0.94
computeDeltas 2.9129 ms/op 3.0518 ms/op 0.95
computeProposerBoostScoreFromBalances 1.8831 ms/op 1.7634 ms/op 1.07
altair processAttestation - 250000 vs - 7PWei normalcase 2.6221 ms/op 2.2155 ms/op 1.18
altair processAttestation - 250000 vs - 7PWei worstcase 3.7568 ms/op 3.2908 ms/op 1.14
altair processAttestation - setStatus - 1/6 committees join 144.12 us/op 138.98 us/op 1.04
altair processAttestation - setStatus - 1/3 committees join 291.17 us/op 275.30 us/op 1.06
altair processAttestation - setStatus - 1/2 committees join 391.18 us/op 374.68 us/op 1.04
altair processAttestation - setStatus - 2/3 committees join 469.15 us/op 462.90 us/op 1.01
altair processAttestation - setStatus - 4/5 committees join 679.78 us/op 652.47 us/op 1.04
altair processAttestation - setStatus - 100% committees join 779.97 us/op 798.68 us/op 0.98
altair processBlock - 250000 vs - 7PWei normalcase 17.652 ms/op 16.170 ms/op 1.09
altair processBlock - 250000 vs - 7PWei normalcase hashState 24.695 ms/op 27.285 ms/op 0.91
altair processBlock - 250000 vs - 7PWei worstcase 53.103 ms/op 54.532 ms/op 0.97
altair processBlock - 250000 vs - 7PWei worstcase hashState 69.855 ms/op 69.424 ms/op 1.01
phase0 processBlock - 250000 vs - 7PWei normalcase 2.1519 ms/op 2.3819 ms/op 0.90
phase0 processBlock - 250000 vs - 7PWei worstcase 30.232 ms/op 29.540 ms/op 1.02
altair processEth1Data - 250000 vs - 7PWei normalcase 517.19 us/op 651.53 us/op 0.79
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 8.5560 us/op 8.6680 us/op 0.99
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 27.038 us/op 23.838 us/op 1.13
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 10.332 us/op 11.461 us/op 0.90
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 7.9260 us/op 12.280 us/op 0.65
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 103.90 us/op 118.80 us/op 0.87
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 654.18 us/op 701.42 us/op 0.93
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 915.71 us/op 938.77 us/op 0.98
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 941.75 us/op 911.87 us/op 1.03
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 2.3633 ms/op 2.5296 ms/op 0.93
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 1.5321 ms/op 1.4988 ms/op 1.02
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 3.9251 ms/op 5.7946 ms/op 0.68
Tree 40 250000 create 361.14 ms/op 382.97 ms/op 0.94
Tree 40 250000 get(125000) 198.63 ns/op 196.52 ns/op 1.01
Tree 40 250000 set(125000) 927.98 ns/op 1.0816 us/op 0.86
Tree 40 250000 toArray() 20.884 ms/op 21.516 ms/op 0.97
Tree 40 250000 iterate all - toArray() + loop 22.278 ms/op 20.505 ms/op 1.09
Tree 40 250000 iterate all - get(i) 76.533 ms/op 76.879 ms/op 1.00
MutableVector 250000 create 10.948 ms/op 11.742 ms/op 0.93
MutableVector 250000 get(125000) 6.5380 ns/op 6.5150 ns/op 1.00
MutableVector 250000 set(125000) 288.17 ns/op 260.00 ns/op 1.11
MutableVector 250000 toArray() 3.1062 ms/op 2.9648 ms/op 1.05
MutableVector 250000 iterate all - toArray() + loop 3.2699 ms/op 3.3173 ms/op 0.99
MutableVector 250000 iterate all - get(i) 1.5692 ms/op 1.5271 ms/op 1.03
Array 250000 create 3.1777 ms/op 2.8201 ms/op 1.13
Array 250000 clone - spread 1.2102 ms/op 1.1657 ms/op 1.04
Array 250000 get(125000) 0.59600 ns/op 0.60400 ns/op 0.99
Array 250000 set(125000) 0.65900 ns/op 0.66500 ns/op 0.99
Array 250000 iterate all - loop 111.57 us/op 92.631 us/op 1.20
effectiveBalanceIncrements clone Uint8Array 300000 36.166 us/op 32.410 us/op 1.12
effectiveBalanceIncrements clone MutableVector 300000 354.00 ns/op 355.00 ns/op 1.00
effectiveBalanceIncrements rw all Uint8Array 300000 171.77 us/op 178.45 us/op 0.96
effectiveBalanceIncrements rw all MutableVector 300000 92.360 ms/op 81.617 ms/op 1.13
phase0 afterProcessEpoch - 250000 vs - 7PWei 119.58 ms/op 118.14 ms/op 1.01
phase0 beforeProcessEpoch - 250000 vs - 7PWei 44.260 ms/op 42.488 ms/op 1.04
altair processEpoch - mainnet_e81889 353.48 ms/op 363.51 ms/op 0.97
mainnet_e81889 - altair beforeProcessEpoch 60.672 ms/op 81.247 ms/op 0.75
mainnet_e81889 - altair processJustificationAndFinalization 20.196 us/op 28.110 us/op 0.72
mainnet_e81889 - altair processInactivityUpdates 5.6732 ms/op 8.9678 ms/op 0.63
mainnet_e81889 - altair processRewardsAndPenalties 66.463 ms/op 66.520 ms/op 1.00
mainnet_e81889 - altair processRegistryUpdates 2.2900 us/op 5.8380 us/op 0.39
mainnet_e81889 - altair processSlashings 497.00 ns/op 1.6980 us/op 0.29
mainnet_e81889 - altair processEth1DataReset 467.00 ns/op 1.5200 us/op 0.31
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2461 ms/op 1.7567 ms/op 0.71
mainnet_e81889 - altair processSlashingsReset 4.4670 us/op 9.1090 us/op 0.49
mainnet_e81889 - altair processRandaoMixesReset 4.2610 us/op 12.705 us/op 0.34
mainnet_e81889 - altair processHistoricalRootsUpdate 546.00 ns/op 1.8130 us/op 0.30
mainnet_e81889 - altair processParticipationFlagUpdates 2.7990 us/op 7.4300 us/op 0.38
mainnet_e81889 - altair processSyncCommitteeUpdates 2.4880 us/op 1.2730 us/op 1.95
mainnet_e81889 - altair afterProcessEpoch 128.96 ms/op 155.75 ms/op 0.83
phase0 processEpoch - mainnet_e58758 362.77 ms/op 453.88 ms/op 0.80
mainnet_e58758 - phase0 beforeProcessEpoch 138.93 ms/op 167.31 ms/op 0.83
mainnet_e58758 - phase0 processJustificationAndFinalization 17.651 us/op 37.860 us/op 0.47
mainnet_e58758 - phase0 processRewardsAndPenalties 64.409 ms/op 79.151 ms/op 0.81
mainnet_e58758 - phase0 processRegistryUpdates 8.0240 us/op 14.125 us/op 0.57
mainnet_e58758 - phase0 processSlashings 493.00 ns/op 979.00 ns/op 0.50
mainnet_e58758 - phase0 processEth1DataReset 539.00 ns/op 1.3960 us/op 0.39
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.0164 ms/op 1.3706 ms/op 0.74
mainnet_e58758 - phase0 processSlashingsReset 4.3320 us/op 10.633 us/op 0.41
mainnet_e58758 - phase0 processRandaoMixesReset 4.0530 us/op 9.4920 us/op 0.43
mainnet_e58758 - phase0 processHistoricalRootsUpdate 565.00 ns/op 1.6280 us/op 0.35
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.2510 us/op 11.794 us/op 0.36
mainnet_e58758 - phase0 afterProcessEpoch 99.738 ms/op 114.80 ms/op 0.87
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2550 ms/op 1.6314 ms/op 0.77
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.5524 ms/op 2.6036 ms/op 0.60
altair processInactivityUpdates - 250000 normalcase 26.244 ms/op 25.383 ms/op 1.03
altair processInactivityUpdates - 250000 worstcase 25.799 ms/op 29.248 ms/op 0.88
phase0 processRegistryUpdates - 250000 normalcase 7.5690 us/op 11.160 us/op 0.68
phase0 processRegistryUpdates - 250000 badcase_full_deposits 272.53 us/op 300.50 us/op 0.91
phase0 processRegistryUpdates - 250000 worstcase 0.5 120.18 ms/op 132.52 ms/op 0.91
altair processRewardsAndPenalties - 250000 normalcase 66.341 ms/op 60.977 ms/op 1.09
altair processRewardsAndPenalties - 250000 worstcase 68.296 ms/op 58.704 ms/op 1.16
phase0 getAttestationDeltas - 250000 normalcase 6.8211 ms/op 7.3212 ms/op 0.93
phase0 getAttestationDeltas - 250000 worstcase 6.7136 ms/op 7.3270 ms/op 0.92
phase0 processSlashings - 250000 worstcase 3.9413 ms/op 3.6003 ms/op 1.09
altair processSyncCommitteeUpdates - 250000 181.60 ms/op 202.29 ms/op 0.90
BeaconState.hashTreeRoot - No change 339.00 ns/op 286.00 ns/op 1.19
BeaconState.hashTreeRoot - 1 full validator 49.129 us/op 54.500 us/op 0.90
BeaconState.hashTreeRoot - 32 full validator 492.38 us/op 529.43 us/op 0.93
BeaconState.hashTreeRoot - 512 full validator 5.2271 ms/op 6.8293 ms/op 0.77
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 61.311 us/op 66.960 us/op 0.92
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 842.88 us/op 939.84 us/op 0.90
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 10.598 ms/op 13.067 ms/op 0.81
BeaconState.hashTreeRoot - 1 balances 46.556 us/op 54.645 us/op 0.85
BeaconState.hashTreeRoot - 32 balances 431.46 us/op 472.14 us/op 0.91
BeaconState.hashTreeRoot - 512 balances 3.9352 ms/op 4.9063 ms/op 0.80
BeaconState.hashTreeRoot - 250000 balances 74.483 ms/op 79.610 ms/op 0.94
aggregationBits - 2048 els - zipIndexesInBitList 16.611 us/op 22.219 us/op 0.75
regular array get 100000 times 44.328 us/op 45.280 us/op 0.98
wrappedArray get 100000 times 43.599 us/op 34.096 us/op 1.28
arrayWithProxy get 100000 times 16.609 ms/op 16.305 ms/op 1.02
ssz.Root.equals 552.00 ns/op 600.00 ns/op 0.92
byteArrayEquals 543.00 ns/op 629.00 ns/op 0.86
shuffle list - 16384 els 6.9610 ms/op 7.6007 ms/op 0.92
shuffle list - 250000 els 101.93 ms/op 107.26 ms/op 0.95
processSlot - 1 slots 8.7260 us/op 10.991 us/op 0.79
processSlot - 32 slots 1.3394 ms/op 1.5313 ms/op 0.87
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 36.066 ms/op 40.670 ms/op 0.89
getCommitteeAssignments - req 1 vs - 250000 vc 2.9987 ms/op 4.0993 ms/op 0.73
getCommitteeAssignments - req 100 vs - 250000 vc 4.2398 ms/op 4.4404 ms/op 0.95
getCommitteeAssignments - req 1000 vs - 250000 vc 4.6380 ms/op 5.5968 ms/op 0.83
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.3700 ns/op 5.7500 ns/op 0.93
state getBlockRootAtSlot - 250000 vs - 7PWei 772.97 ns/op 1.1064 us/op 0.70
computeProposers - vc 250000 12.139 ms/op 14.062 ms/op 0.86
computeEpochShuffling - vc 250000 116.10 ms/op 120.95 ms/op 0.96
getNextSyncCommittee - vc 250000 202.71 ms/op 280.22 ms/op 0.72
computeSigningRoot for AttestationData 14.371 us/op 18.416 us/op 0.78
hash AttestationData serialized data then Buffer.toString(base64) 2.5473 us/op 2.8441 us/op 0.90
toHexString serialized data 1.2457 us/op 2.6983 us/op 0.46
Buffer.toString(base64) 383.69 ns/op 514.33 ns/op 0.75

by benchmarkbot/action

@wemeetagain wemeetagain changed the title refactor!: use StatusCache in PeerManager refactor(network)!: use StatusCache in PeerManager May 1, 2023
@dapplion dapplion merged commit 342eb17 into unstable May 2, 2023
@dapplion dapplion deleted the cayman/status-cache branch May 2, 2023 02:19
@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