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

feat: handle chain stall in peer manager #7508

Open
wants to merge 6 commits into
base: unstable
Choose a base branch
from

Conversation

wemeetagain
Copy link
Member

Motivation

  • our peer management is pretty naive
  • during periods of long non-finality, we may have a lot of useless peers, and need to slowly churn through peers

Description

  • add starved check in the peer manager heartbeat
  • the node is starved when its head hasn't updates since the last heartbeat and is behind STARVATION_THRESHOLD_SLOTS
  • when the node is starved and has at least targetPeers, attempt to prune an additional targetPeers * STARVATION_PRUNE_RATIO peers
  • when the node is starved, disallow pruning of peers that are FAR_AHEAD of us
  • starved or not, adjust the sorting for pruning to disfavor pruning peers that are FAR_AHEAD of us

@wemeetagain wemeetagain requested a review from a team as a code owner February 27, 2025 18:50
Copy link
Contributor

github-actions bot commented Feb 27, 2025

Performance Report

🚀🚀 Significant benchmark improvement detected

Benchmark suite Current: 738104e Previous: 3cb84a8 Ratio
send data - 1000 65536B messages 256.32 ms/op 1.0819 s/op 0.24
Uint8Array.set - with subarray 1.5860 us/op 5.1440 us/op 0.31
forkChoice updateHead vc 600000 bc 1200 eq 0 2.9589 ms/op 10.534 ms/op 0.28
forkChoice updateHead vc 600000 bc 7200 eq 0 3.1902 ms/op 14.062 ms/op 0.23
forkChoice updateHead vc 600000 bc 64 eq 300000 14.781 ms/op 66.751 ms/op 0.22
Full benchmark results
Benchmark suite Current: 738104e Previous: 3cb84a8 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.0400 ms/op 2.2477 ms/op 0.46
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 38.301 us/op 53.733 us/op 0.71
BLS verify - blst 893.52 us/op 1.1043 ms/op 0.81
BLS verifyMultipleSignatures 3 - blst 1.3440 ms/op 1.6318 ms/op 0.82
BLS verifyMultipleSignatures 8 - blst 2.0752 ms/op 2.3938 ms/op 0.87
BLS verifyMultipleSignatures 32 - blst 6.3325 ms/op 8.0519 ms/op 0.79
BLS verifyMultipleSignatures 64 - blst 9.3077 ms/op 12.421 ms/op 0.75
BLS verifyMultipleSignatures 128 - blst 17.871 ms/op 21.382 ms/op 0.84
BLS deserializing 10000 signatures 700.31 ms/op 756.17 ms/op 0.93
BLS deserializing 100000 signatures 7.1269 s/op 7.9413 s/op 0.90
BLS verifyMultipleSignatures - same message - 3 - blst 988.68 us/op 1.1525 ms/op 0.86
BLS verifyMultipleSignatures - same message - 8 - blst 1.1307 ms/op 1.4854 ms/op 0.76
BLS verifyMultipleSignatures - same message - 32 - blst 1.9246 ms/op 1.9926 ms/op 0.97
BLS verifyMultipleSignatures - same message - 64 - blst 2.7804 ms/op 3.3959 ms/op 0.82
BLS verifyMultipleSignatures - same message - 128 - blst 4.7840 ms/op 5.0485 ms/op 0.95
BLS aggregatePubkeys 32 - blst 20.747 us/op 28.574 us/op 0.73
BLS aggregatePubkeys 128 - blst 72.636 us/op 74.585 us/op 0.97
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 58.126 ms/op 69.622 ms/op 0.83
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 51.660 ms/op 63.830 ms/op 0.81
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 42.300 ms/op 49.743 ms/op 0.85
getSlashingsAndExits - default max 81.884 us/op 135.70 us/op 0.60
getSlashingsAndExits - 2k 373.09 us/op 672.07 us/op 0.56
proposeBlockBody type=full, size=empty 5.1343 ms/op 5.5359 ms/op 0.93
isKnown best case - 1 super set check 218.00 ns/op 205.00 ns/op 1.06
isKnown normal case - 2 super set checks 203.00 ns/op 201.00 ns/op 1.01
isKnown worse case - 16 super set checks 201.00 ns/op 201.00 ns/op 1.00
InMemoryCheckpointStateCache - add get delete 2.5050 us/op 2.6400 us/op 0.95
validate api signedAggregateAndProof - struct 1.5104 ms/op 1.5643 ms/op 0.97
validate gossip signedAggregateAndProof - struct 1.6081 ms/op 1.7049 ms/op 0.94
batch validate gossip attestation - vc 640000 - chunk 32 131.19 us/op 148.78 us/op 0.88
batch validate gossip attestation - vc 640000 - chunk 64 113.68 us/op 161.46 us/op 0.70
batch validate gossip attestation - vc 640000 - chunk 128 110.91 us/op 172.52 us/op 0.64
batch validate gossip attestation - vc 640000 - chunk 256 111.63 us/op 183.17 us/op 0.61
pickEth1Vote - no votes 1.0393 ms/op 2.4024 ms/op 0.43
pickEth1Vote - max votes 8.0569 ms/op 18.949 ms/op 0.43
pickEth1Vote - Eth1Data hashTreeRoot value x2048 17.111 ms/op 33.313 ms/op 0.51
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 25.658 ms/op 49.617 ms/op 0.52
pickEth1Vote - Eth1Data fastSerialize value x2048 461.37 us/op 751.24 us/op 0.61
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.7833 ms/op 8.8750 ms/op 0.43
bytes32 toHexString 360.00 ns/op 1.0100 us/op 0.36
bytes32 Buffer.toString(hex) 257.00 ns/op 697.00 ns/op 0.37
bytes32 Buffer.toString(hex) from Uint8Array 374.00 ns/op 842.00 ns/op 0.44
bytes32 Buffer.toString(hex) + 0x 274.00 ns/op 568.00 ns/op 0.48
Object access 1 prop 0.12300 ns/op 0.28100 ns/op 0.44
Map access 1 prop 0.12900 ns/op 0.26000 ns/op 0.50
Object get x1000 6.0600 ns/op 11.314 ns/op 0.54
Map get x1000 6.3990 ns/op 12.725 ns/op 0.50
Object set x1000 30.603 ns/op 59.136 ns/op 0.52
Map set x1000 20.293 ns/op 44.130 ns/op 0.46
Return object 10000 times 0.29190 ns/op 0.56950 ns/op 0.51
Throw Error 10000 times 4.5568 us/op 8.5221 us/op 0.53
toHex 141.01 ns/op 283.72 ns/op 0.50
Buffer.from 140.42 ns/op 267.75 ns/op 0.52
shared Buffer 91.104 ns/op 161.26 ns/op 0.56
fastMsgIdFn sha256 / 200 bytes 2.2300 us/op 4.1790 us/op 0.53
fastMsgIdFn h32 xxhash / 200 bytes 205.00 ns/op 440.00 ns/op 0.47
fastMsgIdFn h64 xxhash / 200 bytes 284.00 ns/op 695.00 ns/op 0.41
fastMsgIdFn sha256 / 1000 bytes 7.2510 us/op 9.6640 us/op 0.75
fastMsgIdFn h32 xxhash / 1000 bytes 337.00 ns/op 376.00 ns/op 0.90
fastMsgIdFn h64 xxhash / 1000 bytes 371.00 ns/op 485.00 ns/op 0.76
fastMsgIdFn sha256 / 10000 bytes 65.307 us/op 73.251 us/op 0.89
fastMsgIdFn h32 xxhash / 10000 bytes 1.8340 us/op 1.9950 us/op 0.92
fastMsgIdFn h64 xxhash / 10000 bytes 1.2160 us/op 1.6860 us/op 0.72
send data - 1000 256B messages 14.474 ms/op 32.799 ms/op 0.44
send data - 1000 512B messages 19.408 ms/op 36.617 ms/op 0.53
send data - 1000 1024B messages 26.896 ms/op 54.481 ms/op 0.49
send data - 1000 1200B messages 23.328 ms/op 52.443 ms/op 0.44
send data - 1000 2048B messages 23.149 ms/op 54.804 ms/op 0.42
send data - 1000 4096B messages 29.747 ms/op 59.583 ms/op 0.50
send data - 1000 16384B messages 84.599 ms/op 113.30 ms/op 0.75
send data - 1000 65536B messages 256.32 ms/op 1.0819 s/op 0.24
enrSubnets - fastDeserialize 64 bits 895.00 ns/op 1.2280 us/op 0.73
enrSubnets - ssz BitVector 64 bits 359.00 ns/op 459.00 ns/op 0.78
enrSubnets - fastDeserialize 4 bits 140.00 ns/op 226.00 ns/op 0.62
enrSubnets - ssz BitVector 4 bits 332.00 ns/op 753.00 ns/op 0.44
array of 16000 items push then shift 1.6214 us/op 1.8118 us/op 0.89
LinkedList of 16000 items push then shift 7.5250 ns/op 13.393 ns/op 0.56
array of 16000 items push then pop 77.113 ns/op 109.63 ns/op 0.70
LinkedList of 16000 items push then pop 7.2130 ns/op 16.001 ns/op 0.45
array of 24000 items push then shift 2.3915 us/op 3.9514 us/op 0.61
LinkedList of 24000 items push then shift 7.4980 ns/op 13.956 ns/op 0.54
array of 24000 items push then pop 101.34 ns/op 189.96 ns/op 0.53
LinkedList of 24000 items push then pop 7.1140 ns/op 12.348 ns/op 0.58
intersect bitArray bitLen 8 6.3580 ns/op 11.873 ns/op 0.54
intersect array and set length 8 38.409 ns/op 76.339 ns/op 0.50
intersect bitArray bitLen 128 30.173 ns/op 63.721 ns/op 0.47
intersect array and set length 128 629.53 ns/op 1.2686 us/op 0.50
bitArray.getTrueBitIndexes() bitLen 128 1.0500 us/op 1.9600 us/op 0.54
bitArray.getTrueBitIndexes() bitLen 248 1.8850 us/op 3.4070 us/op 0.55
bitArray.getTrueBitIndexes() bitLen 512 3.7670 us/op 6.8830 us/op 0.55
Buffer.concat 32 items 673.00 ns/op 1.3080 us/op 0.51
Uint8Array.set 32 items 1.0830 us/op 3.1250 us/op 0.35
Buffer.copy 2.2560 us/op 6.1920 us/op 0.36
Uint8Array.set - with subarray 1.5860 us/op 5.1440 us/op 0.31
Uint8Array.set - without subarray 991.00 ns/op 2.8510 us/op 0.35
getUint32 - dataview 221.00 ns/op 313.00 ns/op 0.71
getUint32 - manual 122.00 ns/op 221.00 ns/op 0.55
Set add up to 64 items then delete first 2.3538 us/op 3.9614 us/op 0.59
OrderedSet add up to 64 items then delete first 3.3783 us/op 5.6607 us/op 0.60
Set add up to 64 items then delete last 2.9058 us/op 4.5545 us/op 0.64
OrderedSet add up to 64 items then delete last 4.1090 us/op 6.1484 us/op 0.67
Set add up to 64 items then delete middle 2.5915 us/op 4.3257 us/op 0.60
OrderedSet add up to 64 items then delete middle 5.9003 us/op 7.1970 us/op 0.82
Set add up to 128 items then delete first 5.6913 us/op 9.9672 us/op 0.57
OrderedSet add up to 128 items then delete first 8.8961 us/op 18.878 us/op 0.47
Set add up to 128 items then delete last 6.0841 us/op 9.4735 us/op 0.64
OrderedSet add up to 128 items then delete last 8.6605 us/op 11.954 us/op 0.72
Set add up to 128 items then delete middle 5.8223 us/op 7.3111 us/op 0.80
OrderedSet add up to 128 items then delete middle 15.971 us/op 19.123 us/op 0.84
Set add up to 256 items then delete first 12.383 us/op 22.281 us/op 0.56
OrderedSet add up to 256 items then delete first 18.606 us/op 28.950 us/op 0.64
Set add up to 256 items then delete last 10.971 us/op 21.917 us/op 0.50
OrderedSet add up to 256 items then delete last 15.634 us/op 43.450 us/op 0.36
Set add up to 256 items then delete middle 11.267 us/op 23.867 us/op 0.47
OrderedSet add up to 256 items then delete middle 45.804 us/op 82.745 us/op 0.55
transfer serialized Status (84 B) 2.5300 us/op 6.6390 us/op 0.38
copy serialized Status (84 B) 1.2230 us/op 3.7050 us/op 0.33
transfer serialized SignedVoluntaryExit (112 B) 2.3170 us/op 4.5930 us/op 0.50
copy serialized SignedVoluntaryExit (112 B) 1.3790 us/op 3.0200 us/op 0.46
transfer serialized ProposerSlashing (416 B) 2.3470 us/op 6.5010 us/op 0.36
copy serialized ProposerSlashing (416 B) 1.5500 us/op 3.2990 us/op 0.47
transfer serialized Attestation (485 B) 2.9810 us/op 5.2580 us/op 0.57
copy serialized Attestation (485 B) 1.7490 us/op 4.0170 us/op 0.44
transfer serialized AttesterSlashing (33232 B) 2.8180 us/op 5.4360 us/op 0.52
copy serialized AttesterSlashing (33232 B) 4.8630 us/op 9.1030 us/op 0.53
transfer serialized Small SignedBeaconBlock (128000 B) 3.2440 us/op 7.5250 us/op 0.43
copy serialized Small SignedBeaconBlock (128000 B) 12.391 us/op 21.909 us/op 0.57
transfer serialized Avg SignedBeaconBlock (200000 B) 4.0740 us/op 5.9330 us/op 0.69
copy serialized Avg SignedBeaconBlock (200000 B) 16.936 us/op 34.681 us/op 0.49
transfer serialized BlobsSidecar (524380 B) 4.0090 us/op 8.0070 us/op 0.50
copy serialized BlobsSidecar (524380 B) 68.390 us/op 214.76 us/op 0.32
transfer serialized Big SignedBeaconBlock (1000000 B) 4.0180 us/op 12.060 us/op 0.33
copy serialized Big SignedBeaconBlock (1000000 B) 115.06 us/op 292.21 us/op 0.39
pass gossip attestations to forkchoice per slot 2.8626 ms/op 6.1357 ms/op 0.47
forkChoice updateHead vc 100000 bc 64 eq 0 467.94 us/op 562.34 us/op 0.83
forkChoice updateHead vc 600000 bc 64 eq 0 2.9262 ms/op 7.4598 ms/op 0.39
forkChoice updateHead vc 1000000 bc 64 eq 0 4.9426 ms/op 10.123 ms/op 0.49
forkChoice updateHead vc 600000 bc 320 eq 0 2.9222 ms/op 7.6471 ms/op 0.38
forkChoice updateHead vc 600000 bc 1200 eq 0 2.9589 ms/op 10.534 ms/op 0.28
forkChoice updateHead vc 600000 bc 7200 eq 0 3.1902 ms/op 14.062 ms/op 0.23
forkChoice updateHead vc 600000 bc 64 eq 1000 10.695 ms/op 13.041 ms/op 0.82
forkChoice updateHead vc 600000 bc 64 eq 10000 10.589 ms/op 14.572 ms/op 0.73
forkChoice updateHead vc 600000 bc 64 eq 300000 14.781 ms/op 66.751 ms/op 0.22
computeDeltas 500000 validators 300 proto nodes 4.0591 ms/op 7.0144 ms/op 0.58
computeDeltas 500000 validators 1200 proto nodes 4.2353 ms/op 6.1322 ms/op 0.69
computeDeltas 500000 validators 7200 proto nodes 4.5092 ms/op 4.8196 ms/op 0.94
computeDeltas 750000 validators 300 proto nodes 6.2655 ms/op 6.5825 ms/op 0.95
computeDeltas 750000 validators 1200 proto nodes 6.2801 ms/op 6.2311 ms/op 1.01
computeDeltas 750000 validators 7200 proto nodes 6.2690 ms/op 6.9635 ms/op 0.90
computeDeltas 1400000 validators 300 proto nodes 11.068 ms/op 13.352 ms/op 0.83
computeDeltas 1400000 validators 1200 proto nodes 11.102 ms/op 15.459 ms/op 0.72
computeDeltas 1400000 validators 7200 proto nodes 11.023 ms/op 14.622 ms/op 0.75
computeDeltas 2100000 validators 300 proto nodes 16.500 ms/op 18.662 ms/op 0.88
computeDeltas 2100000 validators 1200 proto nodes 16.891 ms/op 16.824 ms/op 1.00
computeDeltas 2100000 validators 7200 proto nodes 16.969 ms/op 18.134 ms/op 0.94
altair processAttestation - 250000 vs - 7PWei normalcase 2.1106 ms/op 5.2833 ms/op 0.40
altair processAttestation - 250000 vs - 7PWei worstcase 3.2934 ms/op 4.8573 ms/op 0.68
altair processAttestation - setStatus - 1/6 committees join 124.87 us/op 155.46 us/op 0.80
altair processAttestation - setStatus - 1/3 committees join 240.87 us/op 283.30 us/op 0.85
altair processAttestation - setStatus - 1/2 committees join 359.15 us/op 395.98 us/op 0.91
altair processAttestation - setStatus - 2/3 committees join 450.30 us/op 477.48 us/op 0.94
altair processAttestation - setStatus - 4/5 committees join 618.96 us/op 632.84 us/op 0.98
altair processAttestation - setStatus - 100% committees join 737.24 us/op 765.78 us/op 0.96
altair processBlock - 250000 vs - 7PWei normalcase 6.2845 ms/op 8.6099 ms/op 0.73
altair processBlock - 250000 vs - 7PWei normalcase hashState 33.116 ms/op 34.257 ms/op 0.97
altair processBlock - 250000 vs - 7PWei worstcase 40.800 ms/op 41.203 ms/op 0.99
altair processBlock - 250000 vs - 7PWei worstcase hashState 93.947 ms/op 76.465 ms/op 1.23
phase0 processBlock - 250000 vs - 7PWei normalcase 1.9982 ms/op 1.5868 ms/op 1.26
phase0 processBlock - 250000 vs - 7PWei worstcase 25.752 ms/op 24.351 ms/op 1.06
altair processEth1Data - 250000 vs - 7PWei normalcase 356.12 us/op 340.21 us/op 1.05
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 5.8330 us/op 6.7990 us/op 0.86
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 37.288 us/op 36.649 us/op 1.02
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 9.9410 us/op 12.565 us/op 0.79
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 6.1230 us/op 7.1790 us/op 0.85
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 169.84 us/op 134.53 us/op 1.26
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.2506 ms/op 1.3198 ms/op 0.95
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.7545 ms/op 1.5298 ms/op 1.15
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.7422 ms/op 1.5747 ms/op 1.11
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 3.5472 ms/op 3.5070 ms/op 1.01
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.5107 ms/op 1.6849 ms/op 0.90
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 3.4688 ms/op 3.6491 ms/op 0.95
Tree 40 250000 create 438.65 ms/op 504.60 ms/op 0.87
Tree 40 250000 get(125000) 149.47 ns/op 146.40 ns/op 1.02
Tree 40 250000 set(125000) 1.4759 us/op 1.6135 us/op 0.91
Tree 40 250000 toArray() 20.912 ms/op 23.306 ms/op 0.90
Tree 40 250000 iterate all - toArray() + loop 20.860 ms/op 22.532 ms/op 0.93
Tree 40 250000 iterate all - get(i) 59.786 ms/op 62.942 ms/op 0.95
Array 250000 create 2.5446 ms/op 3.9795 ms/op 0.64
Array 250000 clone - spread 823.62 us/op 1.7785 ms/op 0.46
Array 250000 get(125000) 0.40700 ns/op 0.41100 ns/op 0.99
Array 250000 set(125000) 0.43500 ns/op 0.43300 ns/op 1.00
Array 250000 iterate all - loop 100.60 us/op 103.89 us/op 0.97
phase0 afterProcessEpoch - 250000 vs - 7PWei 50.222 ms/op 49.197 ms/op 1.02
Array.fill - length 1000000 3.5600 ms/op 3.4992 ms/op 1.02
Array push - length 1000000 15.163 ms/op 17.534 ms/op 0.86
Array.get 0.27595 ns/op 0.28124 ns/op 0.98
Uint8Array.get 0.44205 ns/op 0.45520 ns/op 0.97
phase0 beforeProcessEpoch - 250000 vs - 7PWei 17.392 ms/op 21.130 ms/op 0.82
altair processEpoch - mainnet_e81889 278.99 ms/op 289.95 ms/op 0.96
mainnet_e81889 - altair beforeProcessEpoch 19.721 ms/op 23.197 ms/op 0.85
mainnet_e81889 - altair processJustificationAndFinalization 5.6770 us/op 7.5350 us/op 0.75
mainnet_e81889 - altair processInactivityUpdates 4.1409 ms/op 7.1141 ms/op 0.58
mainnet_e81889 - altair processRewardsAndPenalties 48.283 ms/op 39.337 ms/op 1.23
mainnet_e81889 - altair processRegistryUpdates 723.00 ns/op 767.00 ns/op 0.94
mainnet_e81889 - altair processSlashings 180.00 ns/op 179.00 ns/op 1.01
mainnet_e81889 - altair processEth1DataReset 174.00 ns/op 179.00 ns/op 0.97
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2705 ms/op 1.3272 ms/op 0.96
mainnet_e81889 - altair processSlashingsReset 1.0490 us/op 896.00 ns/op 1.17
mainnet_e81889 - altair processRandaoMixesReset 1.2180 us/op 1.1300 us/op 1.08
mainnet_e81889 - altair processHistoricalRootsUpdate 193.00 ns/op 177.00 ns/op 1.09
mainnet_e81889 - altair processParticipationFlagUpdates 519.00 ns/op 528.00 ns/op 0.98
mainnet_e81889 - altair processSyncCommitteeUpdates 143.00 ns/op 136.00 ns/op 1.05
mainnet_e81889 - altair afterProcessEpoch 53.623 ms/op 52.476 ms/op 1.02
capella processEpoch - mainnet_e217614 1.0115 s/op 1.0871 s/op 0.93
mainnet_e217614 - capella beforeProcessEpoch 69.705 ms/op 78.899 ms/op 0.88
mainnet_e217614 - capella processJustificationAndFinalization 5.3780 us/op 5.9520 us/op 0.90
mainnet_e217614 - capella processInactivityUpdates 16.385 ms/op 16.956 ms/op 0.97
mainnet_e217614 - capella processRewardsAndPenalties 195.56 ms/op 187.84 ms/op 1.04
mainnet_e217614 - capella processRegistryUpdates 7.9190 us/op 6.5070 us/op 1.22
mainnet_e217614 - capella processSlashings 193.00 ns/op 182.00 ns/op 1.06
mainnet_e217614 - capella processEth1DataReset 172.00 ns/op 181.00 ns/op 0.95
mainnet_e217614 - capella processEffectiveBalanceUpdates 10.606 ms/op 14.206 ms/op 0.75
mainnet_e217614 - capella processSlashingsReset 1.0160 us/op 916.00 ns/op 1.11
mainnet_e217614 - capella processRandaoMixesReset 1.3170 us/op 1.2150 us/op 1.08
mainnet_e217614 - capella processHistoricalRootsUpdate 198.00 ns/op 196.00 ns/op 1.01
mainnet_e217614 - capella processParticipationFlagUpdates 553.00 ns/op 525.00 ns/op 1.05
mainnet_e217614 - capella afterProcessEpoch 126.65 ms/op 126.33 ms/op 1.00
phase0 processEpoch - mainnet_e58758 310.73 ms/op 320.79 ms/op 0.97
mainnet_e58758 - phase0 beforeProcessEpoch 81.795 ms/op 76.335 ms/op 1.07
mainnet_e58758 - phase0 processJustificationAndFinalization 6.4660 us/op 5.5970 us/op 1.16
mainnet_e58758 - phase0 processRewardsAndPenalties 38.717 ms/op 37.062 ms/op 1.04
mainnet_e58758 - phase0 processRegistryUpdates 3.6670 us/op 3.1500 us/op 1.16
mainnet_e58758 - phase0 processSlashings 193.00 ns/op 177.00 ns/op 1.09
mainnet_e58758 - phase0 processEth1DataReset 175.00 ns/op 173.00 ns/op 1.01
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.0227 ms/op 1.0349 ms/op 0.99
mainnet_e58758 - phase0 processSlashingsReset 1.0600 us/op 1.0160 us/op 1.04
mainnet_e58758 - phase0 processRandaoMixesReset 1.1890 us/op 1.1790 us/op 1.01
mainnet_e58758 - phase0 processHistoricalRootsUpdate 205.00 ns/op 175.00 ns/op 1.17
mainnet_e58758 - phase0 processParticipationRecordUpdates 1.0010 us/op 859.00 ns/op 1.17
mainnet_e58758 - phase0 afterProcessEpoch 45.198 ms/op 43.164 ms/op 1.05
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.6412 ms/op 1.3562 ms/op 1.21
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 3.0235 ms/op 1.9398 ms/op 1.56
altair processInactivityUpdates - 250000 normalcase 18.519 ms/op 18.090 ms/op 1.02
altair processInactivityUpdates - 250000 worstcase 19.201 ms/op 17.944 ms/op 1.07
phase0 processRegistryUpdates - 250000 normalcase 7.0590 us/op 7.1200 us/op 0.99
phase0 processRegistryUpdates - 250000 badcase_full_deposits 353.71 us/op 287.38 us/op 1.23
phase0 processRegistryUpdates - 250000 worstcase 0.5 111.49 ms/op 109.29 ms/op 1.02
altair processRewardsAndPenalties - 250000 normalcase 38.215 ms/op 50.476 ms/op 0.76
altair processRewardsAndPenalties - 250000 worstcase 51.060 ms/op 33.712 ms/op 1.51
phase0 getAttestationDeltas - 250000 normalcase 6.4185 ms/op 8.3116 ms/op 0.77
phase0 getAttestationDeltas - 250000 worstcase 8.9378 ms/op 6.2838 ms/op 1.42
phase0 processSlashings - 250000 worstcase 113.56 us/op 107.35 us/op 1.06
altair processSyncCommitteeUpdates - 250000 139.69 ms/op 124.31 ms/op 1.12
BeaconState.hashTreeRoot - No change 251.00 ns/op 209.00 ns/op 1.20
BeaconState.hashTreeRoot - 1 full validator 92.187 us/op 76.844 us/op 1.20
BeaconState.hashTreeRoot - 32 full validator 1.0239 ms/op 800.03 us/op 1.28
BeaconState.hashTreeRoot - 512 full validator 13.006 ms/op 11.503 ms/op 1.13
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 113.66 us/op 92.453 us/op 1.23
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.5883 ms/op 1.3280 ms/op 1.20
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 25.717 ms/op 20.025 ms/op 1.28
BeaconState.hashTreeRoot - 1 balances 85.320 us/op 77.437 us/op 1.10
BeaconState.hashTreeRoot - 32 balances 712.74 us/op 874.64 us/op 0.81
BeaconState.hashTreeRoot - 512 balances 8.9684 ms/op 9.2412 ms/op 0.97
BeaconState.hashTreeRoot - 250000 balances 166.91 ms/op 190.07 ms/op 0.88
aggregationBits - 2048 els - zipIndexesInBitList 22.610 us/op 22.254 us/op 1.02
byteArrayEquals 32 55.574 ns/op 53.156 ns/op 1.05
Buffer.compare 32 17.887 ns/op 16.995 ns/op 1.05
byteArrayEquals 1024 1.6511 us/op 1.6023 us/op 1.03
Buffer.compare 1024 26.408 ns/op 25.592 ns/op 1.03
byteArrayEquals 16384 26.780 us/op 25.450 us/op 1.05
Buffer.compare 16384 205.69 ns/op 181.95 ns/op 1.13
byteArrayEquals 123687377 208.78 ms/op 196.47 ms/op 1.06
Buffer.compare 123687377 8.2310 ms/op 11.785 ms/op 0.70
byteArrayEquals 32 - diff last byte 54.054 ns/op 55.574 ns/op 0.97
Buffer.compare 32 - diff last byte 17.602 ns/op 20.014 ns/op 0.88
byteArrayEquals 1024 - diff last byte 1.6295 us/op 1.7355 us/op 0.94
Buffer.compare 1024 - diff last byte 25.807 ns/op 29.786 ns/op 0.87
byteArrayEquals 16384 - diff last byte 26.256 us/op 27.557 us/op 0.95
Buffer.compare 16384 - diff last byte 210.38 ns/op 207.23 ns/op 1.02
byteArrayEquals 123687377 - diff last byte 201.62 ms/op 212.04 ms/op 0.95
Buffer.compare 123687377 - diff last byte 7.9579 ms/op 9.4594 ms/op 0.84
byteArrayEquals 32 - random bytes 5.2830 ns/op 5.3030 ns/op 1.00
Buffer.compare 32 - random bytes 17.979 ns/op 18.322 ns/op 0.98
byteArrayEquals 1024 - random bytes 5.6800 ns/op 5.4230 ns/op 1.05
Buffer.compare 1024 - random bytes 17.782 ns/op 18.067 ns/op 0.98
byteArrayEquals 16384 - random bytes 5.3160 ns/op 5.3570 ns/op 0.99
Buffer.compare 16384 - random bytes 17.796 ns/op 18.133 ns/op 0.98
byteArrayEquals 123687377 - random bytes 7.7500 ns/op 6.7400 ns/op 1.15
Buffer.compare 123687377 - random bytes 20.090 ns/op 19.070 ns/op 1.05
regular array get 100000 times 35.561 us/op 43.205 us/op 0.82
wrappedArray get 100000 times 45.503 us/op 35.260 us/op 1.29
arrayWithProxy get 100000 times 14.884 ms/op 17.740 ms/op 0.84
ssz.Root.equals 47.072 ns/op 47.751 ns/op 0.99
byteArrayEquals 46.439 ns/op 46.992 ns/op 0.99
Buffer.compare 11.145 ns/op 10.707 ns/op 1.04
processSlot - 1 slots 14.876 us/op 10.795 us/op 1.38
processSlot - 32 slots 2.5990 ms/op 2.1234 ms/op 1.22
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 60.630 ms/op 56.456 ms/op 1.07
getCommitteeAssignments - req 1 vs - 250000 vc 2.4551 ms/op 2.1765 ms/op 1.13
getCommitteeAssignments - req 100 vs - 250000 vc 4.7539 ms/op 4.3018 ms/op 1.11
getCommitteeAssignments - req 1000 vs - 250000 vc 4.9531 ms/op 4.6003 ms/op 1.08
findModifiedValidators - 10000 modified validators 894.26 ms/op 821.31 ms/op 1.09
findModifiedValidators - 1000 modified validators 769.64 ms/op 797.43 ms/op 0.97
findModifiedValidators - 100 modified validators 258.59 ms/op 287.12 ms/op 0.90
findModifiedValidators - 10 modified validators 263.97 ms/op 318.10 ms/op 0.83
findModifiedValidators - 1 modified validators 276.06 ms/op 176.81 ms/op 1.56
findModifiedValidators - no difference 160.08 ms/op 340.31 ms/op 0.47
compare ViewDUs 6.6671 s/op 9.0110 s/op 0.74
compare each validator Uint8Array 1.3793 s/op 1.7837 s/op 0.77
compare ViewDU to Uint8Array 1.1176 s/op 1.5012 s/op 0.74
migrate state 1000000 validators, 24 modified, 0 new 886.48 ms/op 1.1816 s/op 0.75
migrate state 1000000 validators, 1700 modified, 1000 new 1.0923 s/op 1.6886 s/op 0.65
migrate state 1000000 validators, 3400 modified, 2000 new 1.2531 s/op 1.6261 s/op 0.77
migrate state 1500000 validators, 24 modified, 0 new 906.40 ms/op 1.2226 s/op 0.74
migrate state 1500000 validators, 1700 modified, 1000 new 1.1230 s/op 1.6706 s/op 0.67
migrate state 1500000 validators, 3400 modified, 2000 new 1.3142 s/op 1.8591 s/op 0.71
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.5700 ns/op 4.7300 ns/op 0.97
state getBlockRootAtSlot - 250000 vs - 7PWei 601.58 ns/op 799.41 ns/op 0.75
naive computeProposerIndex 100000 validators 55.658 ms/op 69.389 ms/op 0.80
computeProposerIndex 100000 validators 9.7595 ms/op 14.502 ms/op 0.67
naiveGetNextSyncCommitteeIndices 1000 validators 8.6710 s/op 9.0397 s/op 0.96
getNextSyncCommitteeIndices 1000 validators 283.77 ms/op 298.15 ms/op 0.95
naiveGetNextSyncCommitteeIndices 10000 validators 7.9833 s/op 9.5099 s/op 0.84
getNextSyncCommitteeIndices 10000 validators 275.23 ms/op 293.02 ms/op 0.94
naiveGetNextSyncCommitteeIndices 100000 validators 8.8038 s/op 9.5610 s/op 0.92
getNextSyncCommitteeIndices 100000 validators 337.72 ms/op 319.26 ms/op 1.06
naive computeShuffledIndex 100000 validators 28.107 s/op 29.732 s/op 0.95
cached computeShuffledIndex 100000 validators 669.65 ms/op 692.26 ms/op 0.97
naive computeShuffledIndex 2000000 validators 456.82 s/op 566.71 s/op 0.81
cached computeShuffledIndex 2000000 validators 43.071 s/op 65.296 s/op 0.66
computeProposers - vc 250000 9.3213 ms/op 9.7238 ms/op 0.96
computeEpochShuffling - vc 250000 41.791 ms/op 43.933 ms/op 0.95
getNextSyncCommittee - vc 250000 136.88 ms/op 141.78 ms/op 0.97
computeSigningRoot for AttestationData 18.699 us/op 34.888 us/op 0.54
hash AttestationData serialized data then Buffer.toString(base64) 1.6292 us/op 1.7086 us/op 0.95
toHexString serialized data 1.1753 us/op 1.4239 us/op 0.83
Buffer.toString(base64) 174.22 ns/op 173.38 ns/op 1.00
nodejs block root to RootHex using toHex 147.77 ns/op 145.88 ns/op 1.01
nodejs block root to RootHex using toRootHex 97.292 ns/op 84.049 ns/op 1.16
browser block root to RootHex using the deprecated toHexString 217.37 ns/op 220.41 ns/op 0.99
browser block root to RootHex using toHex 183.61 ns/op 177.98 ns/op 1.03
browser block root to RootHex using toRootHex 172.77 ns/op 164.71 ns/op 1.05

by benchmarkbot/action

nflaig
nflaig previously approved these changes Mar 11, 2025
Copy link
Member

@nflaig nflaig left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - we have tested this for a while on holesky-rescue branch and it was very useful to speed up our sync times + retrieving more details about our connected peers, see discord thread for more details

return StatusScore.FAR_AHEAD;
}

// It seems dangerous to downscore peers that are far behind.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if we ever return FAR_BEHIND, then lodestar nodes will most likely disconnect peers that want to sync from us which is not great for the network. Should we remove FAR_BEHIND completely? or add more info for it

if we delete FAR_BEHIND enum then there is only 2 options: CLOSE_TO_US and FAR_AHEAD. At synced time, this function will always return CLOSE_TO_US. Hence the main usage for this function is for syncing time

please add all of these to the function description for later reference

Copy link
Contributor

@twoeths twoeths left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the feature is great, I dropped some comments/suggestions

@@ -111,6 +111,10 @@ export function createNetworkCoreMetrics(register: RegistryMetricCreator) {
help: "Peer manager heartbeat function duration in seconds",
buckets: [0.001, 0.01, 0.1, 1],
}),
starved: register.gauge({
name: "lodestar_peer_manager_starved_bool",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if you have time would be good to add a panel somewhere that uses the bool

@nflaig nflaig enabled auto-merge (squash) March 14, 2025 18:13
@nflaig nflaig disabled auto-merge March 15, 2025 09:57
@nflaig
Copy link
Member

nflaig commented Mar 15, 2025

seems like we need to update tests here

describe("network / peers / priorization", async () => {
I leave this up to you @wemeetagain to make sure it's done correctly, I don't think we need this in 1.28, so there is no rush

@nflaig nflaig added this to the v1.29.0 milestone Mar 24, 2025
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.

3 participants