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 headState does not exist #4944

Merged
merged 1 commit into from
Dec 24, 2022
Merged

Fix headState does not exist #4944

merged 1 commit into from
Dec 24, 2022

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Dec 24, 2022

Motivation

We have head state strong reference but it does not work if head state is not in the cache

Description

  • In StateContextCache.get check/get from head state strong ref first before the cache

Closes #4700

@twoeths twoeths requested a review from a team as a code owner December 24, 2022 08:13
@github-actions
Copy link
Contributor

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: ac2ce56 Previous: 6a37cca Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 989.79 us/op 1.1646 ms/op 0.85
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 60.636 us/op 69.167 us/op 0.88
BLS verify - blst-native 2.1719 ms/op 1.8654 ms/op 1.16
BLS verifyMultipleSignatures 3 - blst-native 4.4873 ms/op 3.8101 ms/op 1.18
BLS verifyMultipleSignatures 8 - blst-native 9.6954 ms/op 8.1963 ms/op 1.18
BLS verifyMultipleSignatures 32 - blst-native 35.219 ms/op 29.791 ms/op 1.18
BLS aggregatePubkeys 32 - blst-native 46.624 us/op 40.441 us/op 1.15
BLS aggregatePubkeys 128 - blst-native 182.42 us/op 158.75 us/op 1.15
getAttestationsForBlock 77.230 ms/op 87.424 ms/op 0.88
isKnown best case - 1 super set check 451.00 ns/op 420.00 ns/op 1.07
isKnown normal case - 2 super set checks 444.00 ns/op 407.00 ns/op 1.09
isKnown worse case - 16 super set checks 444.00 ns/op 408.00 ns/op 1.09
CheckpointStateCache - add get delete 8.6740 us/op 8.4910 us/op 1.02
validate gossip signedAggregateAndProof - struct 5.0202 ms/op 4.2682 ms/op 1.18
validate gossip attestation - struct 2.3635 ms/op 2.0262 ms/op 1.17
pickEth1Vote - no votes 2.1309 ms/op 2.1119 ms/op 1.01
pickEth1Vote - max votes 15.422 ms/op 16.138 ms/op 0.96
pickEth1Vote - Eth1Data hashTreeRoot value x2048 12.961 ms/op 11.789 ms/op 1.10
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 20.634 ms/op 20.113 ms/op 1.03
pickEth1Vote - Eth1Data fastSerialize value x2048 1.0669 ms/op 1.1891 ms/op 0.90
pickEth1Vote - Eth1Data fastSerialize tree x2048 9.4888 ms/op 9.2393 ms/op 1.03
bytes32 toHexString 852.00 ns/op 1.0010 us/op 0.85
bytes32 Buffer.toString(hex) 655.00 ns/op 574.00 ns/op 1.14
bytes32 Buffer.toString(hex) from Uint8Array 1.0230 us/op 860.00 ns/op 1.19
bytes32 Buffer.toString(hex) + 0x 661.00 ns/op 634.00 ns/op 1.04
Object access 1 prop 0.28300 ns/op 0.27900 ns/op 1.01
Map access 1 prop 0.26600 ns/op 0.25500 ns/op 1.04
Object get x1000 10.807 ns/op 16.253 ns/op 0.66
Map get x1000 0.92700 ns/op 0.99700 ns/op 0.93
Object set x1000 68.384 ns/op 108.48 ns/op 0.63
Map set x1000 41.595 ns/op 67.941 ns/op 0.61
Return object 10000 times 0.43650 ns/op 0.37350 ns/op 1.17
Throw Error 10000 times 6.5901 us/op 6.7617 us/op 0.97
fastMsgIdFn sha256 / 200 bytes 5.1430 us/op 4.3140 us/op 1.19
fastMsgIdFn h32 xxhash / 200 bytes 462.00 ns/op 460.00 ns/op 1.00
fastMsgIdFn h64 xxhash / 200 bytes 625.00 ns/op 638.00 ns/op 0.98
fastMsgIdFn sha256 / 1000 bytes 15.717 us/op 13.540 us/op 1.16
fastMsgIdFn h32 xxhash / 1000 bytes 637.00 ns/op 612.00 ns/op 1.04
fastMsgIdFn h64 xxhash / 1000 bytes 738.00 ns/op 728.00 ns/op 1.01
fastMsgIdFn sha256 / 10000 bytes 136.32 us/op 116.77 us/op 1.17
fastMsgIdFn h32 xxhash / 10000 bytes 2.5650 us/op 2.3310 us/op 1.10
fastMsgIdFn h64 xxhash / 10000 bytes 1.7820 us/op 1.6650 us/op 1.07
enrSubnets - fastDeserialize 64 bits 2.1380 us/op 2.2820 us/op 0.94
enrSubnets - ssz BitVector 64 bits 853.00 ns/op 803.00 ns/op 1.06
enrSubnets - fastDeserialize 4 bits 285.00 ns/op 286.00 ns/op 1.00
enrSubnets - ssz BitVector 4 bits 869.00 ns/op 815.00 ns/op 1.07
prioritizePeers score -10:0 att 32-0.1 sync 2-0 77.980 us/op 95.213 us/op 0.82
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 112.95 us/op 134.50 us/op 0.84
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 197.23 us/op 260.64 us/op 0.76
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 319.51 us/op 400.83 us/op 0.80
prioritizePeers score 0:0 att 64-1 sync 4-1 397.00 us/op 511.91 us/op 0.78
array of 16000 items push then shift 51.610 us/op 2.7895 us/op 18.50
LinkedList of 16000 items push then shift 12.226 ns/op 17.229 ns/op 0.71
array of 16000 items push then pop 190.97 ns/op 207.68 ns/op 0.92
LinkedList of 16000 items push then pop 11.968 ns/op 16.504 ns/op 0.73
array of 24000 items push then shift 77.386 us/op 3.9893 us/op 19.40
LinkedList of 24000 items push then shift 12.416 ns/op 20.373 ns/op 0.61
array of 24000 items push then pop 193.94 ns/op 209.43 ns/op 0.93
LinkedList of 24000 items push then pop 12.007 ns/op 17.958 ns/op 0.67
intersect bitArray bitLen 8 21.718 ns/op 29.601 ns/op 0.73
intersect array and set length 8 124.09 ns/op 167.59 ns/op 0.74
intersect bitArray bitLen 128 70.490 ns/op 118.98 ns/op 0.59
intersect array and set length 128 1.6459 us/op 2.2687 us/op 0.73
Buffer.concat 32 items 5.1910 us/op 5.1480 us/op 1.01
Uint8Array.set 32 items 3.5940 us/op 4.1170 us/op 0.87
pass gossip attestations to forkchoice per slot 3.7679 ms/op 4.3031 ms/op 0.88
computeDeltas 4.2544 ms/op 6.0377 ms/op 0.70
computeProposerBoostScoreFromBalances 2.4910 ms/op 2.8370 ms/op 0.88
altair processAttestation - 250000 vs - 7PWei normalcase 3.4353 ms/op 3.8108 ms/op 0.90
altair processAttestation - 250000 vs - 7PWei worstcase 6.3971 ms/op 6.4499 ms/op 0.99
altair processAttestation - setStatus - 1/6 committees join 181.14 us/op 207.91 us/op 0.87
altair processAttestation - setStatus - 1/3 committees join 358.12 us/op 398.87 us/op 0.90
altair processAttestation - setStatus - 1/2 committees join 526.07 us/op 563.57 us/op 0.93
altair processAttestation - setStatus - 2/3 committees join 686.35 us/op 719.85 us/op 0.95
altair processAttestation - setStatus - 4/5 committees join 946.69 us/op 1.0003 ms/op 0.95
altair processAttestation - setStatus - 100% committees join 1.1332 ms/op 1.1898 ms/op 0.95
altair processBlock - 250000 vs - 7PWei normalcase 22.940 ms/op 26.855 ms/op 0.85
altair processBlock - 250000 vs - 7PWei normalcase hashState 38.761 ms/op 33.554 ms/op 1.16
altair processBlock - 250000 vs - 7PWei worstcase 78.107 ms/op 77.794 ms/op 1.00
altair processBlock - 250000 vs - 7PWei worstcase hashState 101.31 ms/op 109.74 ms/op 0.92
phase0 processBlock - 250000 vs - 7PWei normalcase 3.0870 ms/op 3.4955 ms/op 0.88
phase0 processBlock - 250000 vs - 7PWei worstcase 51.142 ms/op 46.085 ms/op 1.11
altair processEth1Data - 250000 vs - 7PWei normalcase 610.55 us/op 761.30 us/op 0.80
vc - 250000 eb 1 eth1 1 we 0 wn 0 - smpl 15 8.7570 us/op 10.045 us/op 0.87
vc - 250000 eb 0.95 eth1 0.1 we 0.05 wn 0 - smpl 219 24.249 us/op 36.925 us/op 0.66
vc - 250000 eb 0.95 eth1 0.3 we 0.05 wn 0 - smpl 42 12.063 us/op 12.216 us/op 0.99
vc - 250000 eb 0.95 eth1 0.7 we 0.05 wn 0 - smpl 18 8.9850 us/op 11.692 us/op 0.77
vc - 250000 eb 0.1 eth1 0.1 we 0 wn 0 - smpl 1020 90.099 us/op 111.66 us/op 0.81
vc - 250000 eb 0.03 eth1 0.03 we 0 wn 0 - smpl 11777 868.93 us/op 1.0119 ms/op 0.86
vc - 250000 eb 0.01 eth1 0.01 we 0 wn 0 - smpl 16384 1.1596 ms/op 1.3997 ms/op 0.83
vc - 250000 eb 0 eth1 0 we 0 wn 0 - smpl 16384 1.1191 ms/op 1.3269 ms/op 0.84
vc - 250000 eb 0 eth1 0 we 0 wn 0 nocache - smpl 16384 4.0034 ms/op 4.3616 ms/op 0.92
vc - 250000 eb 0 eth1 1 we 0 wn 0 - smpl 16384 2.6993 ms/op 2.9525 ms/op 0.91
vc - 250000 eb 0 eth1 1 we 0 wn 0 nocache - smpl 16384 6.9761 ms/op 7.1564 ms/op 0.97
Tree 40 250000 create 580.64 ms/op 706.12 ms/op 0.82
Tree 40 250000 get(125000) 227.13 ns/op 297.80 ns/op 0.76
Tree 40 250000 set(125000) 1.8888 us/op 2.2193 us/op 0.85
Tree 40 250000 toArray() 26.046 ms/op 31.459 ms/op 0.83
Tree 40 250000 iterate all - toArray() + loop 26.374 ms/op 31.462 ms/op 0.84
Tree 40 250000 iterate all - get(i) 112.86 ms/op 107.04 ms/op 1.05
MutableVector 250000 create 13.315 ms/op 15.497 ms/op 0.86
MutableVector 250000 get(125000) 10.553 ns/op 13.132 ns/op 0.80
MutableVector 250000 set(125000) 493.17 ns/op 620.00 ns/op 0.80
MutableVector 250000 toArray() 5.9211 ms/op 7.1862 ms/op 0.82
MutableVector 250000 iterate all - toArray() + loop 6.0798 ms/op 6.3622 ms/op 0.96
MutableVector 250000 iterate all - get(i) 3.5649 ms/op 3.9031 ms/op 0.91
Array 250000 create 6.2867 ms/op 5.9461 ms/op 1.06
Array 250000 clone - spread 1.9286 ms/op 2.1140 ms/op 0.91
Array 250000 get(125000) 0.92200 ns/op 0.91600 ns/op 1.01
Array 250000 set(125000) 0.94800 ns/op 0.92500 ns/op 1.02
Array 250000 iterate all - loop 150.88 us/op 167.75 us/op 0.90
effectiveBalanceIncrements clone Uint8Array 300000 33.196 us/op 70.063 us/op 0.47
effectiveBalanceIncrements clone MutableVector 300000 541.00 ns/op 567.00 ns/op 0.95
effectiveBalanceIncrements rw all Uint8Array 300000 243.88 us/op 252.71 us/op 0.97
effectiveBalanceIncrements rw all MutableVector 300000 135.12 ms/op 163.39 ms/op 0.83
phase0 afterProcessEpoch - 250000 vs - 7PWei 187.22 ms/op 186.11 ms/op 1.01
phase0 beforeProcessEpoch - 250000 vs - 7PWei 57.998 ms/op 71.258 ms/op 0.81
altair processEpoch - mainnet_e81889 484.09 ms/op 492.22 ms/op 0.98
mainnet_e81889 - altair beforeProcessEpoch 116.90 ms/op 133.78 ms/op 0.87
mainnet_e81889 - altair processJustificationAndFinalization 21.333 us/op 27.789 us/op 0.77
mainnet_e81889 - altair processInactivityUpdates 8.4111 ms/op 10.315 ms/op 0.82
mainnet_e81889 - altair processRewardsAndPenalties 77.111 ms/op 88.873 ms/op 0.87
mainnet_e81889 - altair processRegistryUpdates 3.0480 us/op 3.2510 us/op 0.94
mainnet_e81889 - altair processSlashings 877.00 ns/op 774.00 ns/op 1.13
mainnet_e81889 - altair processEth1DataReset 810.00 ns/op 823.00 ns/op 0.98
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.9777 ms/op 2.3331 ms/op 0.85
mainnet_e81889 - altair processSlashingsReset 5.0980 us/op 4.6940 us/op 1.09
mainnet_e81889 - altair processRandaoMixesReset 6.1940 us/op 6.0680 us/op 1.02
mainnet_e81889 - altair processHistoricalRootsUpdate 888.00 ns/op 871.00 ns/op 1.02
mainnet_e81889 - altair processParticipationFlagUpdates 2.8550 us/op 3.4290 us/op 0.83
mainnet_e81889 - altair processSyncCommitteeUpdates 782.00 ns/op 921.00 ns/op 0.85
mainnet_e81889 - altair afterProcessEpoch 196.94 ms/op 195.23 ms/op 1.01
phase0 processEpoch - mainnet_e58758 480.34 ms/op 525.36 ms/op 0.91
mainnet_e58758 - phase0 beforeProcessEpoch 175.31 ms/op 224.12 ms/op 0.78
mainnet_e58758 - phase0 processJustificationAndFinalization 22.647 us/op 21.713 us/op 1.04
mainnet_e58758 - phase0 processRewardsAndPenalties 97.591 ms/op 121.30 ms/op 0.80
mainnet_e58758 - phase0 processRegistryUpdates 9.5410 us/op 13.480 us/op 0.71
mainnet_e58758 - phase0 processSlashings 742.00 ns/op 1.0420 us/op 0.71
mainnet_e58758 - phase0 processEth1DataReset 786.00 ns/op 980.00 ns/op 0.80
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.7983 ms/op 1.9373 ms/op 0.93
mainnet_e58758 - phase0 processSlashingsReset 4.4070 us/op 6.1540 us/op 0.72
mainnet_e58758 - phase0 processRandaoMixesReset 5.9870 us/op 5.8890 us/op 1.02
mainnet_e58758 - phase0 processHistoricalRootsUpdate 875.00 ns/op 868.00 ns/op 1.01
mainnet_e58758 - phase0 processParticipationRecordUpdates 5.4970 us/op 4.1270 us/op 1.33
mainnet_e58758 - phase0 afterProcessEpoch 162.50 ms/op 160.62 ms/op 1.01
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.9404 ms/op 2.8891 ms/op 0.67
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 2.3431 ms/op 3.3012 ms/op 0.71
altair processInactivityUpdates - 250000 normalcase 39.756 ms/op 39.111 ms/op 1.02
altair processInactivityUpdates - 250000 worstcase 33.360 ms/op 38.489 ms/op 0.87
phase0 processRegistryUpdates - 250000 normalcase 7.9390 us/op 8.6140 us/op 0.92
phase0 processRegistryUpdates - 250000 badcase_full_deposits 368.71 us/op 452.71 us/op 0.81
phase0 processRegistryUpdates - 250000 worstcase 0.5 188.40 ms/op 210.84 ms/op 0.89
altair processRewardsAndPenalties - 250000 normalcase 104.32 ms/op 122.35 ms/op 0.85
altair processRewardsAndPenalties - 250000 worstcase 74.775 ms/op 82.245 ms/op 0.91
phase0 getAttestationDeltas - 250000 normalcase 11.707 ms/op 12.547 ms/op 0.93
phase0 getAttestationDeltas - 250000 worstcase 11.501 ms/op 12.809 ms/op 0.90
phase0 processSlashings - 250000 worstcase 5.2428 ms/op 6.0159 ms/op 0.87
altair processSyncCommitteeUpdates - 250000 286.78 ms/op 272.27 ms/op 1.05
BeaconState.hashTreeRoot - No change 464.00 ns/op 431.00 ns/op 1.08
BeaconState.hashTreeRoot - 1 full validator 66.200 us/op 61.476 us/op 1.08
BeaconState.hashTreeRoot - 32 full validator 778.34 us/op 745.12 us/op 1.04
BeaconState.hashTreeRoot - 512 full validator 6.9583 ms/op 5.9197 ms/op 1.18
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 98.142 us/op 78.998 us/op 1.24
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.2683 ms/op 1.1687 ms/op 1.09
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 16.519 ms/op 15.229 ms/op 1.08
BeaconState.hashTreeRoot - 1 balances 69.558 us/op 58.704 us/op 1.18
BeaconState.hashTreeRoot - 32 balances 641.29 us/op 469.86 us/op 1.36
BeaconState.hashTreeRoot - 512 balances 6.1986 ms/op 5.5230 ms/op 1.12
BeaconState.hashTreeRoot - 250000 balances 102.03 ms/op 96.782 ms/op 1.05
aggregationBits - 2048 els - zipIndexesInBitList 23.961 us/op 27.193 us/op 0.88
regular array get 100000 times 60.522 us/op 67.319 us/op 0.90
wrappedArray get 100000 times 60.537 us/op 67.674 us/op 0.89
arrayWithProxy get 100000 times 26.234 ms/op 28.325 ms/op 0.93
ssz.Root.equals 936.00 ns/op 1.0450 us/op 0.90
byteArrayEquals 912.00 ns/op 1.0470 us/op 0.87
shuffle list - 16384 els 11.612 ms/op 11.325 ms/op 1.03
shuffle list - 250000 els 169.32 ms/op 168.63 ms/op 1.00
processSlot - 1 slots 13.868 us/op 12.021 us/op 1.15
processSlot - 32 slots 2.0063 ms/op 1.7538 ms/op 1.14
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 323.98 us/op 336.86 us/op 0.96
getCommitteeAssignments - req 1 vs - 250000 vc 5.9491 ms/op 5.6026 ms/op 1.06
getCommitteeAssignments - req 100 vs - 250000 vc 7.9909 ms/op 7.5654 ms/op 1.06
getCommitteeAssignments - req 1000 vs - 250000 vc 8.5293 ms/op 8.0198 ms/op 1.06
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 7.3000 ns/op 9.6400 ns/op 0.76
state getBlockRootAtSlot - 250000 vs - 7PWei 1.1141 us/op 1.1558 us/op 0.96
computeProposers - vc 250000 17.108 ms/op 16.249 ms/op 1.05
computeEpochShuffling - vc 250000 171.16 ms/op 170.45 ms/op 1.00
getNextSyncCommittee - vc 250000 285.12 ms/op 269.87 ms/op 1.06

by benchmarkbot/action

@wemeetagain wemeetagain merged commit d7f0168 into unstable Dec 24, 2022
@wemeetagain wemeetagain deleted the tuyen/fix-head-state branch December 24, 2022 15:29
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.

headState does not exist
3 participants