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: forkchoice to track head vote by proto index #5882

Merged
merged 5 commits into from
Aug 17, 2023

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Aug 14, 2023

Motivation

  • In computeDeltas we have to get index from root twice for each vote so @dapplion suggested we can store vote by proto index instead

Description

  • Tracking votes by proto index helps computeDeltas() 2x-3x faster as tested in my local environment
  • It takes a little more time when prune but it happens per epoch while computeDeltas() happens twice per slot
  • With this change it takes 1 extra index lookup per vote per epoch in addLatestMessage(), while the old way takes 2x2x32 = 128 lookups per vote per epoch in computeDeltas (2 lookups for 2 roots, computeDeltas() is called 2 per slot ) and it happens at once so it's worth the change

Closes #5852

TODOs

  • Test this change in a group

@github-actions
Copy link
Contributor

github-actions bot commented Aug 14, 2023

Performance Report

✔️ no performance regression detected

🚀🚀 Significant benchmark improvement detected

Benchmark suite Current: 2fdc742 Previous: 4d5f777 Ratio
forkChoice updateHead vc 100000 bc 64 eq 0 663.41 us/op 2.0529 ms/op 0.32
forkChoice updateHead vc 600000 bc 64 eq 0 4.2110 ms/op 16.272 ms/op 0.26
forkChoice updateHead vc 1000000 bc 64 eq 0 6.9671 ms/op 22.896 ms/op 0.30
forkChoice updateHead vc 600000 bc 320 eq 0 4.2309 ms/op 13.006 ms/op 0.33
computeDeltas 500000 validators 300 proto nodes 6.2505 ms/op 22.167 ms/op 0.28
computeDeltas 500000 validators 1200 proto nodes 6.1933 ms/op 22.621 ms/op 0.27
computeDeltas 500000 validators 7200 proto nodes 6.2215 ms/op 21.395 ms/op 0.29
computeDeltas 750000 validators 300 proto nodes 9.3131 ms/op 32.349 ms/op 0.29
computeDeltas 750000 validators 1200 proto nodes 9.3555 ms/op 33.258 ms/op 0.28
computeDeltas 750000 validators 7200 proto nodes 9.4515 ms/op 34.315 ms/op 0.28
computeDeltas 1400000 validators 300 proto nodes 17.649 ms/op 62.135 ms/op 0.28
computeDeltas 1400000 validators 1200 proto nodes 17.643 ms/op 63.606 ms/op 0.28
computeDeltas 1400000 validators 7200 proto nodes 17.592 ms/op 62.292 ms/op 0.28
computeDeltas 2100000 validators 300 proto nodes 26.974 ms/op 98.333 ms/op 0.27
computeDeltas 2100000 validators 1200 proto nodes 26.683 ms/op 97.049 ms/op 0.27
computeDeltas 2100000 validators 7200 proto nodes 26.851 ms/op 95.456 ms/op 0.28
Full benchmark results
Benchmark suite Current: 2fdc742 Previous: 4d5f777 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 620.72 us/op 765.70 us/op 0.81
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 75.964 us/op 111.46 us/op 0.68
BLS verify - blst-native 1.2432 ms/op 1.4894 ms/op 0.83
BLS verifyMultipleSignatures 3 - blst-native 2.5191 ms/op 3.1579 ms/op 0.80
BLS verifyMultipleSignatures 8 - blst-native 5.3912 ms/op 6.6570 ms/op 0.81
BLS verifyMultipleSignatures 32 - blst-native 19.477 ms/op 23.984 ms/op 0.81
BLS aggregatePubkeys 32 - blst-native 25.725 us/op 31.657 us/op 0.81
BLS aggregatePubkeys 128 - blst-native 101.71 us/op 119.38 us/op 0.85
getAttestationsForBlock 48.502 ms/op 81.170 ms/op 0.60
isKnown best case - 1 super set check 252.00 ns/op 511.00 ns/op 0.49
isKnown normal case - 2 super set checks 254.00 ns/op 509.00 ns/op 0.50
isKnown worse case - 16 super set checks 246.00 ns/op 535.00 ns/op 0.46
CheckpointStateCache - add get delete 4.8280 us/op 6.6410 us/op 0.73
validate api signedAggregateAndProof - struct 2.6229 ms/op 3.3214 ms/op 0.79
validate gossip signedAggregateAndProof - struct 2.6277 ms/op 3.3225 ms/op 0.79
validate api attestation - struct 1.2503 ms/op 1.6236 ms/op 0.77
validate gossip attestation - struct 1.2912 ms/op 1.6957 ms/op 0.76
pickEth1Vote - no votes 1.0758 ms/op 1.5549 ms/op 0.69
pickEth1Vote - max votes 9.1214 ms/op 12.679 ms/op 0.72
pickEth1Vote - Eth1Data hashTreeRoot value x2048 8.3138 ms/op 12.822 ms/op 0.65
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 14.007 ms/op 19.405 ms/op 0.72
pickEth1Vote - Eth1Data fastSerialize value x2048 556.37 us/op 768.86 us/op 0.72
pickEth1Vote - Eth1Data fastSerialize tree x2048 5.7431 ms/op 5.5934 ms/op 1.03
bytes32 toHexString 457.00 ns/op 788.00 ns/op 0.58
bytes32 Buffer.toString(hex) 270.00 ns/op 360.00 ns/op 0.75
bytes32 Buffer.toString(hex) from Uint8Array 418.00 ns/op 567.00 ns/op 0.74
bytes32 Buffer.toString(hex) + 0x 278.00 ns/op 338.00 ns/op 0.82
Object access 1 prop 0.14800 ns/op 0.24200 ns/op 0.61
Map access 1 prop 0.14400 ns/op 0.19000 ns/op 0.76
Object get x1000 6.9390 ns/op 8.1960 ns/op 0.85
Map get x1000 0.50400 ns/op 0.87900 ns/op 0.57
Object set x1000 48.624 ns/op 77.611 ns/op 0.63
Map set x1000 37.662 ns/op 66.083 ns/op 0.57
Return object 10000 times 0.22930 ns/op 0.32510 ns/op 0.71
Throw Error 10000 times 3.7778 us/op 4.9332 us/op 0.77
fastMsgIdFn sha256 / 200 bytes 3.1610 us/op 4.0470 us/op 0.78
fastMsgIdFn h32 xxhash / 200 bytes 258.00 ns/op 407.00 ns/op 0.63
fastMsgIdFn h64 xxhash / 200 bytes 339.00 ns/op 462.00 ns/op 0.73
fastMsgIdFn sha256 / 1000 bytes 11.007 us/op 13.504 us/op 0.82
fastMsgIdFn h32 xxhash / 1000 bytes 381.00 ns/op 531.00 ns/op 0.72
fastMsgIdFn h64 xxhash / 1000 bytes 397.00 ns/op 563.00 ns/op 0.71
fastMsgIdFn sha256 / 10000 bytes 101.28 us/op 123.12 us/op 0.82
fastMsgIdFn h32 xxhash / 10000 bytes 1.8330 us/op 2.3050 us/op 0.80
fastMsgIdFn h64 xxhash / 10000 bytes 1.2480 us/op 1.5890 us/op 0.79
enrSubnets - fastDeserialize 64 bits 1.1690 us/op 1.7370 us/op 0.67
enrSubnets - ssz BitVector 64 bits 408.00 ns/op 645.00 ns/op 0.63
enrSubnets - fastDeserialize 4 bits 155.00 ns/op 282.00 ns/op 0.55
enrSubnets - ssz BitVector 4 bits 407.00 ns/op 637.00 ns/op 0.64
prioritizePeers score -10:0 att 32-0.1 sync 2-0 96.478 us/op 133.53 us/op 0.72
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 122.16 us/op 187.27 us/op 0.65
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 152.09 us/op 246.09 us/op 0.62
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 284.93 us/op 401.41 us/op 0.71
prioritizePeers score 0:0 att 64-1 sync 4-1 316.34 us/op 436.13 us/op 0.73
array of 16000 items push then shift 1.5071 us/op 1.8679 us/op 0.81
LinkedList of 16000 items push then shift 8.4860 ns/op 10.382 ns/op 0.82
array of 16000 items push then pop 43.953 ns/op 69.507 ns/op 0.63
LinkedList of 16000 items push then pop 8.2450 ns/op 9.8740 ns/op 0.84
array of 24000 items push then shift 2.3669 us/op 2.6369 us/op 0.90
LinkedList of 24000 items push then shift 8.7320 ns/op 10.021 ns/op 0.87
array of 24000 items push then pop 94.905 ns/op 137.00 ns/op 0.69
LinkedList of 24000 items push then pop 8.4690 ns/op 10.006 ns/op 0.85
intersect bitArray bitLen 8 6.7530 ns/op 7.8090 ns/op 0.86
intersect array and set length 8 57.111 ns/op 68.924 ns/op 0.83
intersect bitArray bitLen 128 31.329 ns/op 38.072 ns/op 0.82
intersect array and set length 128 762.26 ns/op 923.70 ns/op 0.83
bitArray.getTrueBitIndexes() bitLen 128 1.4490 us/op 1.8820 us/op 0.77
bitArray.getTrueBitIndexes() bitLen 248 2.3810 us/op 3.2130 us/op 0.74
bitArray.getTrueBitIndexes() bitLen 512 4.6600 us/op 6.1320 us/op 0.76
Buffer.concat 32 items 1.0630 us/op 1.1510 us/op 0.92
Uint8Array.set 32 items 1.7930 us/op 2.2260 us/op 0.81
Set add up to 64 items then delete first 3.9856 us/op 5.0878 us/op 0.78
OrderedSet add up to 64 items then delete first 5.0240 us/op 6.1926 us/op 0.81
Set add up to 64 items then delete last 4.2983 us/op 5.2399 us/op 0.82
OrderedSet add up to 64 items then delete last 5.3872 us/op 6.6265 us/op 0.81
Set add up to 64 items then delete middle 4.2496 us/op 5.2659 us/op 0.81
OrderedSet add up to 64 items then delete middle 6.4908 us/op 8.0391 us/op 0.81
Set add up to 128 items then delete first 8.7277 us/op 11.236 us/op 0.78
OrderedSet add up to 128 items then delete first 11.570 us/op 14.856 us/op 0.78
Set add up to 128 items then delete last 8.5219 us/op 10.856 us/op 0.78
OrderedSet add up to 128 items then delete last 10.794 us/op 13.869 us/op 0.78
Set add up to 128 items then delete middle 8.4179 us/op 10.492 us/op 0.80
OrderedSet add up to 128 items then delete middle 15.742 us/op 19.264 us/op 0.82
Set add up to 256 items then delete first 17.572 us/op 22.023 us/op 0.80
OrderedSet add up to 256 items then delete first 23.375 us/op 29.560 us/op 0.79
Set add up to 256 items then delete last 16.975 us/op 20.954 us/op 0.81
OrderedSet add up to 256 items then delete last 21.820 us/op 28.291 us/op 0.77
Set add up to 256 items then delete middle 16.816 us/op 21.079 us/op 0.80
OrderedSet add up to 256 items then delete middle 42.010 us/op 52.796 us/op 0.80
transfer serialized Status (84 B) 1.7720 us/op 2.0230 us/op 0.88
copy serialized Status (84 B) 1.4970 us/op 1.7470 us/op 0.86
transfer serialized SignedVoluntaryExit (112 B) 2.0720 us/op 2.0640 us/op 1.00
copy serialized SignedVoluntaryExit (112 B) 1.6000 us/op 1.8450 us/op 0.87
transfer serialized ProposerSlashing (416 B) 2.4010 us/op 3.0210 us/op 0.79
copy serialized ProposerSlashing (416 B) 2.2280 us/op 2.6250 us/op 0.85
transfer serialized Attestation (485 B) 2.4730 us/op 3.4050 us/op 0.73
copy serialized Attestation (485 B) 2.1540 us/op 2.6830 us/op 0.80
transfer serialized AttesterSlashing (33232 B) 2.4610 us/op 3.0230 us/op 0.81
copy serialized AttesterSlashing (33232 B) 4.8840 us/op 7.8160 us/op 0.62
transfer serialized Small SignedBeaconBlock (128000 B) 2.9710 us/op 3.1230 us/op 0.95
copy serialized Small SignedBeaconBlock (128000 B) 11.782 us/op 21.229 us/op 0.55
transfer serialized Avg SignedBeaconBlock (200000 B) 2.9500 us/op 4.3390 us/op 0.68
copy serialized Avg SignedBeaconBlock (200000 B) 16.377 us/op 26.038 us/op 0.63
transfer serialized BlobsSidecar (524380 B) 2.8010 us/op 3.5630 us/op 0.79
copy serialized BlobsSidecar (524380 B) 86.617 us/op 101.30 us/op 0.86
transfer serialized Big SignedBeaconBlock (1000000 B) 2.8320 us/op 4.0860 us/op 0.69
copy serialized Big SignedBeaconBlock (1000000 B) 159.67 us/op 229.85 us/op 0.69
pass gossip attestations to forkchoice per slot 4.6011 ms/op 3.7736 ms/op 1.22
forkChoice updateHead vc 100000 bc 64 eq 0 663.41 us/op 2.0529 ms/op 0.32
forkChoice updateHead vc 600000 bc 64 eq 0 4.2110 ms/op 16.272 ms/op 0.26
forkChoice updateHead vc 1000000 bc 64 eq 0 6.9671 ms/op 22.896 ms/op 0.30
forkChoice updateHead vc 600000 bc 320 eq 0 4.2309 ms/op 13.006 ms/op 0.33
forkChoice updateHead vc 600000 bc 1200 eq 0 4.3395 ms/op 12.737 ms/op 0.34
forkChoice updateHead vc 600000 bc 7200 eq 0 5.0059 ms/op 14.598 ms/op 0.34
forkChoice updateHead vc 600000 bc 64 eq 1000 11.812 ms/op 22.025 ms/op 0.54
forkChoice updateHead vc 600000 bc 64 eq 10000 11.930 ms/op 24.877 ms/op 0.48
forkChoice updateHead vc 600000 bc 64 eq 300000 15.576 ms/op 37.783 ms/op 0.41
computeDeltas 500000 validators 300 proto nodes 6.2505 ms/op 22.167 ms/op 0.28
computeDeltas 500000 validators 1200 proto nodes 6.1933 ms/op 22.621 ms/op 0.27
computeDeltas 500000 validators 7200 proto nodes 6.2215 ms/op 21.395 ms/op 0.29
computeDeltas 750000 validators 300 proto nodes 9.3131 ms/op 32.349 ms/op 0.29
computeDeltas 750000 validators 1200 proto nodes 9.3555 ms/op 33.258 ms/op 0.28
computeDeltas 750000 validators 7200 proto nodes 9.4515 ms/op 34.315 ms/op 0.28
computeDeltas 1400000 validators 300 proto nodes 17.649 ms/op 62.135 ms/op 0.28
computeDeltas 1400000 validators 1200 proto nodes 17.643 ms/op 63.606 ms/op 0.28
computeDeltas 1400000 validators 7200 proto nodes 17.592 ms/op 62.292 ms/op 0.28
computeDeltas 2100000 validators 300 proto nodes 26.974 ms/op 98.333 ms/op 0.27
computeDeltas 2100000 validators 1200 proto nodes 26.683 ms/op 97.049 ms/op 0.27
computeDeltas 2100000 validators 7200 proto nodes 26.851 ms/op 95.456 ms/op 0.28
computeProposerBoostScoreFromBalances 500000 validators 3.2473 ms/op 4.0240 ms/op 0.81
computeProposerBoostScoreFromBalances 750000 validators 3.2173 ms/op 4.0833 ms/op 0.79
computeProposerBoostScoreFromBalances 1400000 validators 3.1804 ms/op 4.0125 ms/op 0.79
computeProposerBoostScoreFromBalances 2100000 validators 3.2244 ms/op 3.9257 ms/op 0.82
altair processAttestation - 250000 vs - 7PWei normalcase 2.2103 ms/op 4.1446 ms/op 0.53
altair processAttestation - 250000 vs - 7PWei worstcase 3.2187 ms/op 5.8400 ms/op 0.55
altair processAttestation - setStatus - 1/6 committees join 177.98 us/op 226.73 us/op 0.78
altair processAttestation - setStatus - 1/3 committees join 347.33 us/op 484.38 us/op 0.72
altair processAttestation - setStatus - 1/2 committees join 470.78 us/op 631.17 us/op 0.75
altair processAttestation - setStatus - 2/3 committees join 596.16 us/op 696.71 us/op 0.86
altair processAttestation - setStatus - 4/5 committees join 804.73 us/op 976.30 us/op 0.82
altair processAttestation - setStatus - 100% committees join 944.54 us/op 1.1130 ms/op 0.85
altair processBlock - 250000 vs - 7PWei normalcase 9.5237 ms/op 12.018 ms/op 0.79
altair processBlock - 250000 vs - 7PWei normalcase hashState 18.297 ms/op 22.444 ms/op 0.82
altair processBlock - 250000 vs - 7PWei worstcase 36.814 ms/op 47.523 ms/op 0.77
altair processBlock - 250000 vs - 7PWei worstcase hashState 56.838 ms/op 74.707 ms/op 0.76
phase0 processBlock - 250000 vs - 7PWei normalcase 2.1905 ms/op 3.3407 ms/op 0.66
phase0 processBlock - 250000 vs - 7PWei worstcase 29.552 ms/op 36.892 ms/op 0.80
altair processEth1Data - 250000 vs - 7PWei normalcase 458.30 us/op 700.70 us/op 0.65
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 9.7510 us/op 17.458 us/op 0.56
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 32.451 us/op 58.857 us/op 0.55
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 17.523 us/op 20.962 us/op 0.84
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 7.2130 us/op 20.161 us/op 0.36
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 124.46 us/op 179.40 us/op 0.69
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 995.14 us/op 1.8187 ms/op 0.55
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.4469 ms/op 2.1555 ms/op 0.67
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.4161 ms/op 2.1903 ms/op 0.65
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 3.3838 ms/op 6.9401 ms/op 0.49
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.2881 ms/op 3.5962 ms/op 0.64
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 4.9470 ms/op 8.9889 ms/op 0.55
Tree 40 250000 create 303.65 ms/op 658.22 ms/op 0.46
Tree 40 250000 get(125000) 194.19 ns/op 250.06 ns/op 0.78
Tree 40 250000 set(125000) 963.92 ns/op 2.1682 us/op 0.44
Tree 40 250000 toArray() 20.835 ms/op 33.631 ms/op 0.62
Tree 40 250000 iterate all - toArray() + loop 21.972 ms/op 31.107 ms/op 0.71
Tree 40 250000 iterate all - get(i) 71.144 ms/op 98.313 ms/op 0.72
MutableVector 250000 create 11.830 ms/op 19.678 ms/op 0.60
MutableVector 250000 get(125000) 6.5260 ns/op 8.3300 ns/op 0.78
MutableVector 250000 set(125000) 270.07 ns/op 524.78 ns/op 0.51
MutableVector 250000 toArray() 3.0659 ms/op 5.1150 ms/op 0.60
MutableVector 250000 iterate all - toArray() + loop 3.1976 ms/op 5.5568 ms/op 0.58
MutableVector 250000 iterate all - get(i) 1.5727 ms/op 1.8764 ms/op 0.84
Array 250000 create 2.9098 ms/op 5.4582 ms/op 0.53
Array 250000 clone - spread 996.98 us/op 2.0865 ms/op 0.48
Array 250000 get(125000) 0.48500 ns/op 1.5950 ns/op 0.30
Array 250000 set(125000) 0.55700 ns/op 1.7460 ns/op 0.32
Array 250000 iterate all - loop 109.34 us/op 100.65 us/op 1.09
effectiveBalanceIncrements clone Uint8Array 300000 21.314 us/op 71.506 us/op 0.30
effectiveBalanceIncrements clone MutableVector 300000 255.00 ns/op 551.00 ns/op 0.46
effectiveBalanceIncrements rw all Uint8Array 300000 178.51 us/op 239.79 us/op 0.74
effectiveBalanceIncrements rw all MutableVector 300000 74.291 ms/op 170.19 ms/op 0.44
phase0 afterProcessEpoch - 250000 vs - 7PWei 112.48 ms/op 137.09 ms/op 0.82
phase0 beforeProcessEpoch - 250000 vs - 7PWei 38.294 ms/op 44.068 ms/op 0.87
altair processEpoch - mainnet_e81889 312.72 ms/op 380.05 ms/op 0.82
mainnet_e81889 - altair beforeProcessEpoch 60.669 ms/op 68.066 ms/op 0.89
mainnet_e81889 - altair processJustificationAndFinalization 14.026 us/op 25.499 us/op 0.55
mainnet_e81889 - altair processInactivityUpdates 5.3848 ms/op 7.7108 ms/op 0.70
mainnet_e81889 - altair processRewardsAndPenalties 59.203 ms/op 81.393 ms/op 0.73
mainnet_e81889 - altair processRegistryUpdates 2.5290 us/op 6.4930 us/op 0.39
mainnet_e81889 - altair processSlashings 442.00 ns/op 887.00 ns/op 0.50
mainnet_e81889 - altair processEth1DataReset 526.00 ns/op 1.2480 us/op 0.42
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2772 ms/op 1.9482 ms/op 0.66
mainnet_e81889 - altair processSlashingsReset 2.5900 us/op 6.8050 us/op 0.38
mainnet_e81889 - altair processRandaoMixesReset 4.7260 us/op 10.215 us/op 0.46
mainnet_e81889 - altair processHistoricalRootsUpdate 812.00 ns/op 1.9780 us/op 0.41
mainnet_e81889 - altair processParticipationFlagUpdates 1.8440 us/op 5.0040 us/op 0.37
mainnet_e81889 - altair processSyncCommitteeUpdates 638.00 ns/op 1.3290 us/op 0.48
mainnet_e81889 - altair afterProcessEpoch 125.38 ms/op 153.94 ms/op 0.81
capella processEpoch - mainnet_e217614 1.0622 s/op 1.2349 s/op 0.86
mainnet_e217614 - capella beforeProcessEpoch 242.22 ms/op 289.02 ms/op 0.84
mainnet_e217614 - capella processJustificationAndFinalization 15.276 us/op 24.664 us/op 0.62
mainnet_e217614 - capella processInactivityUpdates 20.172 ms/op 26.352 ms/op 0.77
mainnet_e217614 - capella processRewardsAndPenalties 295.37 ms/op 351.14 ms/op 0.84
mainnet_e217614 - capella processRegistryUpdates 18.644 us/op 26.810 us/op 0.70
mainnet_e217614 - capella processSlashings 502.00 ns/op 884.00 ns/op 0.57
mainnet_e217614 - capella processEth1DataReset 469.00 ns/op 1.0370 us/op 0.45
mainnet_e217614 - capella processEffectiveBalanceUpdates 4.2112 ms/op 4.7911 ms/op 0.88
mainnet_e217614 - capella processSlashingsReset 2.3040 us/op 4.8330 us/op 0.48
mainnet_e217614 - capella processRandaoMixesReset 3.8840 us/op 12.819 us/op 0.30
mainnet_e217614 - capella processHistoricalRootsUpdate 443.00 ns/op 1.2780 us/op 0.35
mainnet_e217614 - capella processParticipationFlagUpdates 1.8860 us/op 2.4840 us/op 0.76
mainnet_e217614 - capella afterProcessEpoch 294.10 ms/op 323.59 ms/op 0.91
phase0 processEpoch - mainnet_e58758 320.96 ms/op 375.79 ms/op 0.85
mainnet_e58758 - phase0 beforeProcessEpoch 113.34 ms/op 133.42 ms/op 0.85
mainnet_e58758 - phase0 processJustificationAndFinalization 15.605 us/op 20.338 us/op 0.77
mainnet_e58758 - phase0 processRewardsAndPenalties 53.964 ms/op 60.190 ms/op 0.90
mainnet_e58758 - phase0 processRegistryUpdates 9.5780 us/op 17.461 us/op 0.55
mainnet_e58758 - phase0 processSlashings 491.00 ns/op 1.1950 us/op 0.41
mainnet_e58758 - phase0 processEth1DataReset 412.00 ns/op 955.00 ns/op 0.43
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.0147 ms/op 1.4479 ms/op 0.70
mainnet_e58758 - phase0 processSlashingsReset 2.1990 us/op 5.9280 us/op 0.37
mainnet_e58758 - phase0 processRandaoMixesReset 3.5230 us/op 9.2880 us/op 0.38
mainnet_e58758 - phase0 processHistoricalRootsUpdate 385.00 ns/op 946.00 ns/op 0.41
mainnet_e58758 - phase0 processParticipationRecordUpdates 5.2200 us/op 8.5740 us/op 0.61
mainnet_e58758 - phase0 afterProcessEpoch 101.45 ms/op 121.32 ms/op 0.84
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2332 ms/op 1.6920 ms/op 0.73
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.4537 ms/op 1.6736 ms/op 0.87
altair processInactivityUpdates - 250000 normalcase 18.763 ms/op 26.399 ms/op 0.71
altair processInactivityUpdates - 250000 worstcase 22.174 ms/op 27.812 ms/op 0.80
phase0 processRegistryUpdates - 250000 normalcase 9.5640 us/op 12.128 us/op 0.79
phase0 processRegistryUpdates - 250000 badcase_full_deposits 297.44 us/op 439.30 us/op 0.68
phase0 processRegistryUpdates - 250000 worstcase 0.5 114.93 ms/op 163.40 ms/op 0.70
altair processRewardsAndPenalties - 250000 normalcase 48.687 ms/op 79.270 ms/op 0.61
altair processRewardsAndPenalties - 250000 worstcase 54.965 ms/op 77.405 ms/op 0.71
phase0 getAttestationDeltas - 250000 normalcase 7.7471 ms/op 10.574 ms/op 0.73
phase0 getAttestationDeltas - 250000 worstcase 7.8320 ms/op 10.829 ms/op 0.72
phase0 processSlashings - 250000 worstcase 2.2412 ms/op 2.8565 ms/op 0.78
altair processSyncCommitteeUpdates - 250000 153.53 ms/op 176.90 ms/op 0.87
BeaconState.hashTreeRoot - No change 258.00 ns/op 304.00 ns/op 0.85
BeaconState.hashTreeRoot - 1 full validator 51.547 us/op 60.730 us/op 0.85
BeaconState.hashTreeRoot - 32 full validator 546.35 us/op 576.01 us/op 0.95
BeaconState.hashTreeRoot - 512 full validator 5.4437 ms/op 6.5368 ms/op 0.83
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 64.407 us/op 75.468 us/op 0.85
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 893.26 us/op 1.0309 ms/op 0.87
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 11.429 ms/op 15.438 ms/op 0.74
BeaconState.hashTreeRoot - 1 balances 49.571 us/op 63.841 us/op 0.78
BeaconState.hashTreeRoot - 32 balances 453.02 us/op 518.44 us/op 0.87
BeaconState.hashTreeRoot - 512 balances 4.3099 ms/op 5.2875 ms/op 0.82
BeaconState.hashTreeRoot - 250000 balances 74.275 ms/op 90.150 ms/op 0.82
aggregationBits - 2048 els - zipIndexesInBitList 16.279 us/op 22.692 us/op 0.72
regular array get 100000 times 43.663 us/op 47.157 us/op 0.93
wrappedArray get 100000 times 44.135 us/op 36.033 us/op 1.22
arrayWithProxy get 100000 times 15.899 ms/op 16.147 ms/op 0.98
ssz.Root.equals 201.00 ns/op 258.00 ns/op 0.78
byteArrayEquals 206.00 ns/op 274.00 ns/op 0.75
shuffle list - 16384 els 6.9691 ms/op 7.3401 ms/op 0.95
shuffle list - 250000 els 103.48 ms/op 111.33 ms/op 0.93
processSlot - 1 slots 8.3490 us/op 9.9130 us/op 0.84
processSlot - 32 slots 1.3327 ms/op 1.5796 ms/op 0.84
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 47.867 ms/op 59.585 ms/op 0.80
getCommitteeAssignments - req 1 vs - 250000 vc 2.5086 ms/op 2.6879 ms/op 0.93
getCommitteeAssignments - req 100 vs - 250000 vc 3.7178 ms/op 4.2058 ms/op 0.88
getCommitteeAssignments - req 1000 vs - 250000 vc 4.0913 ms/op 4.4178 ms/op 0.93
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.8500 ns/op 5.5000 ns/op 0.88
state getBlockRootAtSlot - 250000 vs - 7PWei 705.30 ns/op 949.95 ns/op 0.74
computeProposers - vc 250000 8.9749 ms/op 9.9071 ms/op 0.91
computeEpochShuffling - vc 250000 105.97 ms/op 108.79 ms/op 0.97
getNextSyncCommittee - vc 250000 153.00 ms/op 175.71 ms/op 0.87
computeSigningRoot for AttestationData 13.350 us/op 14.519 us/op 0.92
hash AttestationData serialized data then Buffer.toString(base64) 2.3548 us/op 2.5546 us/op 0.92
toHexString serialized data 1.0867 us/op 1.1965 us/op 0.91
Buffer.toString(base64) 208.81 ns/op 247.37 ns/op 0.84

by benchmarkbot/action

@philknows philknows added this to the v1.11.0 milestone Aug 14, 2023
@twoeths
Copy link
Contributor Author

twoeths commented Aug 15, 2023

The benchmark looks great, also the result in a mainnet node

Screenshot 2023-08-15 at 09 12 56

it really helps "time till block become head" metric

Screenshot 2023-08-15 at 09 14 15

@twoeths twoeths marked this pull request as ready for review August 15, 2023 03:13
@twoeths twoeths requested a review from a team as a code owner August 15, 2023 03:13
return this.protoArray.maybePrune(finalizedRoot);
const prunedNodes = this.protoArray.maybePrune(finalizedRoot);
const prunedCount = prunedNodes.length;
for (const vote of this.votes) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If this array if not sparse, it's always faster to use a regular for loop

Copy link
Contributor Author

Choose a reason for hiding this comment

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

will work on this in another PR, merging to see if it helps the I/O lag issue in subsribe-all-subnets mode

Copy link
Contributor Author

Choose a reason for hiding this comment

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

addressed in #5907

@twoeths twoeths merged commit f9c7107 into unstable Aug 17, 2023
11 checks passed
@twoeths twoeths deleted the tuyen/forkchoice_vote_by_index branch August 17, 2023 01:19
@wemeetagain
Copy link
Member

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

Improve recomputeForkChoiceHead
4 participants