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: increase batch size to get validator indices to 64 #5743

Merged
merged 1 commit into from
Jul 11, 2023

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Jul 10, 2023

Motivation

The current batch size of 10 is quite conservative. The rationale behind choosing the value #2730 (comment) seems outdated and there has been more discussion on this ethereum/beacon-APIs#328 in the meantime.

The value 64 is supported by all implementations and reducing the amount of queries reduces load on beacon node, especially during startup.

Description

  • Increase batch size (PUBKEYS_PER_REQUEST) to get validator indices to 64
  • Update tsdoc of batchItems, previous comment is misleading and inaccurate

@nflaig nflaig requested a review from a team as a code owner July 10, 2023 19:25
@github-actions
Copy link
Contributor

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: f72e6bd Previous: b596000 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 604.21 us/op 894.21 us/op 0.68
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 56.885 us/op 46.348 us/op 1.23
BLS verify - blst-native 1.2835 ms/op 1.2125 ms/op 1.06
BLS verifyMultipleSignatures 3 - blst-native 2.6375 ms/op 2.4445 ms/op 1.08
BLS verifyMultipleSignatures 8 - blst-native 5.6477 ms/op 5.2173 ms/op 1.08
BLS verifyMultipleSignatures 32 - blst-native 20.506 ms/op 18.955 ms/op 1.08
BLS aggregatePubkeys 32 - blst-native 27.451 us/op 25.358 us/op 1.08
BLS aggregatePubkeys 128 - blst-native 106.24 us/op 98.422 us/op 1.08
getAttestationsForBlock 60.472 ms/op 52.984 ms/op 1.14
isKnown best case - 1 super set check 281.00 ns/op 254.00 ns/op 1.11
isKnown normal case - 2 super set checks 274.00 ns/op 248.00 ns/op 1.10
isKnown worse case - 16 super set checks 275.00 ns/op 243.00 ns/op 1.13
CheckpointStateCache - add get delete 6.5380 us/op 5.5590 us/op 1.18
validate gossip signedAggregateAndProof - struct 2.8934 ms/op 2.8109 ms/op 1.03
validate gossip attestation - struct 1.3955 ms/op 1.4150 ms/op 0.99
pickEth1Vote - no votes 1.4010 ms/op 1.4279 ms/op 0.98
pickEth1Vote - max votes 11.148 ms/op 12.656 ms/op 0.88
pickEth1Vote - Eth1Data hashTreeRoot value x2048 9.7302 ms/op 8.8420 ms/op 1.10
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 16.130 ms/op 14.511 ms/op 1.11
pickEth1Vote - Eth1Data fastSerialize value x2048 956.87 us/op 677.02 us/op 1.41
pickEth1Vote - Eth1Data fastSerialize tree x2048 9.7724 ms/op 6.9445 ms/op 1.41
bytes32 toHexString 890.00 ns/op 540.00 ns/op 1.65
bytes32 Buffer.toString(hex) 465.00 ns/op 351.00 ns/op 1.32
bytes32 Buffer.toString(hex) from Uint8Array 672.00 ns/op 578.00 ns/op 1.16
bytes32 Buffer.toString(hex) + 0x 475.00 ns/op 359.00 ns/op 1.32
Object access 1 prop 0.22400 ns/op 0.15800 ns/op 1.42
Map access 1 prop 0.18300 ns/op 0.16000 ns/op 1.14
Object get x1000 7.7920 ns/op 6.6640 ns/op 1.17
Map get x1000 0.70000 ns/op 0.63500 ns/op 1.10
Object set x1000 68.083 ns/op 55.116 ns/op 1.24
Map set x1000 61.019 ns/op 43.275 ns/op 1.41
Return object 10000 times 0.25900 ns/op 0.23980 ns/op 1.08
Throw Error 10000 times 4.7554 us/op 4.2545 us/op 1.12
fastMsgIdFn sha256 / 200 bytes 3.8510 us/op 3.4540 us/op 1.11
fastMsgIdFn h32 xxhash / 200 bytes 314.00 ns/op 291.00 ns/op 1.08
fastMsgIdFn h64 xxhash / 200 bytes 503.00 ns/op 392.00 ns/op 1.28
fastMsgIdFn sha256 / 1000 bytes 12.519 us/op 11.647 us/op 1.07
fastMsgIdFn h32 xxhash / 1000 bytes 430.00 ns/op 422.00 ns/op 1.02
fastMsgIdFn h64 xxhash / 1000 bytes 556.00 ns/op 492.00 ns/op 1.13
fastMsgIdFn sha256 / 10000 bytes 108.75 us/op 103.81 us/op 1.05
fastMsgIdFn h32 xxhash / 10000 bytes 2.0450 us/op 1.9870 us/op 1.03
fastMsgIdFn h64 xxhash / 10000 bytes 1.4820 us/op 1.4340 us/op 1.03
enrSubnets - fastDeserialize 64 bits 1.4770 us/op 1.3020 us/op 1.13
enrSubnets - ssz BitVector 64 bits 563.00 ns/op 493.00 ns/op 1.14
enrSubnets - fastDeserialize 4 bits 201.00 ns/op 165.00 ns/op 1.22
enrSubnets - ssz BitVector 4 bits 592.00 ns/op 485.00 ns/op 1.22
prioritizePeers score -10:0 att 32-0.1 sync 2-0 117.95 us/op 106.94 us/op 1.10
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 162.76 us/op 140.13 us/op 1.16
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 198.19 us/op 178.07 us/op 1.11
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 352.89 us/op 328.16 us/op 1.08
prioritizePeers score 0:0 att 64-1 sync 4-1 449.39 us/op 381.45 us/op 1.18
array of 16000 items push then shift 1.7110 us/op 1.6622 us/op 1.03
LinkedList of 16000 items push then shift 9.3710 ns/op 8.8880 ns/op 1.05
array of 16000 items push then pop 112.18 ns/op 80.757 ns/op 1.39
LinkedList of 16000 items push then pop 8.9590 ns/op 8.7510 ns/op 1.02
array of 24000 items push then shift 2.4443 us/op 2.3721 us/op 1.03
LinkedList of 24000 items push then shift 9.1930 ns/op 9.1840 ns/op 1.00
array of 24000 items push then pop 81.177 ns/op 79.132 ns/op 1.03
LinkedList of 24000 items push then pop 9.1590 ns/op 8.7370 ns/op 1.05
intersect bitArray bitLen 8 13.782 ns/op 13.430 ns/op 1.03
intersect array and set length 8 85.968 ns/op 80.221 ns/op 1.07
intersect bitArray bitLen 128 45.758 ns/op 44.947 ns/op 1.02
intersect array and set length 128 1.3628 us/op 1.0843 us/op 1.26
Buffer.concat 32 items 3.0080 us/op 2.9590 us/op 1.02
Uint8Array.set 32 items 3.0720 us/op 2.8450 us/op 1.08
transfer serialized Status (84 B) 2.2550 us/op 2.0510 us/op 1.10
copy serialized Status (84 B) 1.9840 us/op 1.6940 us/op 1.17
transfer serialized SignedVoluntaryExit (112 B) 2.4310 us/op 2.1370 us/op 1.14
copy serialized SignedVoluntaryExit (112 B) 1.9990 us/op 1.7110 us/op 1.17
transfer serialized ProposerSlashing (416 B) 3.2460 us/op 2.2570 us/op 1.44
copy serialized ProposerSlashing (416 B) 2.7360 us/op 2.1100 us/op 1.30
transfer serialized Attestation (485 B) 2.6030 us/op 2.2700 us/op 1.15
copy serialized Attestation (485 B) 2.0700 us/op 2.2330 us/op 0.93
transfer serialized AttesterSlashing (33232 B) 2.7720 us/op 2.4610 us/op 1.13
copy serialized AttesterSlashing (33232 B) 5.6860 us/op 7.3200 us/op 0.78
transfer serialized Small SignedBeaconBlock (128000 B) 2.8360 us/op 2.9710 us/op 0.95
copy serialized Small SignedBeaconBlock (128000 B) 13.094 us/op 14.894 us/op 0.88
transfer serialized Avg SignedBeaconBlock (200000 B) 3.1590 us/op 3.2040 us/op 0.99
copy serialized Avg SignedBeaconBlock (200000 B) 20.162 us/op 25.106 us/op 0.80
transfer serialized BlobsSidecar (524380 B) 3.2920 us/op 3.5040 us/op 0.94
copy serialized BlobsSidecar (524380 B) 86.812 us/op 184.83 us/op 0.47
transfer serialized Big SignedBeaconBlock (1000000 B) 3.5060 us/op 3.1600 us/op 1.11
copy serialized Big SignedBeaconBlock (1000000 B) 255.91 us/op 300.81 us/op 0.85
pass gossip attestations to forkchoice per slot 2.8013 ms/op 2.7129 ms/op 1.03
forkChoice updateHead vc 100000 bc 64 eq 0 2.2079 ms/op 2.1294 ms/op 1.04
forkChoice updateHead vc 600000 bc 64 eq 0 13.697 ms/op 11.822 ms/op 1.16
forkChoice updateHead vc 1000000 bc 64 eq 0 21.599 ms/op 23.326 ms/op 0.93
forkChoice updateHead vc 600000 bc 320 eq 0 17.494 ms/op 16.561 ms/op 1.06
forkChoice updateHead vc 600000 bc 1200 eq 0 89.269 ms/op 81.670 ms/op 1.09
forkChoice updateHead vc 600000 bc 64 eq 1000 21.532 ms/op 21.016 ms/op 1.02
forkChoice updateHead vc 600000 bc 64 eq 10000 23.529 ms/op 24.354 ms/op 0.97
forkChoice updateHead vc 600000 bc 64 eq 300000 34.249 ms/op 33.369 ms/op 1.03
computeDeltas 3.2235 ms/op 3.2849 ms/op 0.98
computeProposerBoostScoreFromBalances 1.9217 ms/op 1.7858 ms/op 1.08
altair processAttestation - 250000 vs - 7PWei normalcase 4.0857 ms/op 2.5199 ms/op 1.62
altair processAttestation - 250000 vs - 7PWei worstcase 6.5126 ms/op 3.6569 ms/op 1.78
altair processAttestation - setStatus - 1/6 committees join 170.64 us/op 141.02 us/op 1.21
altair processAttestation - setStatus - 1/3 committees join 296.26 us/op 276.84 us/op 1.07
altair processAttestation - setStatus - 1/2 committees join 387.66 us/op 375.02 us/op 1.03
altair processAttestation - setStatus - 2/3 committees join 527.31 us/op 489.26 us/op 1.08
altair processAttestation - setStatus - 4/5 committees join 729.68 us/op 666.25 us/op 1.10
altair processAttestation - setStatus - 100% committees join 840.75 us/op 754.01 us/op 1.12
altair processBlock - 250000 vs - 7PWei normalcase 21.164 ms/op 17.339 ms/op 1.22
altair processBlock - 250000 vs - 7PWei normalcase hashState 29.088 ms/op 27.327 ms/op 1.06
altair processBlock - 250000 vs - 7PWei worstcase 57.738 ms/op 51.672 ms/op 1.12
altair processBlock - 250000 vs - 7PWei worstcase hashState 77.777 ms/op 67.788 ms/op 1.15
phase0 processBlock - 250000 vs - 7PWei normalcase 2.9163 ms/op 2.0346 ms/op 1.43
phase0 processBlock - 250000 vs - 7PWei worstcase 33.076 ms/op 29.053 ms/op 1.14
altair processEth1Data - 250000 vs - 7PWei normalcase 696.37 us/op 498.49 us/op 1.40
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 16.530 us/op 8.8990 us/op 1.86
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 51.671 us/op 29.407 us/op 1.76
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 18.653 us/op 11.028 us/op 1.69
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 14.636 us/op 8.4700 us/op 1.73
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 128.96 us/op 107.00 us/op 1.21
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 904.01 us/op 656.85 us/op 1.38
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.2175 ms/op 944.33 us/op 1.29
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.3858 ms/op 913.38 us/op 1.52
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.3443 ms/op 2.3771 ms/op 1.83
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.3561 ms/op 1.5236 ms/op 1.55
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 6.2172 ms/op 3.8803 ms/op 1.60
Tree 40 250000 create 857.28 ms/op 328.43 ms/op 2.61
Tree 40 250000 get(125000) 224.69 ns/op 185.49 ns/op 1.21
Tree 40 250000 set(125000) 3.2187 us/op 888.89 ns/op 3.62
Tree 40 250000 toArray() 38.115 ms/op 17.955 ms/op 2.12
Tree 40 250000 iterate all - toArray() + loop 34.141 ms/op 18.153 ms/op 1.88
Tree 40 250000 iterate all - get(i) 100.08 ms/op 68.709 ms/op 1.46
MutableVector 250000 create 17.347 ms/op 10.559 ms/op 1.64
MutableVector 250000 get(125000) 7.5930 ns/op 6.3560 ns/op 1.19
MutableVector 250000 set(125000) 795.58 ns/op 241.99 ns/op 3.29
MutableVector 250000 toArray() 5.6704 ms/op 2.7173 ms/op 2.09
MutableVector 250000 iterate all - toArray() + loop 5.8653 ms/op 2.8381 ms/op 2.07
MutableVector 250000 iterate all - get(i) 1.8241 ms/op 1.5353 ms/op 1.19
Array 250000 create 4.9879 ms/op 2.5328 ms/op 1.97
Array 250000 clone - spread 2.8275 ms/op 1.1111 ms/op 2.54
Array 250000 get(125000) 1.8680 ns/op 0.55200 ns/op 3.38
Array 250000 set(125000) 1.7970 ns/op 0.60500 ns/op 2.97
Array 250000 iterate all - loop 92.663 us/op 83.499 us/op 1.11
effectiveBalanceIncrements clone Uint8Array 300000 71.381 us/op 32.746 us/op 2.18
effectiveBalanceIncrements clone MutableVector 300000 514.00 ns/op 337.00 ns/op 1.53
effectiveBalanceIncrements rw all Uint8Array 300000 193.15 us/op 169.54 us/op 1.14
effectiveBalanceIncrements rw all MutableVector 300000 158.69 ms/op 82.160 ms/op 1.93
phase0 afterProcessEpoch - 250000 vs - 7PWei 125.10 ms/op 116.70 ms/op 1.07
phase0 beforeProcessEpoch - 250000 vs - 7PWei 43.437 ms/op 44.061 ms/op 0.99
altair processEpoch - mainnet_e81889 379.70 ms/op 332.14 ms/op 1.14
mainnet_e81889 - altair beforeProcessEpoch 81.200 ms/op 70.853 ms/op 1.15
mainnet_e81889 - altair processJustificationAndFinalization 26.724 us/op 19.385 us/op 1.38
mainnet_e81889 - altair processInactivityUpdates 8.5033 ms/op 6.4702 ms/op 1.31
mainnet_e81889 - altair processRewardsAndPenalties 79.896 ms/op 70.083 ms/op 1.14
mainnet_e81889 - altair processRegistryUpdates 5.1640 us/op 3.0570 us/op 1.69
mainnet_e81889 - altair processSlashings 1.0730 us/op 581.00 ns/op 1.85
mainnet_e81889 - altair processEth1DataReset 1.2130 us/op 732.00 ns/op 1.66
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.4148 ms/op 1.2467 ms/op 1.94
mainnet_e81889 - altair processSlashingsReset 9.2570 us/op 4.4940 us/op 2.06
mainnet_e81889 - altair processRandaoMixesReset 6.8370 us/op 6.2630 us/op 1.09
mainnet_e81889 - altair processHistoricalRootsUpdate 1.4270 us/op 1.3810 us/op 1.03
mainnet_e81889 - altair processParticipationFlagUpdates 5.4130 us/op 4.5230 us/op 1.20
mainnet_e81889 - altair processSyncCommitteeUpdates 1.2370 us/op 1.1080 us/op 1.12
mainnet_e81889 - altair afterProcessEpoch 139.94 ms/op 136.13 ms/op 1.03
phase0 processEpoch - mainnet_e58758 440.62 ms/op 378.89 ms/op 1.16
mainnet_e58758 - phase0 beforeProcessEpoch 166.58 ms/op 155.09 ms/op 1.07
mainnet_e58758 - phase0 processJustificationAndFinalization 29.986 us/op 24.645 us/op 1.22
mainnet_e58758 - phase0 processRewardsAndPenalties 69.695 ms/op 66.012 ms/op 1.06
mainnet_e58758 - phase0 processRegistryUpdates 13.542 us/op 12.056 us/op 1.12
mainnet_e58758 - phase0 processSlashings 1.2900 us/op 616.00 ns/op 2.09
mainnet_e58758 - phase0 processEth1DataReset 1.0030 us/op 655.00 ns/op 1.53
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 2.4005 ms/op 1.3112 ms/op 1.83
mainnet_e58758 - phase0 processSlashingsReset 7.5060 us/op 4.7080 us/op 1.59
mainnet_e58758 - phase0 processRandaoMixesReset 9.5260 us/op 5.4710 us/op 1.74
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.3470 us/op 912.00 ns/op 1.48
mainnet_e58758 - phase0 processParticipationRecordUpdates 6.5920 us/op 6.0940 us/op 1.08
mainnet_e58758 - phase0 afterProcessEpoch 104.05 ms/op 106.17 ms/op 0.98
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2739 ms/op 1.3185 ms/op 0.97
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.5756 ms/op 1.5630 ms/op 1.01
altair processInactivityUpdates - 250000 normalcase 27.875 ms/op 26.302 ms/op 1.06
altair processInactivityUpdates - 250000 worstcase 26.555 ms/op 27.284 ms/op 0.97
phase0 processRegistryUpdates - 250000 normalcase 9.9030 us/op 8.7550 us/op 1.13
phase0 processRegistryUpdates - 250000 badcase_full_deposits 344.45 us/op 437.79 us/op 0.79
phase0 processRegistryUpdates - 250000 worstcase 0.5 146.95 ms/op 131.54 ms/op 1.12
altair processRewardsAndPenalties - 250000 normalcase 73.833 ms/op 70.668 ms/op 1.04
altair processRewardsAndPenalties - 250000 worstcase 71.020 ms/op 68.480 ms/op 1.04
phase0 getAttestationDeltas - 250000 normalcase 7.3907 ms/op 7.1207 ms/op 1.04
phase0 getAttestationDeltas - 250000 worstcase 7.7697 ms/op 7.3137 ms/op 1.06
phase0 processSlashings - 250000 worstcase 3.6675 ms/op 3.6693 ms/op 1.00
altair processSyncCommitteeUpdates - 250000 189.77 ms/op 181.28 ms/op 1.05
BeaconState.hashTreeRoot - No change 341.00 ns/op 262.00 ns/op 1.30
BeaconState.hashTreeRoot - 1 full validator 53.493 us/op 53.395 us/op 1.00
BeaconState.hashTreeRoot - 32 full validator 491.95 us/op 535.74 us/op 0.92
BeaconState.hashTreeRoot - 512 full validator 5.4680 ms/op 5.2697 ms/op 1.04
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 69.324 us/op 62.093 us/op 1.12
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 924.07 us/op 1.0083 ms/op 0.92
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 12.091 ms/op 11.166 ms/op 1.08
BeaconState.hashTreeRoot - 1 balances 51.206 us/op 47.834 us/op 1.07
BeaconState.hashTreeRoot - 32 balances 484.80 us/op 465.61 us/op 1.04
BeaconState.hashTreeRoot - 512 balances 4.7995 ms/op 4.5960 ms/op 1.04
BeaconState.hashTreeRoot - 250000 balances 80.141 ms/op 74.149 ms/op 1.08
aggregationBits - 2048 els - zipIndexesInBitList 20.629 us/op 16.147 us/op 1.28
regular array get 100000 times 33.462 us/op 34.158 us/op 0.98
wrappedArray get 100000 times 34.569 us/op 33.576 us/op 1.03
arrayWithProxy get 100000 times 18.758 ms/op 15.648 ms/op 1.20
ssz.Root.equals 638.00 ns/op 552.00 ns/op 1.16
byteArrayEquals 617.00 ns/op 557.00 ns/op 1.11
shuffle list - 16384 els 7.2711 ms/op 6.8905 ms/op 1.06
shuffle list - 250000 els 102.89 ms/op 102.35 ms/op 1.01
processSlot - 1 slots 9.1700 us/op 8.5590 us/op 1.07
processSlot - 32 slots 1.4139 ms/op 1.3530 ms/op 1.05
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 38.032 ms/op 36.577 ms/op 1.04
getCommitteeAssignments - req 1 vs - 250000 vc 3.0089 ms/op 2.9296 ms/op 1.03
getCommitteeAssignments - req 100 vs - 250000 vc 4.4991 ms/op 4.1747 ms/op 1.08
getCommitteeAssignments - req 1000 vs - 250000 vc 4.9223 ms/op 4.4769 ms/op 1.10
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.8500 ns/op 4.7100 ns/op 1.24
state getBlockRootAtSlot - 250000 vs - 7PWei 989.32 ns/op 564.93 ns/op 1.75
computeProposers - vc 250000 12.598 ms/op 10.297 ms/op 1.22
computeEpochShuffling - vc 250000 107.76 ms/op 103.82 ms/op 1.04
getNextSyncCommittee - vc 250000 183.41 ms/op 173.00 ms/op 1.06
computeSigningRoot for AttestationData 15.028 us/op 13.584 us/op 1.11
hash AttestationData serialized data then Buffer.toString(base64) 2.8475 us/op 2.5074 us/op 1.14
toHexString serialized data 2.0556 us/op 1.0796 us/op 1.90
Buffer.toString(base64) 459.17 ns/op 345.58 ns/op 1.33

by benchmarkbot/action

@wemeetagain wemeetagain merged commit 85ff3cf into unstable Jul 11, 2023
@wemeetagain wemeetagain deleted the nflaig/increase-pubkeys-per-request branch July 11, 2023 00:02
@wemeetagain
Copy link
Member

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