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: regen to consume state cache reload api #6456

Merged
merged 2 commits into from Mar 4, 2024
Merged

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Feb 20, 2024

Motivation

Jan-29 19:30:06.015[rest]            error: Req req-7ml getStateV2 error - REGEN_ERROR_NO_SEED_STATE
Error: REGEN_ERROR_NO_SEED_STATE:
    at StateRegenerator.getState (file:///usr/app/packages/beacon-node/src/chain/regen/regen.ts:162:13)
    at StateRegenerator.getBlockSlotState (file:///usr/app/packages/beacon-node/src/chain/regen/regen.ts:122:38)
    at JobItemQueue.QueuedStateRegenerator.jobQueueProcessor [as itemProcessor] (file:///usr/app/packages/beacon-node/src/chain/regen/queued.ts:239:35)

Description

  • consume reload apis of checkpoint state cache
  • fix regen code. Since the regen logics relate to different modules, it's worth to only have e2e test for it which will come in the next PR
  • handle INVALID_STATE_ROOT error during regen and add logs
  • add metric to tell where epoch transition comes from

this is cherry-picked from #6359, it does not affect production code because we haven't configured new state caches yet, getOrReload* is just the same to get*

part of #5968

Copy link
Contributor

github-actions bot commented Feb 20, 2024

Performance Report

✔️ no performance regression detected

🚀🚀 Significant benchmark improvement detected

Benchmark suite Current: de041dd Previous: 6675739 Ratio
Buffer.compare 123687377 - diff last byte 3.7651 ms/op 12.230 ms/op 0.31
Full benchmark results
Benchmark suite Current: de041dd Previous: 6675739 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 730.30 us/op 757.16 us/op 0.96
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 110.21 us/op 179.45 us/op 0.61
BLS verify - blst-native 1.1313 ms/op 1.3862 ms/op 0.82
BLS verifyMultipleSignatures 3 - blst-native 2.4426 ms/op 2.9397 ms/op 0.83
BLS verifyMultipleSignatures 8 - blst-native 5.3780 ms/op 6.7566 ms/op 0.80
BLS verifyMultipleSignatures 32 - blst-native 19.777 ms/op 24.250 ms/op 0.82
BLS verifyMultipleSignatures 64 - blst-native 38.662 ms/op 49.201 ms/op 0.79
BLS verifyMultipleSignatures 128 - blst-native 77.068 ms/op 108.90 ms/op 0.71
BLS deserializing 10000 signatures 831.06 ms/op 991.14 ms/op 0.84
BLS deserializing 100000 signatures 8.3930 s/op 9.1570 s/op 0.92
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.1438 ms/op 1.4837 ms/op 0.77
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.3062 ms/op 1.5447 ms/op 0.85
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.0888 ms/op 2.4032 ms/op 0.87
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.8466 ms/op 3.5443 ms/op 1.09
BLS verifyMultipleSignatures - same message - 128 - blst-native 5.0090 ms/op 5.6694 ms/op 0.88
BLS aggregatePubkeys 32 - blst-native 22.474 us/op 26.180 us/op 0.86
BLS aggregatePubkeys 128 - blst-native 88.849 us/op 101.38 us/op 0.88
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 48.722 ms/op 63.669 ms/op 0.77
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 39.219 ms/op 55.744 ms/op 0.70
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 23.549 ms/op 46.464 ms/op 0.51
getSlashingsAndExits - default max 114.73 us/op 298.90 us/op 0.38
getSlashingsAndExits - 2k 418.58 us/op 586.30 us/op 0.71
proposeBlockBody type=full, size=empty 4.2561 ms/op 6.7576 ms/op 0.63
isKnown best case - 1 super set check 671.00 ns/op 603.00 ns/op 1.11
isKnown normal case - 2 super set checks 380.00 ns/op 660.00 ns/op 0.58
isKnown worse case - 16 super set checks 350.00 ns/op 636.00 ns/op 0.55
CheckpointStateCache - add get delete 5.0510 us/op 6.7500 us/op 0.75
validate api signedAggregateAndProof - struct 2.4821 ms/op 2.9278 ms/op 0.85
validate gossip signedAggregateAndProof - struct 2.3595 ms/op 2.9100 ms/op 0.81
validate gossip attestation - vc 640000 1.1349 ms/op 1.4562 ms/op 0.78
batch validate gossip attestation - vc 640000 - chunk 32 139.15 us/op 177.20 us/op 0.79
batch validate gossip attestation - vc 640000 - chunk 64 121.99 us/op 155.73 us/op 0.78
batch validate gossip attestation - vc 640000 - chunk 128 113.77 us/op 151.09 us/op 0.75
batch validate gossip attestation - vc 640000 - chunk 256 110.97 us/op 146.68 us/op 0.76
pickEth1Vote - no votes 847.02 us/op 1.2724 ms/op 0.67
pickEth1Vote - max votes 7.1003 ms/op 12.208 ms/op 0.58
pickEth1Vote - Eth1Data hashTreeRoot value x2048 11.661 ms/op 21.625 ms/op 0.54
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 16.506 ms/op 29.769 ms/op 0.55
pickEth1Vote - Eth1Data fastSerialize value x2048 425.72 us/op 692.41 us/op 0.61
pickEth1Vote - Eth1Data fastSerialize tree x2048 3.3669 ms/op 4.8067 ms/op 0.70
bytes32 toHexString 484.00 ns/op 600.00 ns/op 0.81
bytes32 Buffer.toString(hex) 321.00 ns/op 312.00 ns/op 1.03
bytes32 Buffer.toString(hex) from Uint8Array 453.00 ns/op 526.00 ns/op 0.86
bytes32 Buffer.toString(hex) + 0x 341.00 ns/op 323.00 ns/op 1.06
Object access 1 prop 0.21000 ns/op 0.18300 ns/op 1.15
Map access 1 prop 0.19300 ns/op 0.15200 ns/op 1.27
Object get x1000 5.5930 ns/op 7.1670 ns/op 0.78
Map get x1000 0.73900 ns/op 0.82000 ns/op 0.90
Object set x1000 25.258 ns/op 53.412 ns/op 0.47
Map set x1000 18.187 ns/op 44.014 ns/op 0.41
Return object 10000 times 0.23060 ns/op 0.24650 ns/op 0.94
Throw Error 10000 times 2.8412 us/op 3.9677 us/op 0.72
fastMsgIdFn sha256 / 200 bytes 2.0610 us/op 3.3440 us/op 0.62
fastMsgIdFn h32 xxhash / 200 bytes 306.00 ns/op 327.00 ns/op 0.94
fastMsgIdFn h64 xxhash / 200 bytes 362.00 ns/op 387.00 ns/op 0.94
fastMsgIdFn sha256 / 1000 bytes 6.3780 us/op 11.784 us/op 0.54
fastMsgIdFn h32 xxhash / 1000 bytes 421.00 ns/op 477.00 ns/op 0.88
fastMsgIdFn h64 xxhash / 1000 bytes 431.00 ns/op 455.00 ns/op 0.95
fastMsgIdFn sha256 / 10000 bytes 53.785 us/op 106.72 us/op 0.50
fastMsgIdFn h32 xxhash / 10000 bytes 1.8920 us/op 2.0700 us/op 0.91
fastMsgIdFn h64 xxhash / 10000 bytes 1.2600 us/op 1.4370 us/op 0.88
send data - 1000 256B messages 11.465 ms/op 20.379 ms/op 0.56
send data - 1000 512B messages 14.620 ms/op 28.337 ms/op 0.52
send data - 1000 1024B messages 26.952 ms/op 42.255 ms/op 0.64
send data - 1000 1200B messages 34.201 ms/op 42.679 ms/op 0.80
send data - 1000 2048B messages 43.178 ms/op 48.745 ms/op 0.89
send data - 1000 4096B messages 36.807 ms/op 46.813 ms/op 0.79
send data - 1000 16384B messages 99.591 ms/op 124.51 ms/op 0.80
send data - 1000 65536B messages 393.86 ms/op 525.41 ms/op 0.75
enrSubnets - fastDeserialize 64 bits 1.0130 us/op 1.5860 us/op 0.64
enrSubnets - ssz BitVector 64 bits 512.00 ns/op 551.00 ns/op 0.93
enrSubnets - fastDeserialize 4 bits 284.00 ns/op 237.00 ns/op 1.20
enrSubnets - ssz BitVector 4 bits 589.00 ns/op 553.00 ns/op 1.07
prioritizePeers score -10:0 att 32-0.1 sync 2-0 101.49 us/op 129.74 us/op 0.78
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 112.15 us/op 162.19 us/op 0.69
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 138.15 us/op 224.72 us/op 0.61
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 190.61 us/op 387.45 us/op 0.49
prioritizePeers score 0:0 att 64-1 sync 4-1 320.92 us/op 447.22 us/op 0.72
array of 16000 items push then shift 1.4031 us/op 2.2528 us/op 0.62
LinkedList of 16000 items push then shift 6.4150 ns/op 12.713 ns/op 0.50
array of 16000 items push then pop 122.41 ns/op 136.69 ns/op 0.90
LinkedList of 16000 items push then pop 6.0780 ns/op 10.771 ns/op 0.56
array of 24000 items push then shift 2.0157 us/op 2.8742 us/op 0.70
LinkedList of 24000 items push then shift 6.3480 ns/op 11.508 ns/op 0.55
array of 24000 items push then pop 169.24 ns/op 178.53 ns/op 0.95
LinkedList of 24000 items push then pop 5.8940 ns/op 10.945 ns/op 0.54
intersect bitArray bitLen 8 5.1840 ns/op 6.9010 ns/op 0.75
intersect array and set length 8 49.801 ns/op 96.072 ns/op 0.52
intersect bitArray bitLen 128 29.978 ns/op 39.030 ns/op 0.77
intersect array and set length 128 737.32 ns/op 1.3896 us/op 0.53
bitArray.getTrueBitIndexes() bitLen 128 1.5350 us/op 2.0620 us/op 0.74
bitArray.getTrueBitIndexes() bitLen 248 3.0230 us/op 3.5250 us/op 0.86
bitArray.getTrueBitIndexes() bitLen 512 5.4650 us/op 6.8790 us/op 0.79
Buffer.concat 32 items 898.00 ns/op 1.1210 us/op 0.80
Uint8Array.set 32 items 1.3310 us/op 2.4880 us/op 0.53
Set add up to 64 items then delete first 1.7500 us/op 5.0722 us/op 0.35
OrderedSet add up to 64 items then delete first 2.6708 us/op 6.8496 us/op 0.39
Set add up to 64 items then delete last 2.2211 us/op 5.7123 us/op 0.39
OrderedSet add up to 64 items then delete last 2.9592 us/op 7.2624 us/op 0.41
Set add up to 64 items then delete middle 1.9744 us/op 5.5551 us/op 0.36
OrderedSet add up to 64 items then delete middle 4.1857 us/op 8.6158 us/op 0.49
Set add up to 128 items then delete first 3.8467 us/op 11.505 us/op 0.33
OrderedSet add up to 128 items then delete first 6.0867 us/op 17.056 us/op 0.36
Set add up to 128 items then delete last 3.8370 us/op 11.262 us/op 0.34
OrderedSet add up to 128 items then delete last 8.2662 us/op 15.261 us/op 0.54
Set add up to 128 items then delete middle 5.1617 us/op 11.640 us/op 0.44
OrderedSet add up to 128 items then delete middle 13.348 us/op 20.842 us/op 0.64
Set add up to 256 items then delete first 10.523 us/op 23.063 us/op 0.46
OrderedSet add up to 256 items then delete first 16.781 us/op 32.618 us/op 0.51
Set add up to 256 items then delete last 9.8261 us/op 23.370 us/op 0.42
OrderedSet add up to 256 items then delete last 14.891 us/op 31.128 us/op 0.48
Set add up to 256 items then delete middle 9.3574 us/op 22.991 us/op 0.41
OrderedSet add up to 256 items then delete middle 34.638 us/op 54.892 us/op 0.63
transfer serialized Status (84 B) 1.6790 us/op 2.4260 us/op 0.69
copy serialized Status (84 B) 1.3230 us/op 1.6350 us/op 0.81
transfer serialized SignedVoluntaryExit (112 B) 1.7970 us/op 2.4040 us/op 0.75
copy serialized SignedVoluntaryExit (112 B) 1.4130 us/op 2.2470 us/op 0.63
transfer serialized ProposerSlashing (416 B) 2.8430 us/op 3.4510 us/op 0.82
copy serialized ProposerSlashing (416 B) 3.0970 us/op 3.1060 us/op 1.00
transfer serialized Attestation (485 B) 3.0170 us/op 3.0300 us/op 1.00
copy serialized Attestation (485 B) 1.7350 us/op 2.9720 us/op 0.58
transfer serialized AttesterSlashing (33232 B) 1.6430 us/op 3.4560 us/op 0.48
copy serialized AttesterSlashing (33232 B) 3.7570 us/op 17.676 us/op 0.21
transfer serialized Small SignedBeaconBlock (128000 B) 1.7320 us/op 4.8540 us/op 0.36
copy serialized Small SignedBeaconBlock (128000 B) 9.1430 us/op 39.581 us/op 0.23
transfer serialized Avg SignedBeaconBlock (200000 B) 1.8290 us/op 3.6840 us/op 0.50
copy serialized Avg SignedBeaconBlock (200000 B) 12.595 us/op 53.688 us/op 0.23
transfer serialized BlobsSidecar (524380 B) 2.2370 us/op 5.6470 us/op 0.40
copy serialized BlobsSidecar (524380 B) 75.661 us/op 260.68 us/op 0.29
transfer serialized Big SignedBeaconBlock (1000000 B) 2.6290 us/op 5.7450 us/op 0.46
copy serialized Big SignedBeaconBlock (1000000 B) 262.28 us/op 478.99 us/op 0.55
pass gossip attestations to forkchoice per slot 2.8701 ms/op 4.1934 ms/op 0.68
forkChoice updateHead vc 100000 bc 64 eq 0 468.77 us/op 725.78 us/op 0.65
forkChoice updateHead vc 600000 bc 64 eq 0 2.5910 ms/op 4.6407 ms/op 0.56
forkChoice updateHead vc 1000000 bc 64 eq 0 4.4480 ms/op 8.0277 ms/op 0.55
forkChoice updateHead vc 600000 bc 320 eq 0 2.6035 ms/op 4.7606 ms/op 0.55
forkChoice updateHead vc 600000 bc 1200 eq 0 2.8868 ms/op 4.7439 ms/op 0.61
forkChoice updateHead vc 600000 bc 7200 eq 0 3.7403 ms/op 5.6388 ms/op 0.66
forkChoice updateHead vc 600000 bc 64 eq 1000 10.399 ms/op 12.117 ms/op 0.86
forkChoice updateHead vc 600000 bc 64 eq 10000 10.037 ms/op 13.169 ms/op 0.76
forkChoice updateHead vc 600000 bc 64 eq 300000 11.919 ms/op 21.915 ms/op 0.54
computeDeltas 500000 validators 300 proto nodes 3.2137 ms/op 7.5134 ms/op 0.43
computeDeltas 500000 validators 1200 proto nodes 3.0780 ms/op 8.2616 ms/op 0.37
computeDeltas 500000 validators 7200 proto nodes 2.9734 ms/op 7.6798 ms/op 0.39
computeDeltas 750000 validators 300 proto nodes 4.5732 ms/op 11.062 ms/op 0.41
computeDeltas 750000 validators 1200 proto nodes 4.5009 ms/op 11.118 ms/op 0.40
computeDeltas 750000 validators 7200 proto nodes 4.5356 ms/op 10.422 ms/op 0.44
computeDeltas 1400000 validators 300 proto nodes 8.7985 ms/op 20.674 ms/op 0.43
computeDeltas 1400000 validators 1200 proto nodes 8.7826 ms/op 21.141 ms/op 0.42
computeDeltas 1400000 validators 7200 proto nodes 8.6336 ms/op 20.394 ms/op 0.42
computeDeltas 2100000 validators 300 proto nodes 13.335 ms/op 30.240 ms/op 0.44
computeDeltas 2100000 validators 1200 proto nodes 12.909 ms/op 30.540 ms/op 0.42
computeDeltas 2100000 validators 7200 proto nodes 13.765 ms/op 31.472 ms/op 0.44
altair processAttestation - 250000 vs - 7PWei normalcase 1.4132 ms/op 2.7128 ms/op 0.52
altair processAttestation - 250000 vs - 7PWei worstcase 2.7310 ms/op 4.9741 ms/op 0.55
altair processAttestation - setStatus - 1/6 committees join 81.702 us/op 212.32 us/op 0.38
altair processAttestation - setStatus - 1/3 committees join 145.72 us/op 388.84 us/op 0.37
altair processAttestation - setStatus - 1/2 committees join 206.50 us/op 495.79 us/op 0.42
altair processAttestation - setStatus - 2/3 committees join 281.54 us/op 609.41 us/op 0.46
altair processAttestation - setStatus - 4/5 committees join 394.16 us/op 856.35 us/op 0.46
altair processAttestation - setStatus - 100% committees join 489.45 us/op 1.0061 ms/op 0.49
altair processBlock - 250000 vs - 7PWei normalcase 8.2655 ms/op 12.006 ms/op 0.69
altair processBlock - 250000 vs - 7PWei normalcase hashState 30.501 ms/op 36.628 ms/op 0.83
altair processBlock - 250000 vs - 7PWei worstcase 34.997 ms/op 42.875 ms/op 0.82
altair processBlock - 250000 vs - 7PWei worstcase hashState 91.507 ms/op 94.588 ms/op 0.97
phase0 processBlock - 250000 vs - 7PWei normalcase 2.9078 ms/op 2.7122 ms/op 1.07
phase0 processBlock - 250000 vs - 7PWei worstcase 29.122 ms/op 33.574 ms/op 0.87
altair processEth1Data - 250000 vs - 7PWei normalcase 493.57 us/op 692.33 us/op 0.71
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 15.382 us/op 10.430 us/op 1.47
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 68.161 us/op 72.723 us/op 0.94
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 25.088 us/op 14.363 us/op 1.75
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 10.672 us/op 12.732 us/op 0.84
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 175.30 us/op 173.93 us/op 1.01
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.2242 ms/op 1.3561 ms/op 0.90
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.5818 ms/op 1.9619 ms/op 0.81
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.3594 ms/op 2.1028 ms/op 0.65
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 2.8894 ms/op 4.6146 ms/op 0.63
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.0839 ms/op 3.1841 ms/op 0.65
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 5.6839 ms/op 7.4284 ms/op 0.77
Tree 40 250000 create 291.39 ms/op 830.56 ms/op 0.35
Tree 40 250000 get(125000) 118.29 ns/op 230.55 ns/op 0.51
Tree 40 250000 set(125000) 828.25 ns/op 2.6068 us/op 0.32
Tree 40 250000 toArray() 19.229 ms/op 30.503 ms/op 0.63
Tree 40 250000 iterate all - toArray() + loop 16.595 ms/op 25.474 ms/op 0.65
Tree 40 250000 iterate all - get(i) 41.446 ms/op 79.700 ms/op 0.52
MutableVector 250000 create 9.6660 ms/op 18.615 ms/op 0.52
MutableVector 250000 get(125000) 5.6470 ns/op 7.0330 ns/op 0.80
MutableVector 250000 set(125000) 208.16 ns/op 714.90 ns/op 0.29
MutableVector 250000 toArray() 2.5541 ms/op 4.8762 ms/op 0.52
MutableVector 250000 iterate all - toArray() + loop 3.0574 ms/op 5.4138 ms/op 0.56
MutableVector 250000 iterate all - get(i) 1.3166 ms/op 1.6235 ms/op 0.81
Array 250000 create 2.4466 ms/op 4.3544 ms/op 0.56
Array 250000 clone - spread 1.0363 ms/op 2.2759 ms/op 0.46
Array 250000 get(125000) 0.99700 ns/op 2.5700 ns/op 0.39
Array 250000 set(125000) 1.1950 ns/op 6.2110 ns/op 0.19
Array 250000 iterate all - loop 147.68 us/op 189.85 us/op 0.78
effectiveBalanceIncrements clone Uint8Array 300000 20.203 us/op 74.795 us/op 0.27
effectiveBalanceIncrements clone MutableVector 300000 394.00 ns/op 644.00 ns/op 0.61
effectiveBalanceIncrements rw all Uint8Array 300000 178.16 us/op 219.92 us/op 0.81
effectiveBalanceIncrements rw all MutableVector 300000 65.137 ms/op 222.55 ms/op 0.29
phase0 afterProcessEpoch - 250000 vs - 7PWei 72.133 ms/op 144.81 ms/op 0.50
phase0 beforeProcessEpoch - 250000 vs - 7PWei 42.265 ms/op 54.077 ms/op 0.78
altair processEpoch - mainnet_e81889 429.96 ms/op 696.69 ms/op 0.62
mainnet_e81889 - altair beforeProcessEpoch 66.238 ms/op 131.01 ms/op 0.51
mainnet_e81889 - altair processJustificationAndFinalization 5.6090 us/op 33.596 us/op 0.17
mainnet_e81889 - altair processInactivityUpdates 3.7886 ms/op 10.091 ms/op 0.38
mainnet_e81889 - altair processRewardsAndPenalties 63.519 ms/op 84.959 ms/op 0.75
mainnet_e81889 - altair processRegistryUpdates 1.8270 us/op 6.5360 us/op 0.28
mainnet_e81889 - altair processSlashings 565.00 ns/op 951.00 ns/op 0.59
mainnet_e81889 - altair processEth1DataReset 556.00 ns/op 1.1840 us/op 0.47
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.7527 ms/op 2.1945 ms/op 0.80
mainnet_e81889 - altair processSlashingsReset 2.1770 us/op 8.2410 us/op 0.26
mainnet_e81889 - altair processRandaoMixesReset 2.5730 us/op 12.617 us/op 0.20
mainnet_e81889 - altair processHistoricalRootsUpdate 624.00 ns/op 1.1910 us/op 0.52
mainnet_e81889 - altair processParticipationFlagUpdates 1.0990 us/op 3.2360 us/op 0.34
mainnet_e81889 - altair processSyncCommitteeUpdates 559.00 ns/op 864.00 ns/op 0.65
mainnet_e81889 - altair afterProcessEpoch 75.055 ms/op 133.21 ms/op 0.56
capella processEpoch - mainnet_e217614 1.7496 s/op 3.4680 s/op 0.50
mainnet_e217614 - capella beforeProcessEpoch 435.92 ms/op 576.65 ms/op 0.76
mainnet_e217614 - capella processJustificationAndFinalization 7.6490 us/op 21.192 us/op 0.36
mainnet_e217614 - capella processInactivityUpdates 17.908 ms/op 24.678 ms/op 0.73
mainnet_e217614 - capella processRewardsAndPenalties 382.66 ms/op 532.83 ms/op 0.72
mainnet_e217614 - capella processRegistryUpdates 27.631 us/op 38.779 us/op 0.71
mainnet_e217614 - capella processSlashings 608.00 ns/op 956.00 ns/op 0.64
mainnet_e217614 - capella processEth1DataReset 654.00 ns/op 754.00 ns/op 0.87
mainnet_e217614 - capella processEffectiveBalanceUpdates 11.458 ms/op 5.9759 ms/op 1.92
mainnet_e217614 - capella processSlashingsReset 2.3590 us/op 5.2140 us/op 0.45
mainnet_e217614 - capella processRandaoMixesReset 3.2680 us/op 8.4150 us/op 0.39
mainnet_e217614 - capella processHistoricalRootsUpdate 540.00 ns/op 1.1180 us/op 0.48
mainnet_e217614 - capella processParticipationFlagUpdates 1.1820 us/op 4.6680 us/op 0.25
mainnet_e217614 - capella afterProcessEpoch 209.64 ms/op 331.76 ms/op 0.63
phase0 processEpoch - mainnet_e58758 391.01 ms/op 488.76 ms/op 0.80
mainnet_e58758 - phase0 beforeProcessEpoch 117.77 ms/op 162.76 ms/op 0.72
mainnet_e58758 - phase0 processJustificationAndFinalization 12.856 us/op 22.349 us/op 0.58
mainnet_e58758 - phase0 processRewardsAndPenalties 52.406 ms/op 66.732 ms/op 0.79
mainnet_e58758 - phase0 processRegistryUpdates 4.2030 us/op 22.821 us/op 0.18
mainnet_e58758 - phase0 processSlashings 353.00 ns/op 831.00 ns/op 0.42
mainnet_e58758 - phase0 processEth1DataReset 312.00 ns/op 1.0260 us/op 0.30
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 869.80 us/op 1.9292 ms/op 0.45
mainnet_e58758 - phase0 processSlashingsReset 2.8110 us/op 6.9510 us/op 0.40
mainnet_e58758 - phase0 processRandaoMixesReset 2.3800 us/op 9.9830 us/op 0.24
mainnet_e58758 - phase0 processHistoricalRootsUpdate 555.00 ns/op 1.0800 us/op 0.51
mainnet_e58758 - phase0 processParticipationRecordUpdates 3.6810 us/op 9.7010 us/op 0.38
mainnet_e58758 - phase0 afterProcessEpoch 65.557 ms/op 114.43 ms/op 0.57
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.0273 ms/op 2.3909 ms/op 0.43
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.8624 ms/op 2.7490 ms/op 0.68
altair processInactivityUpdates - 250000 normalcase 25.758 ms/op 41.049 ms/op 0.63
altair processInactivityUpdates - 250000 worstcase 25.072 ms/op 42.925 ms/op 0.58
phase0 processRegistryUpdates - 250000 normalcase 8.1640 us/op 25.903 us/op 0.32
phase0 processRegistryUpdates - 250000 badcase_full_deposits 457.68 us/op 689.67 us/op 0.66
phase0 processRegistryUpdates - 250000 worstcase 0.5 104.36 ms/op 228.58 ms/op 0.46
altair processRewardsAndPenalties - 250000 normalcase 59.815 ms/op 68.078 ms/op 0.88
altair processRewardsAndPenalties - 250000 worstcase 58.237 ms/op 77.278 ms/op 0.75
phase0 getAttestationDeltas - 250000 normalcase 5.8517 ms/op 13.321 ms/op 0.44
phase0 getAttestationDeltas - 250000 worstcase 5.7946 ms/op 13.035 ms/op 0.44
phase0 processSlashings - 250000 worstcase 81.287 us/op 140.96 us/op 0.58
altair processSyncCommitteeUpdates - 250000 103.91 ms/op 181.79 ms/op 0.57
BeaconState.hashTreeRoot - No change 408.00 ns/op 832.00 ns/op 0.49
BeaconState.hashTreeRoot - 1 full validator 123.22 us/op 170.18 us/op 0.72
BeaconState.hashTreeRoot - 32 full validator 1.3782 ms/op 1.9683 ms/op 0.70
BeaconState.hashTreeRoot - 512 full validator 13.674 ms/op 20.288 ms/op 0.67
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 160.67 us/op 194.69 us/op 0.83
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.7321 ms/op 2.7560 ms/op 0.63
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 23.405 ms/op 39.202 ms/op 0.60
BeaconState.hashTreeRoot - 1 balances 83.287 us/op 181.48 us/op 0.46
BeaconState.hashTreeRoot - 32 balances 1.1561 ms/op 1.8353 ms/op 0.63
BeaconState.hashTreeRoot - 512 balances 12.189 ms/op 17.283 ms/op 0.71
BeaconState.hashTreeRoot - 250000 balances 191.83 ms/op 268.58 ms/op 0.71
aggregationBits - 2048 els - zipIndexesInBitList 12.180 us/op 28.436 us/op 0.43
byteArrayEquals 32 61.124 ns/op 80.230 ns/op 0.76
Buffer.compare 32 34.817 ns/op 59.680 ns/op 0.58
byteArrayEquals 1024 1.6584 us/op 2.4619 us/op 0.67
Buffer.compare 1024 43.378 ns/op 76.744 ns/op 0.57
byteArrayEquals 16384 25.871 us/op 40.569 us/op 0.64
Buffer.compare 16384 194.83 ns/op 294.93 ns/op 0.66
byteArrayEquals 123687377 196.33 ms/op 264.93 ms/op 0.74
Buffer.compare 123687377 5.2723 ms/op 9.8345 ms/op 0.54
byteArrayEquals 32 - diff last byte 59.170 ns/op 83.283 ns/op 0.71
Buffer.compare 32 - diff last byte 34.640 ns/op 60.758 ns/op 0.57
byteArrayEquals 1024 - diff last byte 1.6304 us/op 2.1176 us/op 0.77
Buffer.compare 1024 - diff last byte 47.758 ns/op 76.146 ns/op 0.63
byteArrayEquals 16384 - diff last byte 28.173 us/op 34.723 us/op 0.81
Buffer.compare 16384 - diff last byte 206.11 ns/op 292.00 ns/op 0.71
byteArrayEquals 123687377 - diff last byte 202.11 ms/op 279.17 ms/op 0.72
Buffer.compare 123687377 - diff last byte 3.7651 ms/op 12.230 ms/op 0.31
byteArrayEquals 32 - random bytes 4.4270 ns/op 7.0680 ns/op 0.63
Buffer.compare 32 - random bytes 38.969 ns/op 68.712 ns/op 0.57
byteArrayEquals 1024 - random bytes 4.3750 ns/op 6.9350 ns/op 0.63
Buffer.compare 1024 - random bytes 37.505 ns/op 67.521 ns/op 0.56
byteArrayEquals 16384 - random bytes 4.3940 ns/op 7.2940 ns/op 0.60
Buffer.compare 16384 - random bytes 37.512 ns/op 65.389 ns/op 0.57
byteArrayEquals 123687377 - random bytes 7.7700 ns/op 10.460 ns/op 0.74
Buffer.compare 123687377 - random bytes 41.360 ns/op 83.810 ns/op 0.49
regular array get 100000 times 40.625 us/op 48.780 us/op 0.83
wrappedArray get 100000 times 40.582 us/op 48.566 us/op 0.84
arrayWithProxy get 100000 times 9.7890 ms/op 14.897 ms/op 0.66
ssz.Root.equals 54.398 ns/op 56.826 ns/op 0.96
byteArrayEquals 53.188 ns/op 56.422 ns/op 0.94
Buffer.compare 9.4020 ns/op 12.636 ns/op 0.74
shuffle list - 16384 els 4.6009 ms/op 7.4680 ms/op 0.62
shuffle list - 250000 els 66.369 ms/op 111.49 ms/op 0.60
processSlot - 1 slots 10.804 us/op 19.537 us/op 0.55
processSlot - 32 slots 2.4092 ms/op 4.3820 ms/op 0.55
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 49.806 ms/op 64.649 ms/op 0.77
getCommitteeAssignments - req 1 vs - 250000 vc 2.3028 ms/op 2.7683 ms/op 0.83
getCommitteeAssignments - req 100 vs - 250000 vc 3.4398 ms/op 3.8945 ms/op 0.88
getCommitteeAssignments - req 1000 vs - 250000 vc 3.7707 ms/op 4.3041 ms/op 0.88
findModifiedValidators - 10000 modified validators 369.85 ms/op 572.33 ms/op 0.65
findModifiedValidators - 1000 modified validators 347.10 ms/op 478.97 ms/op 0.72
findModifiedValidators - 100 modified validators 381.50 ms/op 545.89 ms/op 0.70
findModifiedValidators - 10 modified validators 325.78 ms/op 513.32 ms/op 0.63
findModifiedValidators - 1 modified validators 339.10 ms/op 491.18 ms/op 0.69
findModifiedValidators - no difference 351.05 ms/op 491.96 ms/op 0.71
compare ViewDUs 4.8935 s/op 5.1229 s/op 0.96
compare each validator Uint8Array 2.1218 s/op 2.0263 s/op 1.05
compare ViewDU to Uint8Array 983.95 ms/op 1.5932 s/op 0.62
migrate state 1000000 validators, 24 modified, 0 new 816.31 ms/op 1.0353 s/op 0.79
migrate state 1000000 validators, 1700 modified, 1000 new 1.5061 s/op 1.3377 s/op 1.13
migrate state 1000000 validators, 3400 modified, 2000 new 1.9359 s/op 1.6171 s/op 1.20
migrate state 1500000 validators, 24 modified, 0 new 832.37 ms/op 1.0201 s/op 0.82
migrate state 1500000 validators, 1700 modified, 1000 new 993.92 ms/op 1.2659 s/op 0.79
migrate state 1500000 validators, 3400 modified, 2000 new 1.1468 s/op 1.6838 s/op 0.68
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.3400 ns/op 4.9600 ns/op 0.88
state getBlockRootAtSlot - 250000 vs - 7PWei 959.58 ns/op 963.42 ns/op 1.00
computeProposers - vc 250000 6.7271 ms/op 11.647 ms/op 0.58
computeEpochShuffling - vc 250000 66.718 ms/op 112.52 ms/op 0.59
getNextSyncCommittee - vc 250000 105.12 ms/op 185.56 ms/op 0.57
computeSigningRoot for AttestationData 24.999 us/op 32.016 us/op 0.78
hash AttestationData serialized data then Buffer.toString(base64) 1.1943 us/op 2.4480 us/op 0.49
toHexString serialized data 768.10 ns/op 1.4097 us/op 0.54
Buffer.toString(base64) 165.81 ns/op 258.19 ns/op 0.64

by benchmarkbot/action

@twoeths twoeths marked this pull request as ready for review February 20, 2024 07:35
@twoeths twoeths requested a review from a team as a code owner February 20, 2024 07:35
}

/**
* Get state after block `blockRoot` dialed forward to `slot`
* - shouldReload should be used with care, as it will cause the state to be reloaded from disk
Copy link
Contributor

Choose a reason for hiding this comment

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

Do you think it is better to rename shouldReload to shouldReloadFromDisk to emphasize and warn about the consequence of setting this flag to true?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm open to change, cc @wemeetagain for your preference

Copy link
Member

Choose a reason for hiding this comment

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

I think that is a good suggestion. shouldReloadFromDisk is more descriptive and expressive

Copy link
Contributor

Choose a reason for hiding this comment

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

or allowDiskReload?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes allowDiskReload really matches the usage of this flag 👍

packages/beacon-node/src/chain/regen/regen.ts Outdated Show resolved Hide resolved
packages/beacon-node/src/chain/regen/regen.ts Show resolved Hide resolved
packages/beacon-node/src/chain/regen/regen.ts Show resolved Hide resolved
@@ -77,20 +84,23 @@ export class StateRegenerator implements IStateRegeneratorInternal {
async getCheckpointState(
cp: phase0.Checkpoint,
opts: StateCloneOpts,
rCaller: RegenCaller
rCaller: RegenCaller,
shouldReload = false
Copy link
Contributor

Choose a reason for hiding this comment

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

should this flag move in StateCloneOpts?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

shouldReload is designed to use within this file only, I don't want to publish shouldReload flag to all consumers, it should only be true when we get state for block processing, or updateHeadState. It's easier to control it within this file

*/
async getBlockSlotState(
blockRoot: RootHex,
slot: Slot,
opts: StateCloneOpts,
rCaller: RegenCaller
rCaller: RegenCaller,
shouldReload = false
Copy link
Contributor

Choose a reason for hiding this comment

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

may be can move in StateCloneOpts here as well?

}

/**
* Get state after block `blockRoot` dialed forward to `slot`
* - shouldReload should be used with care, as it will cause the state to be reloaded from disk
Copy link
Member

Choose a reason for hiding this comment

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

I think that is a good suggestion. shouldReloadFromDisk is more descriptive and expressive

packages/beacon-node/src/chain/regen/regen.ts Outdated Show resolved Hide resolved
packages/beacon-node/src/chain/regen/regen.ts Outdated Show resolved Hide resolved
packages/beacon-node/src/chain/regen/regen.ts Outdated Show resolved Hide resolved
const checkpointState = postState;
const cp = getCheckpointFromState(checkpointState);
checkpointStateCache.add(cp, checkpointState);
emitter.emit(ChainEvent.checkpoint, cp, checkpointState);
emitter.emit(ChainEvent.checkpoint, cp, checkpointState.clone());
Copy link
Member

Choose a reason for hiding this comment

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

Why add the costly clone() here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

in fact I will add more clone() when returning an item from cache to avoid this mistake, see #6178 (comment)

Copy link

codecov bot commented Feb 29, 2024

Codecov Report

Merging #6456 (4ea5461) into unstable (efb684a) will increase coverage by 0.05%.
Report is 27 commits behind head on unstable.
The diff coverage is 19.73%.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #6456      +/-   ##
============================================
+ Coverage     61.63%   61.69%   +0.05%     
============================================
  Files           553      555       +2     
  Lines         57975    58253     +278     
  Branches       1832     1844      +12     
============================================
+ Hits          35733    35937     +204     
- Misses        22205    22277      +72     
- Partials         37       39       +2     

Copy link
Contributor

@g11tech g11tech left a comment

Choose a reason for hiding this comment

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

seems to have addressed all concerns lgtm

@twoeths twoeths merged commit d10ed38 into unstable Mar 4, 2024
19 of 20 checks passed
@twoeths twoeths deleted the tuyen/regen branch March 4, 2024 01:21
@wemeetagain
Copy link
Member

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

None yet

5 participants