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

fix: improve regen state #7033

Merged
merged 5 commits into from
Sep 4, 2024
Merged

fix: improve regen state #7033

merged 5 commits into from
Sep 4, 2024

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Aug 19, 2024

Motivation

  • improve regen state
  • more metrics when regen state

Description

  • most of the time to regen state is due to loading block from db. At this time there are a lot of gossip attestation messages coming so we need to save time to load all blocks in a single call using Promise.all() , see Performance issue regen state #7002
  • add more metrics in regen.getState():
    • time to get seed state
    • block count
    • time to load blocks from db
    • time to run state transition

will have follow-up PR for Grafana dashboard once this is merged

closes #7002

Copy link

codecov bot commented Aug 19, 2024

Codecov Report

Attention: Patch coverage is 1.47059% with 67 lines in your changes missing coverage. Please review.

Project coverage is 49.17%. Comparing base (6f470f8) to head (9911750).
Report is 85 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #7033      +/-   ##
============================================
- Coverage     49.25%   49.17%   -0.08%     
============================================
  Files           578      578              
  Lines         37443    37502      +59     
  Branches       2172     2171       -1     
============================================
  Hits          18441    18441              
- Misses        18962    19021      +59     
  Partials         40       40              

Copy link
Contributor

github-actions bot commented Aug 19, 2024

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 6076e72 Previous: 6d01593 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.9049 ms/op 2.6969 ms/op 0.71
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 46.460 us/op 137.04 us/op 0.34
BLS verify - blst 1.4810 ms/op 1.1575 ms/op 1.28
BLS verifyMultipleSignatures 3 - blst 2.2541 ms/op 1.8172 ms/op 1.24
BLS verifyMultipleSignatures 8 - blst 2.5016 ms/op 2.7915 ms/op 0.90
BLS verifyMultipleSignatures 32 - blst 7.1325 ms/op 7.6422 ms/op 0.93
BLS verifyMultipleSignatures 64 - blst 10.293 ms/op 14.212 ms/op 0.72
BLS verifyMultipleSignatures 128 - blst 16.920 ms/op 26.648 ms/op 0.63
BLS deserializing 10000 signatures 653.15 ms/op 937.59 ms/op 0.70
BLS deserializing 100000 signatures 6.7294 s/op 9.3440 s/op 0.72
BLS verifyMultipleSignatures - same message - 3 - blst 1.5693 ms/op 1.1901 ms/op 1.32
BLS verifyMultipleSignatures - same message - 8 - blst 1.0571 ms/op 1.3583 ms/op 0.78
BLS verifyMultipleSignatures - same message - 32 - blst 1.9266 ms/op 2.4223 ms/op 0.80
BLS verifyMultipleSignatures - same message - 64 - blst 2.8071 ms/op 3.9451 ms/op 0.71
BLS verifyMultipleSignatures - same message - 128 - blst 4.3820 ms/op 7.2646 ms/op 0.60
BLS aggregatePubkeys 32 - blst 19.484 us/op 29.181 us/op 0.67
BLS aggregatePubkeys 128 - blst 67.501 us/op 100.53 us/op 0.67
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 77.908 ms/op 78.741 ms/op 0.99
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 66.170 ms/op 71.539 ms/op 0.92
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 35.920 ms/op 60.125 ms/op 0.60
getSlashingsAndExits - default max 91.730 us/op 157.31 us/op 0.58
getSlashingsAndExits - 2k 284.39 us/op 431.03 us/op 0.66
proposeBlockBody type=full, size=empty 5.8105 ms/op 9.3370 ms/op 0.62
isKnown best case - 1 super set check 307.00 ns/op 733.00 ns/op 0.42
isKnown normal case - 2 super set checks 287.00 ns/op 708.00 ns/op 0.41
isKnown worse case - 16 super set checks 278.00 ns/op 810.00 ns/op 0.34
InMemoryCheckpointStateCache - add get delete 2.7920 us/op 4.4530 us/op 0.63
validate api signedAggregateAndProof - struct 1.5130 ms/op 1.8001 ms/op 0.84
validate gossip signedAggregateAndProof - struct 1.4180 ms/op 1.8076 ms/op 0.78
validate gossip attestation - vc 640000 1.1047 ms/op 1.1664 ms/op 0.95
batch validate gossip attestation - vc 640000 - chunk 32 127.70 us/op 166.38 us/op 0.77
batch validate gossip attestation - vc 640000 - chunk 64 111.49 us/op 137.28 us/op 0.81
batch validate gossip attestation - vc 640000 - chunk 128 104.93 us/op 116.87 us/op 0.90
batch validate gossip attestation - vc 640000 - chunk 256 102.75 us/op 114.45 us/op 0.90
pickEth1Vote - no votes 963.46 us/op 1.2466 ms/op 0.77
pickEth1Vote - max votes 6.8774 ms/op 7.7442 ms/op 0.89
pickEth1Vote - Eth1Data hashTreeRoot value x2048 15.306 ms/op 20.766 ms/op 0.74
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 24.756 ms/op 19.492 ms/op 1.27
pickEth1Vote - Eth1Data fastSerialize value x2048 437.15 us/op 530.82 us/op 0.82
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.5055 ms/op 3.4882 ms/op 1.00
bytes32 toHexString 410.00 ns/op 614.00 ns/op 0.67
bytes32 Buffer.toString(hex) 243.00 ns/op 276.00 ns/op 0.88
bytes32 Buffer.toString(hex) from Uint8Array 361.00 ns/op 477.00 ns/op 0.76
bytes32 Buffer.toString(hex) + 0x 249.00 ns/op 277.00 ns/op 0.90
Object access 1 prop 0.13200 ns/op 0.15800 ns/op 0.84
Map access 1 prop 0.12900 ns/op 0.13900 ns/op 0.93
Object get x1000 5.6680 ns/op 6.7140 ns/op 0.84
Map get x1000 6.3650 ns/op 7.2300 ns/op 0.88
Object set x1000 30.522 ns/op 38.073 ns/op 0.80
Map set x1000 21.271 ns/op 26.684 ns/op 0.80
Return object 10000 times 0.27680 ns/op 0.32210 ns/op 0.86
Throw Error 10000 times 3.2432 us/op 3.5738 us/op 0.91
toHex 139.46 ns/op 154.72 ns/op 0.90
Buffer.from 129.60 ns/op 152.21 ns/op 0.85
shared Buffer 83.235 ns/op 97.588 ns/op 0.85
fastMsgIdFn sha256 / 200 bytes 2.2140 us/op 2.3650 us/op 0.94
fastMsgIdFn h32 xxhash / 200 bytes 225.00 ns/op 249.00 ns/op 0.90
fastMsgIdFn h64 xxhash / 200 bytes 265.00 ns/op 296.00 ns/op 0.90
fastMsgIdFn sha256 / 1000 bytes 7.4060 us/op 8.0370 us/op 0.92
fastMsgIdFn h32 xxhash / 1000 bytes 349.00 ns/op 401.00 ns/op 0.87
fastMsgIdFn h64 xxhash / 1000 bytes 339.00 ns/op 355.00 ns/op 0.95
fastMsgIdFn sha256 / 10000 bytes 64.145 us/op 67.675 us/op 0.95
fastMsgIdFn h32 xxhash / 10000 bytes 1.8040 us/op 1.9620 us/op 0.92
fastMsgIdFn h64 xxhash / 10000 bytes 1.1910 us/op 1.2960 us/op 0.92
send data - 1000 256B messages 11.391 ms/op 13.114 ms/op 0.87
send data - 1000 512B messages 15.984 ms/op 17.573 ms/op 0.91
send data - 1000 1024B messages 27.228 ms/op 29.786 ms/op 0.91
send data - 1000 1200B messages 27.088 ms/op 26.747 ms/op 1.01
send data - 1000 2048B messages 33.137 ms/op 35.470 ms/op 0.93
send data - 1000 4096B messages 32.055 ms/op 32.245 ms/op 0.99
send data - 1000 16384B messages 73.143 ms/op 81.485 ms/op 0.90
send data - 1000 65536B messages 201.07 ms/op 265.12 ms/op 0.76
enrSubnets - fastDeserialize 64 bits 1.0420 us/op 1.2030 us/op 0.87
enrSubnets - ssz BitVector 64 bits 341.00 ns/op 372.00 ns/op 0.92
enrSubnets - fastDeserialize 4 bits 141.00 ns/op 168.00 ns/op 0.84
enrSubnets - ssz BitVector 4 bits 347.00 ns/op 426.00 ns/op 0.81
prioritizePeers score -10:0 att 32-0.1 sync 2-0 163.24 us/op 188.72 us/op 0.86
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 170.42 us/op 184.84 us/op 0.92
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 412.95 us/op 286.63 us/op 1.44
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 584.94 us/op 438.32 us/op 1.33
prioritizePeers score 0:0 att 64-1 sync 4-1 821.42 us/op 801.84 us/op 1.02
array of 16000 items push then shift 1.5489 us/op 1.9385 us/op 0.80
LinkedList of 16000 items push then shift 6.7690 ns/op 8.8580 ns/op 0.76
array of 16000 items push then pop 101.05 ns/op 140.13 ns/op 0.72
LinkedList of 16000 items push then pop 6.6040 ns/op 8.1420 ns/op 0.81
array of 24000 items push then shift 2.2749 us/op 2.5682 us/op 0.89
LinkedList of 24000 items push then shift 6.7010 ns/op 8.0400 ns/op 0.83
array of 24000 items push then pop 136.70 ns/op 186.88 ns/op 0.73
LinkedList of 24000 items push then pop 6.8400 ns/op 8.5000 ns/op 0.80
intersect bitArray bitLen 8 6.3330 ns/op 7.7250 ns/op 0.82
intersect array and set length 8 46.404 ns/op 51.765 ns/op 0.90
intersect bitArray bitLen 128 29.458 ns/op 32.643 ns/op 0.90
intersect array and set length 128 672.04 ns/op 866.08 ns/op 0.78
bitArray.getTrueBitIndexes() bitLen 128 2.3730 us/op 2.1110 us/op 1.12
bitArray.getTrueBitIndexes() bitLen 248 3.8940 us/op 3.9910 us/op 0.98
bitArray.getTrueBitIndexes() bitLen 512 8.0560 us/op 8.7750 us/op 0.92
Buffer.concat 32 items 931.00 ns/op 1.1770 us/op 0.79
Uint8Array.set 32 items 1.5720 us/op 1.7870 us/op 0.88
Buffer.copy 1.8230 us/op 1.9670 us/op 0.93
Uint8Array.set - with subarray 2.8410 us/op 2.9400 us/op 0.97
Uint8Array.set - without subarray 1.4790 us/op 1.6180 us/op 0.91
getUint32 - dataview 228.00 ns/op 281.00 ns/op 0.81
getUint32 - manual 144.00 ns/op 189.00 ns/op 0.76
Set add up to 64 items then delete first 2.1359 us/op 2.4505 us/op 0.87
OrderedSet add up to 64 items then delete first 3.1523 us/op 4.3257 us/op 0.73
Set add up to 64 items then delete last 2.6051 us/op 3.9953 us/op 0.65
OrderedSet add up to 64 items then delete last 4.1753 us/op 5.3918 us/op 0.77
Set add up to 64 items then delete middle 2.8129 us/op 2.8880 us/op 0.97
OrderedSet add up to 64 items then delete middle 5.7188 us/op 6.2907 us/op 0.91
Set add up to 128 items then delete first 5.3766 us/op 6.2008 us/op 0.87
OrderedSet add up to 128 items then delete first 7.4133 us/op 9.2181 us/op 0.80
Set add up to 128 items then delete last 5.4148 us/op 7.0064 us/op 0.77
OrderedSet add up to 128 items then delete last 8.4545 us/op 9.2842 us/op 0.91
Set add up to 128 items then delete middle 5.4616 us/op 5.8901 us/op 0.93
OrderedSet add up to 128 items then delete middle 14.441 us/op 14.941 us/op 0.97
Set add up to 256 items then delete first 10.564 us/op 11.137 us/op 0.95
OrderedSet add up to 256 items then delete first 14.643 us/op 22.705 us/op 0.64
Set add up to 256 items then delete last 10.692 us/op 15.787 us/op 0.68
OrderedSet add up to 256 items then delete last 17.405 us/op 25.672 us/op 0.68
Set add up to 256 items then delete middle 11.472 us/op 15.873 us/op 0.72
OrderedSet add up to 256 items then delete middle 43.686 us/op 64.128 us/op 0.68
transfer serialized Status (84 B) 1.3660 us/op 1.6590 us/op 0.82
copy serialized Status (84 B) 1.2320 us/op 1.3800 us/op 0.89
transfer serialized SignedVoluntaryExit (112 B) 1.5080 us/op 1.5620 us/op 0.97
copy serialized SignedVoluntaryExit (112 B) 1.2140 us/op 1.3740 us/op 0.88
transfer serialized ProposerSlashing (416 B) 1.9320 us/op 2.4350 us/op 0.79
copy serialized ProposerSlashing (416 B) 1.8650 us/op 3.7960 us/op 0.49
transfer serialized Attestation (485 B) 2.0130 us/op 4.4940 us/op 0.45
copy serialized Attestation (485 B) 1.9020 us/op 4.0410 us/op 0.47
transfer serialized AttesterSlashing (33232 B) 2.4540 us/op 4.1250 us/op 0.59
copy serialized AttesterSlashing (33232 B) 5.5810 us/op 15.615 us/op 0.36
transfer serialized Small SignedBeaconBlock (128000 B) 2.5910 us/op 4.4090 us/op 0.59
copy serialized Small SignedBeaconBlock (128000 B) 12.746 us/op 28.044 us/op 0.45
transfer serialized Avg SignedBeaconBlock (200000 B) 2.5590 us/op 3.8730 us/op 0.66
copy serialized Avg SignedBeaconBlock (200000 B) 17.597 us/op 29.009 us/op 0.61
transfer serialized BlobsSidecar (524380 B) 2.3380 us/op 2.8820 us/op 0.81
copy serialized BlobsSidecar (524380 B) 190.67 us/op 85.920 us/op 2.22
transfer serialized Big SignedBeaconBlock (1000000 B) 2.4370 us/op 3.9720 us/op 0.61
copy serialized Big SignedBeaconBlock (1000000 B) 141.58 us/op 181.93 us/op 0.78
pass gossip attestations to forkchoice per slot 2.8264 ms/op 3.0532 ms/op 0.93
forkChoice updateHead vc 100000 bc 64 eq 0 488.28 us/op 527.20 us/op 0.93
forkChoice updateHead vc 600000 bc 64 eq 0 3.1843 ms/op 3.4635 ms/op 0.92
forkChoice updateHead vc 1000000 bc 64 eq 0 5.7146 ms/op 5.8508 ms/op 0.98
forkChoice updateHead vc 600000 bc 320 eq 0 3.1113 ms/op 3.3821 ms/op 0.92
forkChoice updateHead vc 600000 bc 1200 eq 0 3.1842 ms/op 3.4205 ms/op 0.93
forkChoice updateHead vc 600000 bc 7200 eq 0 3.5928 ms/op 4.2611 ms/op 0.84
forkChoice updateHead vc 600000 bc 64 eq 1000 10.890 ms/op 11.621 ms/op 0.94
forkChoice updateHead vc 600000 bc 64 eq 10000 11.298 ms/op 11.791 ms/op 0.96
forkChoice updateHead vc 600000 bc 64 eq 300000 14.873 ms/op 16.063 ms/op 0.93
computeDeltas 500000 validators 300 proto nodes 3.7944 ms/op 3.8128 ms/op 1.00
computeDeltas 500000 validators 1200 proto nodes 3.8369 ms/op 3.8168 ms/op 1.01
computeDeltas 500000 validators 7200 proto nodes 3.8114 ms/op 3.8018 ms/op 1.00
computeDeltas 750000 validators 300 proto nodes 5.5964 ms/op 5.6262 ms/op 0.99
computeDeltas 750000 validators 1200 proto nodes 5.5023 ms/op 5.8429 ms/op 0.94
computeDeltas 750000 validators 7200 proto nodes 5.4778 ms/op 5.9507 ms/op 0.92
computeDeltas 1400000 validators 300 proto nodes 10.563 ms/op 11.024 ms/op 0.96
computeDeltas 1400000 validators 1200 proto nodes 10.634 ms/op 10.562 ms/op 1.01
computeDeltas 1400000 validators 7200 proto nodes 10.653 ms/op 10.232 ms/op 1.04
computeDeltas 2100000 validators 300 proto nodes 15.656 ms/op 16.072 ms/op 0.97
computeDeltas 2100000 validators 1200 proto nodes 16.343 ms/op 15.907 ms/op 1.03
computeDeltas 2100000 validators 7200 proto nodes 16.533 ms/op 16.388 ms/op 1.01
altair processAttestation - 250000 vs - 7PWei normalcase 2.0672 ms/op 2.0281 ms/op 1.02
altair processAttestation - 250000 vs - 7PWei worstcase 3.7881 ms/op 2.9187 ms/op 1.30
altair processAttestation - setStatus - 1/6 committees join 108.67 us/op 104.00 us/op 1.04
altair processAttestation - setStatus - 1/3 committees join 212.81 us/op 208.75 us/op 1.02
altair processAttestation - setStatus - 1/2 committees join 273.27 us/op 296.62 us/op 0.92
altair processAttestation - setStatus - 2/3 committees join 340.34 us/op 374.68 us/op 0.91
altair processAttestation - setStatus - 4/5 committees join 497.19 us/op 525.00 us/op 0.95
altair processAttestation - setStatus - 100% committees join 602.52 us/op 659.40 us/op 0.91
altair processBlock - 250000 vs - 7PWei normalcase 4.8341 ms/op 5.0869 ms/op 0.95
altair processBlock - 250000 vs - 7PWei normalcase hashState 29.013 ms/op 26.726 ms/op 1.09
altair processBlock - 250000 vs - 7PWei worstcase 37.818 ms/op 35.608 ms/op 1.06
altair processBlock - 250000 vs - 7PWei worstcase hashState 81.334 ms/op 76.680 ms/op 1.06
phase0 processBlock - 250000 vs - 7PWei normalcase 2.6959 ms/op 2.1263 ms/op 1.27
phase0 processBlock - 250000 vs - 7PWei worstcase 27.458 ms/op 26.361 ms/op 1.04
altair processEth1Data - 250000 vs - 7PWei normalcase 362.02 us/op 410.46 us/op 0.88
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 6.2040 us/op 6.3610 us/op 0.98
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 28.307 us/op 31.115 us/op 0.91
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 9.8170 us/op 11.091 us/op 0.89
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 6.0850 us/op 8.3060 us/op 0.73
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 110.11 us/op 94.111 us/op 1.17
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 702.47 us/op 872.11 us/op 0.81
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 991.31 us/op 1.0684 ms/op 0.93
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.0486 ms/op 1.0058 ms/op 1.04
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.7229 ms/op 2.7519 ms/op 0.99
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.6229 ms/op 1.7413 ms/op 0.93
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 4.3060 ms/op 4.4345 ms/op 0.97
Tree 40 250000 create 251.31 ms/op 244.92 ms/op 1.03
Tree 40 250000 get(125000) 157.47 ns/op 174.37 ns/op 0.90
Tree 40 250000 set(125000) 728.23 ns/op 773.26 ns/op 0.94
Tree 40 250000 toArray() 18.528 ms/op 21.366 ms/op 0.87
Tree 40 250000 iterate all - toArray() + loop 21.191 ms/op 21.486 ms/op 0.99
Tree 40 250000 iterate all - get(i) 51.922 ms/op 60.421 ms/op 0.86
MutableVector 250000 create 8.3005 ms/op 8.3994 ms/op 0.99
MutableVector 250000 get(125000) 10.818 ns/op 10.284 ns/op 1.05
MutableVector 250000 set(125000) 220.94 ns/op 209.36 ns/op 1.06
MutableVector 250000 toArray() 3.7150 ms/op 4.0600 ms/op 0.92
MutableVector 250000 iterate all - toArray() + loop 3.7029 ms/op 4.2981 ms/op 0.86
MutableVector 250000 iterate all - get(i) 1.5176 ms/op 1.8111 ms/op 0.84
Array 250000 create 3.0353 ms/op 3.4750 ms/op 0.87
Array 250000 clone - spread 1.5189 ms/op 1.4401 ms/op 1.05
Array 250000 get(125000) 0.39800 ns/op 0.44200 ns/op 0.90
Array 250000 set(125000) 0.41900 ns/op 0.45800 ns/op 0.91
Array 250000 iterate all - loop 105.39 us/op 114.46 us/op 0.92
effectiveBalanceIncrements clone Uint8Array 300000 31.922 us/op 29.538 us/op 1.08
effectiveBalanceIncrements clone MutableVector 300000 126.00 ns/op 137.00 ns/op 0.92
effectiveBalanceIncrements rw all Uint8Array 300000 198.28 us/op 210.28 us/op 0.94
effectiveBalanceIncrements rw all MutableVector 300000 67.560 ms/op 70.186 ms/op 0.96
phase0 afterProcessEpoch - 250000 vs - 7PWei 84.672 ms/op 93.917 ms/op 0.90
Array.fill - length 1000000 3.6419 ms/op 3.5350 ms/op 1.03
Array push - length 1000000 12.042 ms/op 24.845 ms/op 0.48
Array.get 0.29790 ns/op 0.28507 ns/op 1.05
Uint8Array.get 0.44634 ns/op 0.45008 ns/op 0.99
phase0 beforeProcessEpoch - 250000 vs - 7PWei 16.231 ms/op 15.971 ms/op 1.02
altair processEpoch - mainnet_e81889 353.72 ms/op 334.79 ms/op 1.06
mainnet_e81889 - altair beforeProcessEpoch 17.105 ms/op 18.940 ms/op 0.90
mainnet_e81889 - altair processJustificationAndFinalization 17.838 us/op 12.378 us/op 1.44
mainnet_e81889 - altair processInactivityUpdates 5.0232 ms/op 5.3328 ms/op 0.94
mainnet_e81889 - altair processRewardsAndPenalties 60.026 ms/op 51.894 ms/op 1.16
mainnet_e81889 - altair processRegistryUpdates 2.6940 us/op 1.8200 us/op 1.48
mainnet_e81889 - altair processSlashings 668.00 ns/op 326.00 ns/op 2.05
mainnet_e81889 - altair processEth1DataReset 570.00 ns/op 295.00 ns/op 1.93
mainnet_e81889 - altair processEffectiveBalanceUpdates 3.1850 ms/op 1.2375 ms/op 2.57
mainnet_e81889 - altair processSlashingsReset 4.4950 us/op 2.4770 us/op 1.81
mainnet_e81889 - altair processRandaoMixesReset 5.1560 us/op 3.3030 us/op 1.56
mainnet_e81889 - altair processHistoricalRootsUpdate 637.00 ns/op 305.00 ns/op 2.09
mainnet_e81889 - altair processParticipationFlagUpdates 2.2860 us/op 1.6480 us/op 1.39
mainnet_e81889 - altair processSyncCommitteeUpdates 413.00 ns/op 249.00 ns/op 1.66
mainnet_e81889 - altair afterProcessEpoch 93.155 ms/op 99.507 ms/op 0.94
capella processEpoch - mainnet_e217614 1.2472 s/op 1.4114 s/op 0.88
mainnet_e217614 - capella beforeProcessEpoch 79.271 ms/op 67.835 ms/op 1.17
mainnet_e217614 - capella processJustificationAndFinalization 20.569 us/op 15.062 us/op 1.37
mainnet_e217614 - capella processInactivityUpdates 16.422 ms/op 18.382 ms/op 0.89
mainnet_e217614 - capella processRewardsAndPenalties 282.74 ms/op 238.24 ms/op 1.19
mainnet_e217614 - capella processRegistryUpdates 20.709 us/op 11.949 us/op 1.73
mainnet_e217614 - capella processSlashings 687.00 ns/op 375.00 ns/op 1.83
mainnet_e217614 - capella processEth1DataReset 522.00 ns/op 305.00 ns/op 1.71
mainnet_e217614 - capella processEffectiveBalanceUpdates 9.8152 ms/op 11.659 ms/op 0.84
mainnet_e217614 - capella processSlashingsReset 5.9410 us/op 2.3690 us/op 2.51
mainnet_e217614 - capella processRandaoMixesReset 5.8030 us/op 8.0020 us/op 0.73
mainnet_e217614 - capella processHistoricalRootsUpdate 637.00 ns/op 663.00 ns/op 0.96
mainnet_e217614 - capella processParticipationFlagUpdates 2.8900 us/op 2.0240 us/op 1.43
mainnet_e217614 - capella afterProcessEpoch 222.57 ms/op 252.46 ms/op 0.88
phase0 processEpoch - mainnet_e58758 419.58 ms/op 405.20 ms/op 1.04
mainnet_e58758 - phase0 beforeProcessEpoch 93.299 ms/op 82.728 ms/op 1.13
mainnet_e58758 - phase0 processJustificationAndFinalization 21.427 us/op 17.739 us/op 1.21
mainnet_e58758 - phase0 processRewardsAndPenalties 39.265 ms/op 35.255 ms/op 1.11
mainnet_e58758 - phase0 processRegistryUpdates 10.553 us/op 6.7890 us/op 1.55
mainnet_e58758 - phase0 processSlashings 692.00 ns/op 356.00 ns/op 1.94
mainnet_e58758 - phase0 processEth1DataReset 517.00 ns/op 298.00 ns/op 1.73
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.7120 ms/op 1.1020 ms/op 1.55
mainnet_e58758 - phase0 processSlashingsReset 4.3000 us/op 3.4050 us/op 1.26
mainnet_e58758 - phase0 processRandaoMixesReset 5.9890 us/op 4.0790 us/op 1.47
mainnet_e58758 - phase0 processHistoricalRootsUpdate 553.00 ns/op 322.00 ns/op 1.72
mainnet_e58758 - phase0 processParticipationRecordUpdates 5.3000 us/op 3.3270 us/op 1.59
mainnet_e58758 - phase0 afterProcessEpoch 78.340 ms/op 81.109 ms/op 0.97
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.0393 ms/op 1.1940 ms/op 0.87
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.8427 ms/op 1.9377 ms/op 0.95
altair processInactivityUpdates - 250000 normalcase 23.375 ms/op 16.743 ms/op 1.40
altair processInactivityUpdates - 250000 worstcase 22.864 ms/op 17.198 ms/op 1.33
phase0 processRegistryUpdates - 250000 normalcase 9.2360 us/op 6.2780 us/op 1.47
phase0 processRegistryUpdates - 250000 badcase_full_deposits 421.53 us/op 266.83 us/op 1.58
phase0 processRegistryUpdates - 250000 worstcase 0.5 131.37 ms/op 108.07 ms/op 1.22
altair processRewardsAndPenalties - 250000 normalcase 53.075 ms/op 39.414 ms/op 1.35
altair processRewardsAndPenalties - 250000 worstcase 50.223 ms/op 39.857 ms/op 1.26
phase0 getAttestationDeltas - 250000 normalcase 7.6029 ms/op 7.8360 ms/op 0.97
phase0 getAttestationDeltas - 250000 worstcase 8.2195 ms/op 8.4075 ms/op 0.98
phase0 processSlashings - 250000 worstcase 121.96 us/op 86.088 us/op 1.42
altair processSyncCommitteeUpdates - 250000 119.99 ms/op 131.54 ms/op 0.91
BeaconState.hashTreeRoot - No change 279.00 ns/op 297.00 ns/op 0.94
BeaconState.hashTreeRoot - 1 full validator 100.75 us/op 109.87 us/op 0.92
BeaconState.hashTreeRoot - 32 full validator 1.5226 ms/op 1.5896 ms/op 0.96
BeaconState.hashTreeRoot - 512 full validator 9.5761 ms/op 16.032 ms/op 0.60
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 116.16 us/op 179.13 us/op 0.65
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.6499 ms/op 2.4685 ms/op 0.67
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 20.626 ms/op 31.396 ms/op 0.66
BeaconState.hashTreeRoot - 1 balances 84.594 us/op 136.66 us/op 0.62
BeaconState.hashTreeRoot - 32 balances 756.68 us/op 1.3168 ms/op 0.57
BeaconState.hashTreeRoot - 512 balances 6.8604 ms/op 13.080 ms/op 0.52
BeaconState.hashTreeRoot - 250000 balances 143.63 ms/op 151.88 ms/op 0.95
aggregationBits - 2048 els - zipIndexesInBitList 25.784 us/op 24.241 us/op 1.06
byteArrayEquals 32 54.606 ns/op 55.260 ns/op 0.99
Buffer.compare 32 17.293 ns/op 18.077 ns/op 0.96
byteArrayEquals 1024 1.5999 us/op 1.6282 us/op 0.98
Buffer.compare 1024 23.991 ns/op 25.972 ns/op 0.92
byteArrayEquals 16384 24.568 us/op 25.900 us/op 0.95
Buffer.compare 16384 191.74 ns/op 207.25 ns/op 0.93
byteArrayEquals 123687377 186.86 ms/op 193.62 ms/op 0.97
Buffer.compare 123687377 6.0590 ms/op 6.7453 ms/op 0.90
byteArrayEquals 32 - diff last byte 50.660 ns/op 53.941 ns/op 0.94
Buffer.compare 32 - diff last byte 16.518 ns/op 19.294 ns/op 0.86
byteArrayEquals 1024 - diff last byte 1.5249 us/op 1.6209 us/op 0.94
Buffer.compare 1024 - diff last byte 24.986 ns/op 26.897 ns/op 0.93
byteArrayEquals 16384 - diff last byte 24.316 us/op 25.867 us/op 0.94
Buffer.compare 16384 - diff last byte 192.10 ns/op 211.58 ns/op 0.91
byteArrayEquals 123687377 - diff last byte 183.94 ms/op 197.79 ms/op 0.93
Buffer.compare 123687377 - diff last byte 6.1307 ms/op 7.2937 ms/op 0.84
byteArrayEquals 32 - random bytes 4.9610 ns/op 5.3810 ns/op 0.92
Buffer.compare 32 - random bytes 16.602 ns/op 18.134 ns/op 0.92
byteArrayEquals 1024 - random bytes 4.9560 ns/op 5.3410 ns/op 0.93
Buffer.compare 1024 - random bytes 16.558 ns/op 18.029 ns/op 0.92
byteArrayEquals 16384 - random bytes 4.9490 ns/op 6.0210 ns/op 0.82
Buffer.compare 16384 - random bytes 16.564 ns/op 18.444 ns/op 0.90
byteArrayEquals 123687377 - random bytes 6.1800 ns/op 6.6800 ns/op 0.93
Buffer.compare 123687377 - random bytes 17.770 ns/op 19.280 ns/op 0.92
regular array get 100000 times 31.829 us/op 34.339 us/op 0.93
wrappedArray get 100000 times 33.356 us/op 34.355 us/op 0.97
arrayWithProxy get 100000 times 12.950 ms/op 13.996 ms/op 0.93
ssz.Root.equals 44.373 ns/op 47.785 ns/op 0.93
byteArrayEquals 43.728 ns/op 47.261 ns/op 0.93
Buffer.compare 9.9990 ns/op 10.993 ns/op 0.91
shuffle list - 16384 els 6.2153 ms/op 6.5770 ms/op 0.95
shuffle list - 250000 els 92.524 ms/op 96.975 ms/op 0.95
processSlot - 1 slots 13.076 us/op 12.960 us/op 1.01
processSlot - 32 slots 3.2474 ms/op 2.5781 ms/op 1.26
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 39.867 ms/op 37.936 ms/op 1.05
getCommitteeAssignments - req 1 vs - 250000 vc 2.2474 ms/op 2.2530 ms/op 1.00
getCommitteeAssignments - req 100 vs - 250000 vc 4.2968 ms/op 4.3114 ms/op 1.00
getCommitteeAssignments - req 1000 vs - 250000 vc 4.5251 ms/op 4.5565 ms/op 0.99
findModifiedValidators - 10000 modified validators 234.78 ms/op 296.31 ms/op 0.79
findModifiedValidators - 1000 modified validators 165.87 ms/op 198.07 ms/op 0.84
findModifiedValidators - 100 modified validators 149.10 ms/op 205.41 ms/op 0.73
findModifiedValidators - 10 modified validators 139.25 ms/op 177.15 ms/op 0.79
findModifiedValidators - 1 modified validators 143.32 ms/op 192.24 ms/op 0.75
findModifiedValidators - no difference 152.83 ms/op 185.98 ms/op 0.82
compare ViewDUs 3.1111 s/op 3.5378 s/op 0.88
compare each validator Uint8Array 1.2839 s/op 1.7989 s/op 0.71
compare ViewDU to Uint8Array 1.0819 s/op 1.4467 s/op 0.75
migrate state 1000000 validators, 24 modified, 0 new 537.00 ms/op 867.18 ms/op 0.62
migrate state 1000000 validators, 1700 modified, 1000 new 851.81 ms/op 1.4228 s/op 0.60
migrate state 1000000 validators, 3400 modified, 2000 new 1.1313 s/op 1.5631 s/op 0.72
migrate state 1500000 validators, 24 modified, 0 new 693.40 ms/op 900.80 ms/op 0.77
migrate state 1500000 validators, 1700 modified, 1000 new 917.56 ms/op 1.2215 s/op 0.75
migrate state 1500000 validators, 3400 modified, 2000 new 1.0719 s/op 1.4596 s/op 0.73
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.7700 ns/op 5.0900 ns/op 0.94
state getBlockRootAtSlot - 250000 vs - 7PWei 690.14 ns/op 805.69 ns/op 0.86
computeProposers - vc 250000 8.8543 ms/op 10.615 ms/op 0.83
computeEpochShuffling - vc 250000 94.096 ms/op 109.70 ms/op 0.86
getNextSyncCommittee - vc 250000 146.11 ms/op 155.00 ms/op 0.94
computeSigningRoot for AttestationData 30.238 us/op 30.062 us/op 1.01
hash AttestationData serialized data then Buffer.toString(base64) 1.6249 us/op 1.9472 us/op 0.83
toHexString serialized data 950.54 ns/op 1.1414 us/op 0.83
Buffer.toString(base64) 214.50 ns/op 238.96 ns/op 0.90
block root to RootHex using toHex 169.73 ns/op 186.51 ns/op 0.91
block root to RootHex using toRootHex 101.24 ns/op 125.86 ns/op 0.80

by benchmarkbot/action

@twoeths twoeths marked this pull request as ready for review August 19, 2024 06:26
@twoeths twoeths requested a review from a team as a code owner August 19, 2024 06:26
@twoeths
Copy link
Contributor Author

twoeths commented Aug 26, 2024

latest update is to load balances + validators to cache, and transfer cache (dontTransferCache = false) when process block to save time

block reprocess time is around 120ms which is similar to processing a regular block. This is on feat4 mainnet node (with minimal nHistorical state config so that it has to reload state + reprocess blocks frequently)

Screenshot 2024-08-26 at 09 34 17

originally it is ~375ms as in #7002

@philknows philknows added this to the v1.22.0 milestone Sep 3, 2024
@twoeths twoeths merged commit 4e22884 into unstable Sep 4, 2024
20 checks passed
@twoeths twoeths deleted the te/improve_regen_state branch September 4, 2024 01:21
philknows pushed a commit that referenced this pull request Sep 11, 2024
* fix: improve regen state

* fix: check for null block returned from db

* feat: track state.hashTreeRoot() in regen.getState()

* fix: transfer cache when regen state

* fix: add caller as label to regenGetState metrics
@wemeetagain
Copy link
Member

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

Performance issue regen state
3 participants