Skip to content

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
@github-actions
Copy link
Contributor

github-actions bot commented Feb 27, 2025

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 796ed4b Previous: 185bc83 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 911.71 us/op 781.99 us/op 1.17
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 34.764 us/op 29.145 us/op 1.19
BLS verify - blst 716.57 us/op 884.75 us/op 0.81
BLS verifyMultipleSignatures 3 - blst 1.1841 ms/op 1.3072 ms/op 0.91
BLS verifyMultipleSignatures 8 - blst 1.6464 ms/op 2.2342 ms/op 0.74
BLS verifyMultipleSignatures 32 - blst 4.8819 ms/op 4.5502 ms/op 1.07
BLS verifyMultipleSignatures 64 - blst 9.0172 ms/op 8.4861 ms/op 1.06
BLS verifyMultipleSignatures 128 - blst 17.194 ms/op 16.145 ms/op 1.06
BLS deserializing 10000 signatures 686.21 ms/op 605.77 ms/op 1.13
BLS deserializing 100000 signatures 6.8441 s/op 6.0681 s/op 1.13
BLS verifyMultipleSignatures - same message - 3 - blst 898.19 us/op 942.78 us/op 0.95
BLS verifyMultipleSignatures - same message - 8 - blst 1.0160 ms/op 1.0901 ms/op 0.93
BLS verifyMultipleSignatures - same message - 32 - blst 1.6732 ms/op 1.7329 ms/op 0.97
BLS verifyMultipleSignatures - same message - 64 - blst 2.5223 ms/op 2.6087 ms/op 0.97
BLS verifyMultipleSignatures - same message - 128 - blst 4.3161 ms/op 4.2607 ms/op 1.01
BLS aggregatePubkeys 32 - blst 19.213 us/op 17.903 us/op 1.07
BLS aggregatePubkeys 128 - blst 69.021 us/op 63.151 us/op 1.09
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 45.187 ms/op 49.282 ms/op 0.92
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 44.092 ms/op 38.379 ms/op 1.15
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 35.015 ms/op 37.165 ms/op 0.94
getSlashingsAndExits - default max 73.599 us/op 50.751 us/op 1.45
getSlashingsAndExits - 2k 273.82 us/op 296.97 us/op 0.92
proposeBlockBody type=full, size=empty 5.3340 ms/op 5.3892 ms/op 0.99
isKnown best case - 1 super set check 200.00 ns/op 396.00 ns/op 0.51
isKnown normal case - 2 super set checks 196.00 ns/op 397.00 ns/op 0.49
isKnown worse case - 16 super set checks 196.00 ns/op 396.00 ns/op 0.49
InMemoryCheckpointStateCache - add get delete 2.3650 us/op 2.4340 us/op 0.97
validate api signedAggregateAndProof - struct 1.3561 ms/op 1.4637 ms/op 0.93
validate gossip signedAggregateAndProof - struct 1.3373 ms/op 1.4935 ms/op 0.90
batch validate gossip attestation - vc 640000 - chunk 32 112.58 us/op 109.44 us/op 1.03
batch validate gossip attestation - vc 640000 - chunk 64 100.17 us/op 95.511 us/op 1.05
batch validate gossip attestation - vc 640000 - chunk 128 94.691 us/op 86.114 us/op 1.10
batch validate gossip attestation - vc 640000 - chunk 256 94.665 us/op 87.327 us/op 1.08
pickEth1Vote - no votes 955.75 us/op 810.84 us/op 1.18
pickEth1Vote - max votes 6.5503 ms/op 6.3174 ms/op 1.04
pickEth1Vote - Eth1Data hashTreeRoot value x2048 10.791 ms/op 9.6943 ms/op 1.11
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 16.234 ms/op 12.855 ms/op 1.26
pickEth1Vote - Eth1Data fastSerialize value x2048 487.25 us/op 332.44 us/op 1.47
pickEth1Vote - Eth1Data fastSerialize tree x2048 2.5892 ms/op 1.9258 ms/op 1.34
bytes32 toHexString 361.00 ns/op 503.00 ns/op 0.72
bytes32 Buffer.toString(hex) 250.00 ns/op 492.00 ns/op 0.51
bytes32 Buffer.toString(hex) from Uint8Array 341.00 ns/op 502.00 ns/op 0.68
bytes32 Buffer.toString(hex) + 0x 251.00 ns/op 418.00 ns/op 0.60
Object access 1 prop 0.12300 ns/op 0.35700 ns/op 0.34
Map access 1 prop 0.13000 ns/op 0.32000 ns/op 0.41
Object get x1000 6.0390 ns/op 4.9600 ns/op 1.22
Map get x1000 6.2080 ns/op 5.4790 ns/op 1.13
Object set x1000 28.209 ns/op 20.235 ns/op 1.39
Map set x1000 19.338 ns/op 17.041 ns/op 1.13
Return object 10000 times 0.28530 ns/op 0.28840 ns/op 0.99
Throw Error 10000 times 4.2505 us/op 3.6130 us/op 1.18
toHex 136.72 ns/op 108.66 ns/op 1.26
Buffer.from 135.70 ns/op 92.970 ns/op 1.46
shared Buffer 87.808 ns/op 61.789 ns/op 1.42
fastMsgIdFn sha256 / 200 bytes 2.2320 us/op 1.8650 us/op 1.20
fastMsgIdFn h32 xxhash / 200 bytes 205.00 ns/op 377.00 ns/op 0.54
fastMsgIdFn h64 xxhash / 200 bytes 266.00 ns/op 431.00 ns/op 0.62
fastMsgIdFn sha256 / 1000 bytes 7.2220 us/op 5.6050 us/op 1.29
fastMsgIdFn h32 xxhash / 1000 bytes 334.00 ns/op 497.00 ns/op 0.67
fastMsgIdFn h64 xxhash / 1000 bytes 335.00 ns/op 510.00 ns/op 0.66
fastMsgIdFn sha256 / 10000 bytes 64.615 us/op 49.151 us/op 1.31
fastMsgIdFn h32 xxhash / 10000 bytes 1.8160 us/op 2.0460 us/op 0.89
fastMsgIdFn h64 xxhash / 10000 bytes 1.2060 us/op 1.3520 us/op 0.89
send data - 1000 256B messages 11.138 ms/op 12.643 ms/op 0.88
send data - 1000 512B messages 16.088 ms/op 18.608 ms/op 0.86
send data - 1000 1024B messages 25.415 ms/op 22.236 ms/op 1.14
send data - 1000 1200B messages 21.068 ms/op 17.035 ms/op 1.24
send data - 1000 2048B messages 20.990 ms/op 17.004 ms/op 1.23
send data - 1000 4096B messages 23.443 ms/op 27.635 ms/op 0.85
send data - 1000 16384B messages 74.960 ms/op 47.319 ms/op 1.58
send data - 1000 65536B messages 207.53 ms/op 305.73 ms/op 0.68
enrSubnets - fastDeserialize 64 bits 908.00 ns/op 946.00 ns/op 0.96
enrSubnets - ssz BitVector 64 bits 317.00 ns/op 500.00 ns/op 0.63
enrSubnets - fastDeserialize 4 bits 127.00 ns/op 326.00 ns/op 0.39
enrSubnets - ssz BitVector 4 bits 316.00 ns/op 497.00 ns/op 0.64
prioritizePeers score -10:0 att 32-0.1 sync 2-0 121.86 us/op 126.04 us/op 0.97
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 142.80 us/op 124.24 us/op 1.15
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 206.15 us/op 186.49 us/op 1.11
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 372.73 us/op 335.53 us/op 1.11
prioritizePeers score 0:0 att 64-1 sync 4-1 456.36 us/op 402.33 us/op 1.13
array of 16000 items push then shift 1.5881 us/op 1.2482 us/op 1.27
LinkedList of 16000 items push then shift 6.9990 ns/op 8.0320 ns/op 0.87
array of 16000 items push then pop 75.190 ns/op 76.580 ns/op 0.98
LinkedList of 16000 items push then pop 6.9160 ns/op 6.5150 ns/op 1.06
array of 24000 items push then shift 2.3508 us/op 1.8555 us/op 1.27
LinkedList of 24000 items push then shift 6.9450 ns/op 7.6520 ns/op 0.91
array of 24000 items push then pop 100.78 ns/op 109.63 ns/op 0.92
LinkedList of 24000 items push then pop 7.0170 ns/op 6.3350 ns/op 1.11
intersect bitArray bitLen 8 6.3910 ns/op 5.3910 ns/op 1.19
intersect array and set length 8 37.811 ns/op 32.832 ns/op 1.15
intersect bitArray bitLen 128 29.731 ns/op 26.719 ns/op 1.11
intersect array and set length 128 621.34 ns/op 539.53 ns/op 1.15
bitArray.getTrueBitIndexes() bitLen 128 991.00 ns/op 1.2040 us/op 0.82
bitArray.getTrueBitIndexes() bitLen 248 1.7360 us/op 1.9710 us/op 0.88
bitArray.getTrueBitIndexes() bitLen 512 3.5840 us/op 3.8370 us/op 0.93
Buffer.concat 32 items 593.00 ns/op 943.00 ns/op 0.63
Uint8Array.set 32 items 926.00 ns/op 1.3170 us/op 0.70
Buffer.copy 2.0400 us/op 2.5520 us/op 0.80
Uint8Array.set - with subarray 1.5680 us/op 2.0060 us/op 0.78
Uint8Array.set - without subarray 899.00 ns/op 1.4230 us/op 0.63
getUint32 - dataview 198.00 ns/op 404.00 ns/op 0.49
getUint32 - manual 120.00 ns/op 332.00 ns/op 0.36
Set add up to 64 items then delete first 2.2227 us/op 1.8087 us/op 1.23
OrderedSet add up to 64 items then delete first 3.2877 us/op 2.8102 us/op 1.17
Set add up to 64 items then delete last 2.5110 us/op 2.0609 us/op 1.22
OrderedSet add up to 64 items then delete last 3.6279 us/op 3.1894 us/op 1.14
Set add up to 64 items then delete middle 2.5993 us/op 2.0574 us/op 1.26
OrderedSet add up to 64 items then delete middle 5.1131 us/op 4.5519 us/op 1.12
Set add up to 128 items then delete first 4.8192 us/op 4.1555 us/op 1.16
OrderedSet add up to 128 items then delete first 7.5125 us/op 6.5347 us/op 1.15
Set add up to 128 items then delete last 4.6780 us/op 4.0498 us/op 1.16
OrderedSet add up to 128 items then delete last 7.0443 us/op 6.0141 us/op 1.17
Set add up to 128 items then delete middle 4.6182 us/op 4.0197 us/op 1.15
OrderedSet add up to 128 items then delete middle 13.638 us/op 12.200 us/op 1.12
Set add up to 256 items then delete first 9.7339 us/op 8.1944 us/op 1.19
OrderedSet add up to 256 items then delete first 15.229 us/op 12.751 us/op 1.19
Set add up to 256 items then delete last 9.1738 us/op 8.0022 us/op 1.15
OrderedSet add up to 256 items then delete last 14.030 us/op 12.418 us/op 1.13
Set add up to 256 items then delete middle 9.1578 us/op 7.9484 us/op 1.15
OrderedSet add up to 256 items then delete middle 39.337 us/op 35.532 us/op 1.11
transfer serialized Status (84 B) 2.1980 us/op 2.1520 us/op 1.02
copy serialized Status (84 B) 1.2040 us/op 1.2700 us/op 0.95
transfer serialized SignedVoluntaryExit (112 B) 2.2580 us/op 2.1260 us/op 1.06
copy serialized SignedVoluntaryExit (112 B) 1.2660 us/op 1.2840 us/op 0.99
transfer serialized ProposerSlashing (416 B) 3.0960 us/op 2.1530 us/op 1.44
copy serialized ProposerSlashing (416 B) 1.3290 us/op 1.3400 us/op 0.99
transfer serialized Attestation (485 B) 2.3540 us/op 2.1740 us/op 1.08
copy serialized Attestation (485 B) 1.3120 us/op 1.3520 us/op 0.97
transfer serialized AttesterSlashing (33232 B) 2.4260 us/op 2.2440 us/op 1.08
copy serialized AttesterSlashing (33232 B) 3.4610 us/op 2.7930 us/op 1.24
transfer serialized Small SignedBeaconBlock (128000 B) 3.0290 us/op 2.5450 us/op 1.19
copy serialized Small SignedBeaconBlock (128000 B) 9.0770 us/op 6.2650 us/op 1.45
transfer serialized Avg SignedBeaconBlock (200000 B) 3.3580 us/op 2.7640 us/op 1.21
copy serialized Avg SignedBeaconBlock (200000 B) 13.335 us/op 9.7840 us/op 1.36
transfer serialized BlobsSidecar (524380 B) 3.4290 us/op 3.7860 us/op 0.91
copy serialized BlobsSidecar (524380 B) 101.13 us/op 143.15 us/op 0.71
transfer serialized Big SignedBeaconBlock (1000000 B) 3.5080 us/op 4.4330 us/op 0.79
copy serialized Big SignedBeaconBlock (1000000 B) 126.38 us/op 216.27 us/op 0.58
pass gossip attestations to forkchoice per slot 2.7164 ms/op 2.4786 ms/op 1.10
forkChoice updateHead vc 100000 bc 64 eq 0 445.79 us/op 364.34 us/op 1.22
forkChoice updateHead vc 600000 bc 64 eq 0 2.7435 ms/op 2.1983 ms/op 1.25
forkChoice updateHead vc 1000000 bc 64 eq 0 4.7852 ms/op 3.7488 ms/op 1.28
forkChoice updateHead vc 600000 bc 320 eq 0 2.8034 ms/op 2.1976 ms/op 1.28
forkChoice updateHead vc 600000 bc 1200 eq 0 2.8486 ms/op 2.2513 ms/op 1.27
forkChoice updateHead vc 600000 bc 7200 eq 0 3.0655 ms/op 2.4411 ms/op 1.26
forkChoice updateHead vc 600000 bc 64 eq 1000 10.819 ms/op 9.7180 ms/op 1.11
forkChoice updateHead vc 600000 bc 64 eq 10000 10.450 ms/op 9.5584 ms/op 1.09
forkChoice updateHead vc 600000 bc 64 eq 300000 13.587 ms/op 11.456 ms/op 1.19
computeDeltas 500000 validators 300 proto nodes 3.8439 ms/op 3.1682 ms/op 1.21
computeDeltas 500000 validators 1200 proto nodes 3.8571 ms/op 3.0903 ms/op 1.25
computeDeltas 500000 validators 7200 proto nodes 3.8636 ms/op 2.9866 ms/op 1.29
computeDeltas 750000 validators 300 proto nodes 5.7015 ms/op 4.4680 ms/op 1.28
computeDeltas 750000 validators 1200 proto nodes 5.7461 ms/op 4.5415 ms/op 1.27
computeDeltas 750000 validators 7200 proto nodes 5.6691 ms/op 4.5581 ms/op 1.24
computeDeltas 1400000 validators 300 proto nodes 10.914 ms/op 8.6167 ms/op 1.27
computeDeltas 1400000 validators 1200 proto nodes 10.673 ms/op 8.8384 ms/op 1.21
computeDeltas 1400000 validators 7200 proto nodes 10.677 ms/op 8.4318 ms/op 1.27
computeDeltas 2100000 validators 300 proto nodes 16.207 ms/op 13.055 ms/op 1.24
computeDeltas 2100000 validators 1200 proto nodes 16.148 ms/op 13.837 ms/op 1.17
computeDeltas 2100000 validators 7200 proto nodes 16.442 ms/op 13.530 ms/op 1.22
altair processAttestation - 250000 vs - 7PWei normalcase 1.9701 ms/op 1.6447 ms/op 1.20
altair processAttestation - 250000 vs - 7PWei worstcase 2.9897 ms/op 2.4061 ms/op 1.24
altair processAttestation - setStatus - 1/6 committees join 127.21 us/op 111.47 us/op 1.14
altair processAttestation - setStatus - 1/3 committees join 243.86 us/op 195.50 us/op 1.25
altair processAttestation - setStatus - 1/2 committees join 342.56 us/op 281.13 us/op 1.22
altair processAttestation - setStatus - 2/3 committees join 420.30 us/op 351.83 us/op 1.19
altair processAttestation - setStatus - 4/5 committees join 599.07 us/op 490.55 us/op 1.22
altair processAttestation - setStatus - 100% committees join 716.69 us/op 586.88 us/op 1.22
altair processBlock - 250000 vs - 7PWei normalcase 4.1377 ms/op 4.6506 ms/op 0.89
altair processBlock - 250000 vs - 7PWei normalcase hashState 29.926 ms/op 31.529 ms/op 0.95
altair processBlock - 250000 vs - 7PWei worstcase 31.280 ms/op 39.303 ms/op 0.80
altair processBlock - 250000 vs - 7PWei worstcase hashState 73.574 ms/op 72.903 ms/op 1.01
phase0 processBlock - 250000 vs - 7PWei normalcase 1.5618 ms/op 1.7345 ms/op 0.90
phase0 processBlock - 250000 vs - 7PWei worstcase 20.008 ms/op 25.624 ms/op 0.78
altair processEth1Data - 250000 vs - 7PWei normalcase 342.77 us/op 275.67 us/op 1.24
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 5.8230 us/op 5.0790 us/op 1.15
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 35.105 us/op 32.912 us/op 1.07
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 10.606 us/op 10.890 us/op 0.97
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 6.2440 us/op 6.5560 us/op 0.95
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 134.31 us/op 149.75 us/op 0.90
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.7024 ms/op 1.4274 ms/op 1.19
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 2.2111 ms/op 1.8962 ms/op 1.17
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 2.1439 ms/op 1.8861 ms/op 1.14
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.8379 ms/op 3.7374 ms/op 1.29
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.2318 ms/op 1.9174 ms/op 1.16
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 4.5547 ms/op 3.7892 ms/op 1.20
Tree 40 250000 create 419.60 ms/op 347.35 ms/op 1.21
Tree 40 250000 get(125000) 136.41 ns/op 106.62 ns/op 1.28
Tree 40 250000 set(125000) 1.4685 us/op 1.0975 us/op 1.34
Tree 40 250000 toArray() 15.111 ms/op 12.256 ms/op 1.23
Tree 40 250000 iterate all - toArray() + loop 15.549 ms/op 12.436 ms/op 1.25
Tree 40 250000 iterate all - get(i) 49.488 ms/op 40.868 ms/op 1.21
Array 250000 create 2.3789 ms/op 2.3301 ms/op 1.02
Array 250000 clone - spread 795.48 us/op 633.96 us/op 1.25
Array 250000 get(125000) 0.42000 ns/op 0.56300 ns/op 0.75
Array 250000 set(125000) 0.44000 ns/op 0.59600 ns/op 0.74
Array 250000 iterate all - loop 108.82 us/op 78.051 us/op 1.39
phase0 afterProcessEpoch - 250000 vs - 7PWei 41.095 ms/op 38.952 ms/op 1.06
Array.fill - length 1000000 3.6557 ms/op 2.4129 ms/op 1.52
Array push - length 1000000 11.907 ms/op 10.344 ms/op 1.15
Array.get 0.27197 ns/op 0.25128 ns/op 1.08
Uint8Array.get 0.43548 ns/op 0.32320 ns/op 1.35
phase0 beforeProcessEpoch - 250000 vs - 7PWei 15.374 ms/op 14.405 ms/op 1.07
altair processEpoch - mainnet_e81889 275.12 ms/op 266.36 ms/op 1.03
mainnet_e81889 - altair beforeProcessEpoch 17.901 ms/op 14.372 ms/op 1.25
mainnet_e81889 - altair processJustificationAndFinalization 5.3990 us/op 4.9210 us/op 1.10
mainnet_e81889 - altair processInactivityUpdates 4.1171 ms/op 3.5320 ms/op 1.17
mainnet_e81889 - altair processRewardsAndPenalties 39.174 ms/op 41.310 ms/op 0.95
mainnet_e81889 - altair processRegistryUpdates 727.00 ns/op 854.00 ns/op 0.85
mainnet_e81889 - altair processSlashings 191.00 ns/op 393.00 ns/op 0.49
mainnet_e81889 - altair processEth1DataReset 184.00 ns/op 391.00 ns/op 0.47
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2502 ms/op 1.0249 ms/op 1.22
mainnet_e81889 - altair processSlashingsReset 874.00 ns/op 1.0950 us/op 0.80
mainnet_e81889 - altair processRandaoMixesReset 1.0910 us/op 1.5570 us/op 0.70
mainnet_e81889 - altair processHistoricalRootsUpdate 185.00 ns/op 398.00 ns/op 0.46
mainnet_e81889 - altair processParticipationFlagUpdates 520.00 ns/op 688.00 ns/op 0.76
mainnet_e81889 - altair processSyncCommitteeUpdates 148.00 ns/op 352.00 ns/op 0.42
mainnet_e81889 - altair afterProcessEpoch 44.356 ms/op 41.012 ms/op 1.08
capella processEpoch - mainnet_e217614 943.20 ms/op 900.97 ms/op 1.05
mainnet_e217614 - capella beforeProcessEpoch 63.816 ms/op 58.244 ms/op 1.10
mainnet_e217614 - capella processJustificationAndFinalization 5.2030 us/op 4.5950 us/op 1.13
mainnet_e217614 - capella processInactivityUpdates 14.155 ms/op 11.087 ms/op 1.28
mainnet_e217614 - capella processRewardsAndPenalties 174.53 ms/op 189.58 ms/op 0.92
mainnet_e217614 - capella processRegistryUpdates 6.5290 us/op 5.4550 us/op 1.20
mainnet_e217614 - capella processSlashings 182.00 ns/op 400.00 ns/op 0.46
mainnet_e217614 - capella processEth1DataReset 182.00 ns/op 395.00 ns/op 0.46
mainnet_e217614 - capella processEffectiveBalanceUpdates 8.2035 ms/op 3.4959 ms/op 2.35
mainnet_e217614 - capella processSlashingsReset 882.00 ns/op 1.1380 us/op 0.78
mainnet_e217614 - capella processRandaoMixesReset 1.0910 us/op 1.5620 us/op 0.70
mainnet_e217614 - capella processHistoricalRootsUpdate 184.00 ns/op 392.00 ns/op 0.47
mainnet_e217614 - capella processParticipationFlagUpdates 523.00 ns/op 677.00 ns/op 0.77
mainnet_e217614 - capella afterProcessEpoch 114.76 ms/op 112.00 ms/op 1.02
phase0 processEpoch - mainnet_e58758 300.38 ms/op 272.47 ms/op 1.10
mainnet_e58758 - phase0 beforeProcessEpoch 74.116 ms/op 60.652 ms/op 1.22
mainnet_e58758 - phase0 processJustificationAndFinalization 5.9350 us/op 4.4730 us/op 1.33
mainnet_e58758 - phase0 processRewardsAndPenalties 35.307 ms/op 37.067 ms/op 0.95
mainnet_e58758 - phase0 processRegistryUpdates 3.1170 us/op 3.1050 us/op 1.00
mainnet_e58758 - phase0 processSlashings 187.00 ns/op 393.00 ns/op 0.48
mainnet_e58758 - phase0 processEth1DataReset 181.00 ns/op 390.00 ns/op 0.46
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.1847 ms/op 895.70 us/op 1.32
mainnet_e58758 - phase0 processSlashingsReset 925.00 ns/op 1.0220 us/op 0.91
mainnet_e58758 - phase0 processRandaoMixesReset 1.1050 us/op 1.2550 us/op 0.88
mainnet_e58758 - phase0 processHistoricalRootsUpdate 186.00 ns/op 378.00 ns/op 0.49
mainnet_e58758 - phase0 processParticipationRecordUpdates 882.00 ns/op 1.1680 us/op 0.76
mainnet_e58758 - phase0 afterProcessEpoch 35.775 ms/op 32.162 ms/op 1.11
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.3409 ms/op 916.88 us/op 1.46
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.9522 ms/op 1.3250 ms/op 1.47
altair processInactivityUpdates - 250000 normalcase 17.935 ms/op 20.420 ms/op 0.88
altair processInactivityUpdates - 250000 worstcase 16.509 ms/op 16.253 ms/op 1.02
phase0 processRegistryUpdates - 250000 normalcase 6.0890 us/op 5.4950 us/op 1.11
phase0 processRegistryUpdates - 250000 badcase_full_deposits 228.82 us/op 281.32 us/op 0.81
phase0 processRegistryUpdates - 250000 worstcase 0.5 101.68 ms/op 102.47 ms/op 0.99
altair processRewardsAndPenalties - 250000 normalcase 26.658 ms/op 24.956 ms/op 1.07
altair processRewardsAndPenalties - 250000 worstcase 27.679 ms/op 29.474 ms/op 0.94
phase0 getAttestationDeltas - 250000 normalcase 6.8708 ms/op 4.5275 ms/op 1.52
phase0 getAttestationDeltas - 250000 worstcase 6.4905 ms/op 16.887 ms/op 0.38
phase0 processSlashings - 250000 worstcase 77.579 us/op 95.102 us/op 0.82
altair processSyncCommitteeUpdates - 250000 10.827 ms/op 9.1031 ms/op 1.19
BeaconState.hashTreeRoot - No change 215.00 ns/op 419.00 ns/op 0.51
BeaconState.hashTreeRoot - 1 full validator 87.115 us/op 74.905 us/op 1.16
BeaconState.hashTreeRoot - 32 full validator 1.1496 ms/op 818.02 us/op 1.41
BeaconState.hashTreeRoot - 512 full validator 10.794 ms/op 10.485 ms/op 1.03
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 108.56 us/op 125.52 us/op 0.86
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.3913 ms/op 1.3914 ms/op 1.00
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 23.330 ms/op 27.869 ms/op 0.84
BeaconState.hashTreeRoot - 1 balances 75.700 us/op 73.420 us/op 1.03
BeaconState.hashTreeRoot - 32 balances 938.70 us/op 799.10 us/op 1.17
BeaconState.hashTreeRoot - 512 balances 9.0119 ms/op 8.6281 ms/op 1.04
BeaconState.hashTreeRoot - 250000 balances 164.05 ms/op 185.61 ms/op 0.88
aggregationBits - 2048 els - zipIndexesInBitList 20.716 us/op 17.149 us/op 1.21
byteArrayEquals 32 52.199 ns/op 52.669 ns/op 0.99
Buffer.compare 32 16.920 ns/op 15.668 ns/op 1.08
byteArrayEquals 1024 1.5435 us/op 1.3000 us/op 1.19
Buffer.compare 1024 24.663 ns/op 23.122 ns/op 1.07
byteArrayEquals 16384 24.594 us/op 20.692 us/op 1.19
Buffer.compare 16384 192.66 ns/op 202.05 ns/op 0.95
byteArrayEquals 123687377 186.91 ms/op 153.38 ms/op 1.22
Buffer.compare 123687377 6.7024 ms/op 3.7300 ms/op 1.80
byteArrayEquals 32 - diff last byte 52.985 ns/op 48.772 ns/op 1.09
Buffer.compare 32 - diff last byte 17.337 ns/op 14.729 ns/op 1.18
byteArrayEquals 1024 - diff last byte 1.5930 us/op 1.2567 us/op 1.27
Buffer.compare 1024 - diff last byte 25.469 ns/op 22.677 ns/op 1.12
byteArrayEquals 16384 - diff last byte 25.485 us/op 19.926 us/op 1.28
Buffer.compare 16384 - diff last byte 195.10 ns/op 198.94 ns/op 0.98
byteArrayEquals 123687377 - diff last byte 190.39 ms/op 152.75 ms/op 1.25
Buffer.compare 123687377 - diff last byte 6.5522 ms/op 5.2712 ms/op 1.24
byteArrayEquals 32 - random bytes 5.0640 ns/op 5.0180 ns/op 1.01
Buffer.compare 32 - random bytes 17.029 ns/op 16.152 ns/op 1.05
byteArrayEquals 1024 - random bytes 5.1920 ns/op 4.9780 ns/op 1.04
Buffer.compare 1024 - random bytes 18.423 ns/op 14.914 ns/op 1.24
byteArrayEquals 16384 - random bytes 5.1810 ns/op 4.7450 ns/op 1.09
Buffer.compare 16384 - random bytes 17.915 ns/op 15.125 ns/op 1.18
byteArrayEquals 123687377 - random bytes 6.5700 ns/op 7.4800 ns/op 0.88
Buffer.compare 123687377 - random bytes 18.690 ns/op 18.480 ns/op 1.01
regular array get 100000 times 41.798 us/op 29.399 us/op 1.42
wrappedArray get 100000 times 33.308 us/op 29.330 us/op 1.14
arrayWithProxy get 100000 times 16.267 ms/op 8.9020 ms/op 1.83
ssz.Root.equals 47.176 ns/op 40.759 ns/op 1.16
byteArrayEquals 46.275 ns/op 38.588 ns/op 1.20
Buffer.compare 10.585 ns/op 8.9220 ns/op 1.19
processSlot - 1 slots 10.560 us/op 8.8150 us/op 1.20
processSlot - 32 slots 2.3202 ms/op 2.1372 ms/op 1.09
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 3.1839 ms/op 2.1164 ms/op 1.50
getCommitteeAssignments - req 1 vs - 250000 vc 2.1332 ms/op 1.7970 ms/op 1.19
getCommitteeAssignments - req 100 vs - 250000 vc 4.1413 ms/op 3.4908 ms/op 1.19
getCommitteeAssignments - req 1000 vs - 250000 vc 4.3403 ms/op 3.7180 ms/op 1.17
findModifiedValidators - 10000 modified validators 746.49 ms/op 746.28 ms/op 1.00
findModifiedValidators - 1000 modified validators 719.45 ms/op 688.84 ms/op 1.04
findModifiedValidators - 100 modified validators 293.65 ms/op 257.74 ms/op 1.14
findModifiedValidators - 10 modified validators 208.62 ms/op 184.83 ms/op 1.13
findModifiedValidators - 1 modified validators 151.03 ms/op 141.10 ms/op 1.07
findModifiedValidators - no difference 177.78 ms/op 153.20 ms/op 1.16
compare ViewDUs 6.1817 s/op 6.2942 s/op 0.98
compare each validator Uint8Array 1.2654 s/op 943.08 ms/op 1.34
compare ViewDU to Uint8Array 967.65 ms/op 793.98 ms/op 1.22
migrate state 1000000 validators, 24 modified, 0 new 770.35 ms/op 883.55 ms/op 0.87
migrate state 1000000 validators, 1700 modified, 1000 new 1.1377 s/op 1.3035 s/op 0.87
migrate state 1000000 validators, 3400 modified, 2000 new 1.2182 s/op 1.3037 s/op 0.93
migrate state 1500000 validators, 24 modified, 0 new 858.80 ms/op 911.74 ms/op 0.94
migrate state 1500000 validators, 1700 modified, 1000 new 1.0165 s/op 1.0429 s/op 0.97
migrate state 1500000 validators, 3400 modified, 2000 new 1.1579 s/op 1.3037 s/op 0.89
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.3400 ns/op 6.2200 ns/op 0.70
state getBlockRootAtSlot - 250000 vs - 7PWei 517.18 ns/op 353.79 ns/op 1.46
naive computeProposerIndex 100000 validators 47.986 ms/op 42.743 ms/op 1.12
computeProposerIndex 100000 validators 1.4725 ms/op 1.2860 ms/op 1.14
naiveGetNextSyncCommitteeIndices 1000 validators 7.2684 s/op 6.5581 s/op 1.11
getNextSyncCommitteeIndices 1000 validators 108.83 ms/op 90.140 ms/op 1.21
naiveGetNextSyncCommitteeIndices 10000 validators 7.3875 s/op 6.2313 s/op 1.19
getNextSyncCommitteeIndices 10000 validators 109.65 ms/op 96.743 ms/op 1.13
naiveGetNextSyncCommitteeIndices 100000 validators 7.3097 s/op 6.6479 s/op 1.10
getNextSyncCommitteeIndices 100000 validators 108.66 ms/op 88.927 ms/op 1.22
naive computeShuffledIndex 100000 validators 23.400 s/op 18.199 s/op 1.29
cached computeShuffledIndex 100000 validators 543.19 ms/op 469.37 ms/op 1.16
naive computeShuffledIndex 2000000 validators 464.48 s/op 390.84 s/op 1.19
cached computeShuffledIndex 2000000 validators 28.379 s/op 15.462 s/op 1.84
computeProposers - vc 250000 625.44 us/op 557.78 us/op 1.12
computeEpochShuffling - vc 250000 41.698 ms/op 38.841 ms/op 1.07
getNextSyncCommittee - vc 250000 10.393 ms/op 9.9282 ms/op 1.05
computeSigningRoot for AttestationData 19.747 us/op 20.390 us/op 0.97
hash AttestationData serialized data then Buffer.toString(base64) 1.5698 us/op 1.2313 us/op 1.27
toHexString serialized data 1.0668 us/op 1.0661 us/op 1.00
Buffer.toString(base64) 143.86 ns/op 110.59 ns/op 1.30
nodejs block root to RootHex using toHex 145.86 ns/op 118.38 ns/op 1.23
nodejs block root to RootHex using toRootHex 92.148 ns/op 73.253 ns/op 1.26
browser block root to RootHex using the deprecated toHexString 208.69 ns/op 193.02 ns/op 1.08
browser block root to RootHex using toHex 169.13 ns/op 159.69 ns/op 1.06
browser block root to RootHex using toRootHex 158.12 ns/op 150.09 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

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

twoeths
twoeths previously approved these changes Mar 14, 2025
nflaig
nflaig previously approved these changes Mar 14, 2025
@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
@philknows philknows modified the milestones: v1.29.0, v1.30.0 Apr 23, 2025
@nflaig nflaig dismissed stale reviews from twoeths and themself via 33e439b May 3, 2025 09:41
...formatNodePeer(peerIdStr, connections),
agentVersion: peerData?.agentVersion ?? "NA",
status: peerData?.status ? ssz.phase0.Status.toJson(peerData.status) : null,
metadata: peerData?.metadata ? ssz.altair.Metadata.toJson(peerData.metadata) : null,
Copy link
Member

@nflaig nflaig May 3, 2025

Choose a reason for hiding this comment

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

once Fusaka goes live we should update this to use fulu.Metadata, or just if-else based on clock slot but we need the type first #7774

@codecov
Copy link

codecov bot commented May 3, 2025

Codecov Report

Attention: Patch coverage is 41.42857% with 41 lines in your changes missing coverage. Please review.

Project coverage is 56.03%. Comparing base (185bc83) to head (c568061).
Report is 1 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #7508      +/-   ##
============================================
- Coverage     56.04%   56.03%   -0.02%     
============================================
  Files           823      823              
  Lines         57892    57951      +59     
  Branches       4453     4461       +8     
============================================
+ Hits          32448    32472      +24     
- Misses        25376    25411      +35     
  Partials         68       68              
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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

@nflaig nflaig merged commit ca57e6c into unstable May 3, 2025
20 checks passed
@nflaig nflaig deleted the cayman/starved-churn branch May 3, 2025 13:38
nflaig added a commit that referenced this pull request May 8, 2025
Follow up on #7508 to support
dumping `fulu.Metadata`, ie. we can inspect `custody_group_count` of our
connected peers via `GET /eth/v1/lodestar/peers` api.

Closes #7790
@wemeetagain
Copy link
Member Author

🎉 This PR is included in v1.30.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.

5 participants