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: avoid using BigInt for slashing classes #6116

Closed
wants to merge 9 commits into from

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Nov 21, 2023

Motivation

  • Using BigInt in AttesterSlashings and ProposerSlashings caused memory, gc spiked, state transition time spiked and node was not able to recover even 6 days after the incident, see Improve gossip block receive time #6105

Description

  • Use 8 bytes little endian to store epoch, index in slashing objects instead of BigInt:
    • When we receive objects from gossip, we don't need to deserialize
    • Uint8Array little endian objects are comparable
    • hashTreeRoot() and serialize() should be the same
  • Need to handle toJson and fromJson as string number in order to run spec tests, so created a new type Bytes8UintJson
  • Also improve "intToBytes()", "bytesToInt()" to avoid using BigInt if possible

part of #6112

part of #5892

Copy link
Contributor

github-actions bot commented Nov 21, 2023

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: a8510c2 Previous: fa30bcf Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 560.42 us/op 1.0221 ms/op 0.55
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 122.54 us/op 123.14 us/op 1.00
BLS verify - blst-native 1.3973 ms/op 1.3424 ms/op 1.04
BLS verifyMultipleSignatures 3 - blst-native 2.8007 ms/op 2.7949 ms/op 1.00
BLS verifyMultipleSignatures 8 - blst-native 6.1305 ms/op 6.1534 ms/op 1.00
BLS verifyMultipleSignatures 32 - blst-native 22.548 ms/op 22.878 ms/op 0.99
BLS verifyMultipleSignatures 64 - blst-native 44.358 ms/op 45.190 ms/op 0.98
BLS verifyMultipleSignatures 128 - blst-native 87.451 ms/op 89.268 ms/op 0.98
BLS deserializing 10000 signatures 929.91 ms/op 955.31 ms/op 0.97
BLS deserializing 100000 signatures 9.1406 s/op 9.3136 s/op 0.98
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.3520 ms/op 1.4220 ms/op 0.95
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.5128 ms/op 1.5130 ms/op 1.00
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.3553 ms/op 2.3369 ms/op 1.01
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.4791 ms/op 4.1216 ms/op 0.84
BLS verifyMultipleSignatures - same message - 128 - blst-native 5.6137 ms/op 5.4655 ms/op 1.03
BLS aggregatePubkeys 32 - blst-native 25.961 us/op 24.856 us/op 1.04
BLS aggregatePubkeys 128 - blst-native 100.97 us/op 97.166 us/op 1.04
getAttestationsForBlock 46.451 ms/op 42.616 ms/op 1.09
isKnown best case - 1 super set check 597.00 ns/op 315.00 ns/op 1.90
isKnown normal case - 2 super set checks 562.00 ns/op 296.00 ns/op 1.90
isKnown worse case - 16 super set checks 619.00 ns/op 322.00 ns/op 1.92
CheckpointStateCache - add get delete 6.7180 us/op 5.3720 us/op 1.25
validate api signedAggregateAndProof - struct 3.0197 ms/op 2.8373 ms/op 1.06
validate gossip signedAggregateAndProof - struct 2.8093 ms/op 2.7998 ms/op 1.00
validate gossip attestation - vc 640000 1.3687 ms/op 1.3923 ms/op 0.98
batch validate gossip attestation - vc 640000 - chunk 32 166.95 us/op 167.77 us/op 1.00
batch validate gossip attestation - vc 640000 - chunk 64 151.47 us/op 146.74 us/op 1.03
batch validate gossip attestation - vc 640000 - chunk 128 140.99 us/op 139.90 us/op 1.01
batch validate gossip attestation - vc 640000 - chunk 256 137.89 us/op 127.43 us/op 1.08
pickEth1Vote - no votes 1.1879 ms/op 1.3260 ms/op 0.90
pickEth1Vote - max votes 8.4205 ms/op 8.6750 ms/op 0.97
pickEth1Vote - Eth1Data hashTreeRoot value x2048 17.329 ms/op 14.293 ms/op 1.21
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 26.287 ms/op 22.048 ms/op 1.19
pickEth1Vote - Eth1Data fastSerialize value x2048 593.22 us/op 575.28 us/op 1.03
pickEth1Vote - Eth1Data fastSerialize tree x2048 4.8896 ms/op 4.3687 ms/op 1.12
bytes32 toHexString 601.00 ns/op 485.00 ns/op 1.24
bytes32 Buffer.toString(hex) 295.00 ns/op 288.00 ns/op 1.02
bytes32 Buffer.toString(hex) from Uint8Array 461.00 ns/op 437.00 ns/op 1.05
bytes32 Buffer.toString(hex) + 0x 291.00 ns/op 298.00 ns/op 0.98
Object access 1 prop 0.17300 ns/op 0.16800 ns/op 1.03
Map access 1 prop 0.15800 ns/op 0.15000 ns/op 1.05
Object get x1000 6.9760 ns/op 7.3830 ns/op 0.94
Map get x1000 0.58100 ns/op 0.62200 ns/op 0.93
Object set x1000 59.087 ns/op 51.419 ns/op 1.15
Map set x1000 44.126 ns/op 40.256 ns/op 1.10
Return object 10000 times 0.25140 ns/op 0.25170 ns/op 1.00
Throw Error 10000 times 3.8715 us/op 3.9639 us/op 0.98
fastMsgIdFn sha256 / 200 bytes 3.4370 us/op 3.4280 us/op 1.00
fastMsgIdFn h32 xxhash / 200 bytes 329.00 ns/op 316.00 ns/op 1.04
fastMsgIdFn h64 xxhash / 200 bytes 349.00 ns/op 363.00 ns/op 0.96
fastMsgIdFn sha256 / 1000 bytes 11.420 us/op 11.565 us/op 0.99
fastMsgIdFn h32 xxhash / 1000 bytes 432.00 ns/op 436.00 ns/op 0.99
fastMsgIdFn h64 xxhash / 1000 bytes 419.00 ns/op 437.00 ns/op 0.96
fastMsgIdFn sha256 / 10000 bytes 103.02 us/op 106.65 us/op 0.97
fastMsgIdFn h32 xxhash / 10000 bytes 1.9780 us/op 2.0010 us/op 0.99
fastMsgIdFn h64 xxhash / 10000 bytes 1.3500 us/op 1.4320 us/op 0.94
send data - 1000 256B messages 20.594 ms/op 20.881 ms/op 0.99
send data - 1000 512B messages 25.664 ms/op 28.638 ms/op 0.90
send data - 1000 1024B messages 42.188 ms/op 43.715 ms/op 0.97
send data - 1000 1200B messages 34.659 ms/op 38.507 ms/op 0.90
send data - 1000 2048B messages 37.241 ms/op 42.074 ms/op 0.89
send data - 1000 4096B messages 25.805 ms/op 42.726 ms/op 0.60
send data - 1000 16384B messages 109.41 ms/op 114.34 ms/op 0.96
send data - 1000 65536B messages 394.71 ms/op 438.16 ms/op 0.90
enrSubnets - fastDeserialize 64 bits 1.3260 us/op 1.3090 us/op 1.01
enrSubnets - ssz BitVector 64 bits 415.00 ns/op 416.00 ns/op 1.00
enrSubnets - fastDeserialize 4 bits 165.00 ns/op 170.00 ns/op 0.97
enrSubnets - ssz BitVector 4 bits 412.00 ns/op 434.00 ns/op 0.95
prioritizePeers score -10:0 att 32-0.1 sync 2-0 101.52 us/op 101.21 us/op 1.00
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 127.27 us/op 125.04 us/op 1.02
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 158.90 us/op 167.83 us/op 0.95
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 322.79 us/op 288.19 us/op 1.12
prioritizePeers score 0:0 att 64-1 sync 4-1 332.98 us/op 342.03 us/op 0.97
array of 16000 items push then shift 1.6070 us/op 1.6450 us/op 0.98
LinkedList of 16000 items push then shift 8.8410 ns/op 8.9460 ns/op 0.99
array of 16000 items push then pop 76.158 ns/op 87.688 ns/op 0.87
LinkedList of 16000 items push then pop 8.5770 ns/op 8.6580 ns/op 0.99
array of 24000 items push then shift 2.3521 us/op 2.5664 us/op 0.92
LinkedList of 24000 items push then shift 8.6990 ns/op 8.9830 ns/op 0.97
array of 24000 items push then pop 99.054 ns/op 134.51 ns/op 0.74
LinkedList of 24000 items push then pop 8.4950 ns/op 8.8130 ns/op 0.96
intersect bitArray bitLen 8 6.6610 ns/op 6.9280 ns/op 0.96
intersect array and set length 8 55.733 ns/op 61.058 ns/op 0.91
intersect bitArray bitLen 128 31.115 ns/op 34.224 ns/op 0.91
intersect array and set length 128 749.95 ns/op 970.59 ns/op 0.77
bitArray.getTrueBitIndexes() bitLen 128 1.4410 us/op 1.6450 us/op 0.88
bitArray.getTrueBitIndexes() bitLen 248 2.3880 us/op 2.6840 us/op 0.89
bitArray.getTrueBitIndexes() bitLen 512 4.7320 us/op 5.0150 us/op 0.94
Buffer.concat 32 items 927.00 ns/op 953.00 ns/op 0.97
Uint8Array.set 32 items 1.6020 us/op 2.0310 us/op 0.79
Set add up to 64 items then delete first 4.2733 us/op 4.4219 us/op 0.97
OrderedSet add up to 64 items then delete first 5.3745 us/op 6.0943 us/op 0.88
Set add up to 64 items then delete last 4.5714 us/op 4.7728 us/op 0.96
OrderedSet add up to 64 items then delete last 5.6639 us/op 5.8744 us/op 0.96
Set add up to 64 items then delete middle 4.5734 us/op 4.8558 us/op 0.94
OrderedSet add up to 64 items then delete middle 7.0030 us/op 8.1830 us/op 0.86
Set add up to 128 items then delete first 9.4200 us/op 9.8596 us/op 0.96
OrderedSet add up to 128 items then delete first 12.149 us/op 12.587 us/op 0.97
Set add up to 128 items then delete last 9.1988 us/op 9.7485 us/op 0.94
OrderedSet add up to 128 items then delete last 11.528 us/op 13.091 us/op 0.88
Set add up to 128 items then delete middle 9.0528 us/op 10.400 us/op 0.87
OrderedSet add up to 128 items then delete middle 16.401 us/op 17.822 us/op 0.92
Set add up to 256 items then delete first 18.698 us/op 19.486 us/op 0.96
OrderedSet add up to 256 items then delete first 24.820 us/op 25.901 us/op 0.96
Set add up to 256 items then delete last 17.827 us/op 19.626 us/op 0.91
OrderedSet add up to 256 items then delete last 23.172 us/op 26.865 us/op 0.86
Set add up to 256 items then delete middle 18.042 us/op 20.529 us/op 0.88
OrderedSet add up to 256 items then delete middle 44.550 us/op 51.421 us/op 0.87
transfer serialized Status (84 B) 1.7590 us/op 1.8120 us/op 0.97
copy serialized Status (84 B) 1.4720 us/op 1.5480 us/op 0.95
transfer serialized SignedVoluntaryExit (112 B) 1.8960 us/op 1.9460 us/op 0.97
copy serialized SignedVoluntaryExit (112 B) 1.4800 us/op 1.5570 us/op 0.95
transfer serialized ProposerSlashing (416 B) 1.9700 us/op 2.3380 us/op 0.84
copy serialized ProposerSlashing (416 B) 1.8010 us/op 2.0620 us/op 0.87
transfer serialized Attestation (485 B) 2.0110 us/op 2.2020 us/op 0.91
copy serialized Attestation (485 B) 1.8080 us/op 2.2580 us/op 0.80
transfer serialized AttesterSlashing (33232 B) 2.2820 us/op 2.3320 us/op 0.98
copy serialized AttesterSlashing (33232 B) 5.2370 us/op 7.4840 us/op 0.70
transfer serialized Small SignedBeaconBlock (128000 B) 2.7600 us/op 2.7220 us/op 1.01
copy serialized Small SignedBeaconBlock (128000 B) 15.614 us/op 20.313 us/op 0.77
transfer serialized Avg SignedBeaconBlock (200000 B) 2.7470 us/op 3.2970 us/op 0.83
copy serialized Avg SignedBeaconBlock (200000 B) 23.663 us/op 28.762 us/op 0.82
transfer serialized BlobsSidecar (524380 B) 3.1070 us/op 3.8730 us/op 0.80
copy serialized BlobsSidecar (524380 B) 72.483 us/op 109.22 us/op 0.66
transfer serialized Big SignedBeaconBlock (1000000 B) 3.2270 us/op 4.3390 us/op 0.74
copy serialized Big SignedBeaconBlock (1000000 B) 133.12 us/op 175.43 us/op 0.76
pass gossip attestations to forkchoice per slot 3.6972 ms/op 4.4950 ms/op 0.82
forkChoice updateHead vc 100000 bc 64 eq 0 656.73 us/op 694.79 us/op 0.95
forkChoice updateHead vc 600000 bc 64 eq 0 3.9367 ms/op 5.1568 ms/op 0.76
forkChoice updateHead vc 1000000 bc 64 eq 0 6.8943 ms/op 7.2222 ms/op 0.95
forkChoice updateHead vc 600000 bc 320 eq 0 4.0826 ms/op 4.3090 ms/op 0.95
forkChoice updateHead vc 600000 bc 1200 eq 0 4.1600 ms/op 4.4621 ms/op 0.93
forkChoice updateHead vc 600000 bc 7200 eq 0 5.2331 ms/op 5.6238 ms/op 0.93
forkChoice updateHead vc 600000 bc 64 eq 1000 10.955 ms/op 11.688 ms/op 0.94
forkChoice updateHead vc 600000 bc 64 eq 10000 11.757 ms/op 12.519 ms/op 0.94
forkChoice updateHead vc 600000 bc 64 eq 300000 15.248 ms/op 16.274 ms/op 0.94
computeDeltas 500000 validators 300 proto nodes 6.3306 ms/op 6.4767 ms/op 0.98
computeDeltas 500000 validators 1200 proto nodes 6.3096 ms/op 6.5292 ms/op 0.97
computeDeltas 500000 validators 7200 proto nodes 6.2101 ms/op 6.3254 ms/op 0.98
computeDeltas 750000 validators 300 proto nodes 9.6794 ms/op 10.136 ms/op 0.95
computeDeltas 750000 validators 1200 proto nodes 9.6287 ms/op 9.8984 ms/op 0.97
computeDeltas 750000 validators 7200 proto nodes 9.5985 ms/op 10.087 ms/op 0.95
computeDeltas 1400000 validators 300 proto nodes 18.742 ms/op 19.360 ms/op 0.97
computeDeltas 1400000 validators 1200 proto nodes 19.191 ms/op 19.894 ms/op 0.96
computeDeltas 1400000 validators 7200 proto nodes 18.790 ms/op 20.067 ms/op 0.94
computeDeltas 2100000 validators 300 proto nodes 28.101 ms/op 31.969 ms/op 0.88
computeDeltas 2100000 validators 1200 proto nodes 30.236 ms/op 33.623 ms/op 0.90
computeDeltas 2100000 validators 7200 proto nodes 30.330 ms/op 35.427 ms/op 0.86
computeProposerBoostScoreFromBalances 500000 validators 3.3135 ms/op 3.6346 ms/op 0.91
computeProposerBoostScoreFromBalances 750000 validators 3.3078 ms/op 3.6754 ms/op 0.90
computeProposerBoostScoreFromBalances 1400000 validators 3.4775 ms/op 3.4217 ms/op 1.02
computeProposerBoostScoreFromBalances 2100000 validators 3.4284 ms/op 3.4613 ms/op 0.99
altair processAttestation - 250000 vs - 7PWei normalcase 3.5420 ms/op 2.3066 ms/op 1.54
altair processAttestation - 250000 vs - 7PWei worstcase 4.6171 ms/op 7.1374 ms/op 0.65
altair processAttestation - setStatus - 1/6 committees join 182.02 us/op 330.35 us/op 0.55
altair processAttestation - setStatus - 1/3 committees join 305.49 us/op 663.53 us/op 0.46
altair processAttestation - setStatus - 1/2 committees join 406.26 us/op 618.34 us/op 0.66
altair processAttestation - setStatus - 2/3 committees join 524.85 us/op 725.74 us/op 0.72
altair processAttestation - setStatus - 4/5 committees join 704.77 us/op 990.79 us/op 0.71
altair processAttestation - setStatus - 100% committees join 857.08 us/op 1.0123 ms/op 0.85
altair processBlock - 250000 vs - 7PWei normalcase 11.427 ms/op 10.274 ms/op 1.11
altair processBlock - 250000 vs - 7PWei normalcase hashState 41.548 ms/op 35.865 ms/op 1.16
altair processBlock - 250000 vs - 7PWei worstcase 46.275 ms/op 43.228 ms/op 1.07
altair processBlock - 250000 vs - 7PWei worstcase hashState 107.06 ms/op 85.551 ms/op 1.25
phase0 processBlock - 250000 vs - 7PWei normalcase 3.6303 ms/op 2.2669 ms/op 1.60
phase0 processBlock - 250000 vs - 7PWei worstcase 33.299 ms/op 30.185 ms/op 1.10
altair processEth1Data - 250000 vs - 7PWei normalcase 595.13 us/op 696.35 us/op 0.85
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 23.173 us/op 20.921 us/op 1.11
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 87.439 us/op 70.809 us/op 1.23
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 32.644 us/op 30.307 us/op 1.08
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 24.983 us/op 20.776 us/op 1.20
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 226.18 us/op 247.88 us/op 0.91
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.6943 ms/op 1.8919 ms/op 0.90
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.9893 ms/op 2.4015 ms/op 0.83
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.7467 ms/op 2.0195 ms/op 0.86
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.1383 ms/op 4.2838 ms/op 0.97
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 2.8473 ms/op 3.2648 ms/op 0.87
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 7.0139 ms/op 6.5361 ms/op 1.07
Tree 40 250000 create 476.10 ms/op 631.29 ms/op 0.75
Tree 40 250000 get(125000) 212.06 ns/op 258.78 ns/op 0.82
Tree 40 250000 set(125000) 1.2059 us/op 1.9120 us/op 0.63
Tree 40 250000 toArray() 23.735 ms/op 28.383 ms/op 0.84
Tree 40 250000 iterate all - toArray() + loop 24.037 ms/op 24.735 ms/op 0.97
Tree 40 250000 iterate all - get(i) 76.553 ms/op 80.893 ms/op 0.95
MutableVector 250000 create 13.529 ms/op 12.845 ms/op 1.05
MutableVector 250000 get(125000) 6.8230 ns/op 8.1650 ns/op 0.84
MutableVector 250000 set(125000) 338.46 ns/op 541.56 ns/op 0.62
MutableVector 250000 toArray() 4.5297 ms/op 4.8533 ms/op 0.93
MutableVector 250000 iterate all - toArray() + loop 4.8084 ms/op 4.8025 ms/op 1.00
MutableVector 250000 iterate all - get(i) 1.5427 ms/op 1.7620 ms/op 0.88
Array 250000 create 4.7389 ms/op 4.4067 ms/op 1.08
Array 250000 clone - spread 1.3795 ms/op 1.6691 ms/op 0.83
Array 250000 get(125000) 0.63200 ns/op 0.84500 ns/op 0.75
Array 250000 set(125000) 0.76900 ns/op 0.88300 ns/op 0.87
Array 250000 iterate all - loop 91.173 us/op 90.697 us/op 1.01
effectiveBalanceIncrements clone Uint8Array 300000 43.977 us/op 47.973 us/op 0.92
effectiveBalanceIncrements clone MutableVector 300000 360.00 ns/op 308.00 ns/op 1.17
effectiveBalanceIncrements rw all Uint8Array 300000 167.75 us/op 192.86 us/op 0.87
effectiveBalanceIncrements rw all MutableVector 300000 109.97 ms/op 98.531 ms/op 1.12
phase0 afterProcessEpoch - 250000 vs - 7PWei 116.46 ms/op 135.29 ms/op 0.86
phase0 beforeProcessEpoch - 250000 vs - 7PWei 54.402 ms/op 56.801 ms/op 0.96
altair processEpoch - mainnet_e81889 528.84 ms/op 550.21 ms/op 0.96
mainnet_e81889 - altair beforeProcessEpoch 94.077 ms/op 93.141 ms/op 1.01
mainnet_e81889 - altair processJustificationAndFinalization 21.986 us/op 24.284 us/op 0.91
mainnet_e81889 - altair processInactivityUpdates 6.7395 ms/op 8.2881 ms/op 0.81
mainnet_e81889 - altair processRewardsAndPenalties 82.458 ms/op 89.353 ms/op 0.92
mainnet_e81889 - altair processRegistryUpdates 3.7940 us/op 4.7110 us/op 0.81
mainnet_e81889 - altair processSlashings 612.00 ns/op 1.1910 us/op 0.51
mainnet_e81889 - altair processEth1DataReset 968.00 ns/op 962.00 ns/op 1.01
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.3802 ms/op 2.0217 ms/op 0.68
mainnet_e81889 - altair processSlashingsReset 4.5320 us/op 5.7050 us/op 0.79
mainnet_e81889 - altair processRandaoMixesReset 8.8350 us/op 8.4520 us/op 1.05
mainnet_e81889 - altair processHistoricalRootsUpdate 1.7430 us/op 1.5780 us/op 1.10
mainnet_e81889 - altair processParticipationFlagUpdates 2.9900 us/op 4.6330 us/op 0.65
mainnet_e81889 - altair processSyncCommitteeUpdates 1.2390 us/op 1.0460 us/op 1.18
mainnet_e81889 - altair afterProcessEpoch 127.95 ms/op 139.36 ms/op 0.92
capella processEpoch - mainnet_e217614 2.7438 s/op 2.5556 s/op 1.07
mainnet_e217614 - capella beforeProcessEpoch 540.43 ms/op 556.09 ms/op 0.97
mainnet_e217614 - capella processJustificationAndFinalization 22.728 us/op 25.144 us/op 0.90
mainnet_e217614 - capella processInactivityUpdates 21.913 ms/op 23.953 ms/op 0.91
mainnet_e217614 - capella processRewardsAndPenalties 609.27 ms/op 562.92 ms/op 1.08
mainnet_e217614 - capella processRegistryUpdates 34.439 us/op 31.251 us/op 1.10
mainnet_e217614 - capella processSlashings 1.1180 us/op 868.00 ns/op 1.29
mainnet_e217614 - capella processEth1DataReset 1.1500 us/op 632.00 ns/op 1.82
mainnet_e217614 - capella processEffectiveBalanceUpdates 4.3485 ms/op 4.1302 ms/op 1.05
mainnet_e217614 - capella processSlashingsReset 4.5330 us/op 2.2780 us/op 1.99
mainnet_e217614 - capella processRandaoMixesReset 11.488 us/op 4.7590 us/op 2.41
mainnet_e217614 - capella processHistoricalRootsUpdate 764.00 ns/op 550.00 ns/op 1.39
mainnet_e217614 - capella processParticipationFlagUpdates 2.2410 us/op 1.6810 us/op 1.33
mainnet_e217614 - capella afterProcessEpoch 327.84 ms/op 330.34 ms/op 0.99
phase0 processEpoch - mainnet_e58758 466.93 ms/op 439.98 ms/op 1.06
mainnet_e58758 - phase0 beforeProcessEpoch 135.61 ms/op 115.02 ms/op 1.18
mainnet_e58758 - phase0 processJustificationAndFinalization 19.826 us/op 16.773 us/op 1.18
mainnet_e58758 - phase0 processRewardsAndPenalties 67.166 ms/op 60.945 ms/op 1.10
mainnet_e58758 - phase0 processRegistryUpdates 19.755 us/op 13.912 us/op 1.42
mainnet_e58758 - phase0 processSlashings 918.00 ns/op 661.00 ns/op 1.39
mainnet_e58758 - phase0 processEth1DataReset 639.00 ns/op 784.00 ns/op 0.82
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.0520 ms/op 1.0614 ms/op 0.99
mainnet_e58758 - phase0 processSlashingsReset 3.5950 us/op 3.5770 us/op 1.01
mainnet_e58758 - phase0 processRandaoMixesReset 6.5940 us/op 5.3390 us/op 1.24
mainnet_e58758 - phase0 processHistoricalRootsUpdate 556.00 ns/op 541.00 ns/op 1.03
mainnet_e58758 - phase0 processParticipationRecordUpdates 6.5990 us/op 5.6000 us/op 1.18
mainnet_e58758 - phase0 afterProcessEpoch 99.559 ms/op 112.53 ms/op 0.88
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.2284 ms/op 1.7399 ms/op 0.71
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.4674 ms/op 1.9294 ms/op 0.76
altair processInactivityUpdates - 250000 normalcase 22.390 ms/op 23.580 ms/op 0.95
altair processInactivityUpdates - 250000 worstcase 22.509 ms/op 24.315 ms/op 0.93
phase0 processRegistryUpdates - 250000 normalcase 10.016 us/op 15.586 us/op 0.64
phase0 processRegistryUpdates - 250000 badcase_full_deposits 346.43 us/op 474.60 us/op 0.73
phase0 processRegistryUpdates - 250000 worstcase 0.5 144.61 ms/op 145.64 ms/op 0.99
altair processRewardsAndPenalties - 250000 normalcase 64.747 ms/op 81.418 ms/op 0.80
altair processRewardsAndPenalties - 250000 worstcase 65.185 ms/op 73.598 ms/op 0.89
phase0 getAttestationDeltas - 250000 normalcase 9.3182 ms/op 13.436 ms/op 0.69
phase0 getAttestationDeltas - 250000 worstcase 9.0751 ms/op 13.577 ms/op 0.67
phase0 processSlashings - 250000 worstcase 2.3565 ms/op 2.6160 ms/op 0.90
altair processSyncCommitteeUpdates - 250000 158.98 ms/op 186.28 ms/op 0.85
BeaconState.hashTreeRoot - No change 350.00 ns/op 360.00 ns/op 0.97
BeaconState.hashTreeRoot - 1 full validator 156.21 us/op 168.29 us/op 0.93
BeaconState.hashTreeRoot - 32 full validator 1.4360 ms/op 1.9134 ms/op 0.75
BeaconState.hashTreeRoot - 512 full validator 15.744 ms/op 22.000 ms/op 0.72
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 155.53 us/op 222.80 us/op 0.70
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 2.2490 ms/op 3.0557 ms/op 0.74
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 25.637 ms/op 38.071 ms/op 0.67
BeaconState.hashTreeRoot - 1 balances 154.97 us/op 177.43 us/op 0.87
BeaconState.hashTreeRoot - 32 balances 1.4643 ms/op 1.6978 ms/op 0.86
BeaconState.hashTreeRoot - 512 balances 12.755 ms/op 13.604 ms/op 0.94
BeaconState.hashTreeRoot - 250000 balances 217.67 ms/op 226.27 ms/op 0.96
aggregationBits - 2048 els - zipIndexesInBitList 49.475 us/op 21.656 us/op 2.28
byteArrayEquals 32 51.046 ns/op 55.158 ns/op 0.93
Buffer.compare 32 57.022 ns/op 61.685 ns/op 0.92
byteArrayEquals 1024 1.4852 us/op 1.5777 us/op 0.94
Buffer.compare 1024 70.923 ns/op 74.722 ns/op 0.95
byteArrayEquals 16384 23.872 us/op 24.475 us/op 0.98
Buffer.compare 16384 256.05 ns/op 306.44 ns/op 0.84
byteArrayEquals 123687377 181.66 ms/op 198.82 ms/op 0.91
Buffer.compare 123687377 11.332 ms/op 10.189 ms/op 1.11
byteArrayEquals 32 - diff last byte 54.831 ns/op 63.758 ns/op 0.86
Buffer.compare 32 - diff last byte 60.655 ns/op 60.776 ns/op 1.00
byteArrayEquals 1024 - diff last byte 1.6722 us/op 1.6792 us/op 1.00
Buffer.compare 1024 - diff last byte 87.180 ns/op 80.809 ns/op 1.08
byteArrayEquals 16384 - diff last byte 25.571 us/op 27.651 us/op 0.92
Buffer.compare 16384 - diff last byte 345.12 ns/op 331.89 ns/op 1.04
byteArrayEquals 123687377 - diff last byte 191.39 ms/op 195.67 ms/op 0.98
Buffer.compare 123687377 - diff last byte 9.8071 ms/op 10.756 ms/op 0.91
byteArrayEquals 32 - random bytes 7.7540 ns/op 7.7960 ns/op 0.99
Buffer.compare 32 - random bytes 63.068 ns/op 69.628 ns/op 0.91
byteArrayEquals 1024 - random bytes 7.0100 ns/op 7.4430 ns/op 0.94
Buffer.compare 1024 - random bytes 62.596 ns/op 64.388 ns/op 0.97
byteArrayEquals 16384 - random bytes 6.9600 ns/op 7.4410 ns/op 0.94
Buffer.compare 16384 - random bytes 61.636 ns/op 67.552 ns/op 0.91
byteArrayEquals 123687377 - random bytes 10.510 ns/op 9.7900 ns/op 1.07
Buffer.compare 123687377 - random bytes 76.370 ns/op 74.370 ns/op 1.03
regular array get 100000 times 46.101 us/op 41.622 us/op 1.11
wrappedArray get 100000 times 35.540 us/op 36.505 us/op 0.97
arrayWithProxy get 100000 times 14.268 ms/op 16.682 ms/op 0.86
ssz.Root.equals 51.468 ns/op 55.204 ns/op 0.93
byteArrayEquals 55.846 ns/op 54.459 ns/op 1.03
Buffer.compare 12.427 ns/op 12.455 ns/op 1.00
shuffle list - 16384 els 7.2473 ms/op 7.1844 ms/op 1.01
shuffle list - 250000 els 107.47 ms/op 107.38 ms/op 1.00
processSlot - 1 slots 20.221 us/op 16.436 us/op 1.23
processSlot - 32 slots 3.8967 ms/op 3.0493 ms/op 1.28
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 69.567 ms/op 57.877 ms/op 1.20
getCommitteeAssignments - req 1 vs - 250000 vc 2.6511 ms/op 2.6816 ms/op 0.99
getCommitteeAssignments - req 100 vs - 250000 vc 3.8186 ms/op 3.8871 ms/op 0.98
getCommitteeAssignments - req 1000 vs - 250000 vc 4.1900 ms/op 4.3503 ms/op 0.96
findModifiedValidators - 10000 modified validators 685.96 ms/op 567.36 ms/op 1.21
findModifiedValidators - 1000 modified validators 529.90 ms/op 459.24 ms/op 1.15
findModifiedValidators - 100 modified validators 493.07 ms/op 454.98 ms/op 1.08
findModifiedValidators - 10 modified validators 506.74 ms/op 482.54 ms/op 1.05
findModifiedValidators - 1 modified validators 474.32 ms/op 513.02 ms/op 0.92
findModifiedValidators - no difference 416.04 ms/op 464.47 ms/op 0.90
compare ViewDUs 5.2160 s/op 4.8692 s/op 1.07
compare each validator Uint8Array 2.1028 s/op 2.1703 s/op 0.97
compare ViewDU to Uint8Array 1.2172 s/op 1.6938 s/op 0.72
migrate state 1000000 validators, 24 modified, 0 new 810.93 ms/op 1.1511 s/op 0.70
migrate state 1000000 validators, 1700 modified, 1000 new 1.1111 s/op 1.5756 s/op 0.71
migrate state 1000000 validators, 3400 modified, 2000 new 1.3401 s/op 1.6209 s/op 0.83
migrate state 1500000 validators, 24 modified, 0 new 877.00 ms/op 950.29 ms/op 0.92
migrate state 1500000 validators, 1700 modified, 1000 new 1.2264 s/op 1.5397 s/op 0.80
migrate state 1500000 validators, 3400 modified, 2000 new 1.6059 s/op 1.8725 s/op 0.86
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 5.1600 ns/op 6.1400 ns/op 0.84
state getBlockRootAtSlot - 250000 vs - 7PWei 748.45 ns/op 775.03 ns/op 0.97
computeProposers - vc 250000 9.4977 ms/op 11.644 ms/op 0.82
computeEpochShuffling - vc 250000 110.86 ms/op 119.75 ms/op 0.93
getNextSyncCommittee - vc 250000 179.22 ms/op 209.49 ms/op 0.86
computeSigningRoot for AttestationData 34.102 us/op 31.636 us/op 1.08
hash AttestationData serialized data then Buffer.toString(base64) 2.4482 us/op 2.5234 us/op 0.97
toHexString serialized data 1.1285 us/op 1.5267 us/op 0.74
Buffer.toString(base64) 234.78 ns/op 292.90 ns/op 0.80
intToBytes 50.280 ns/op
bigIntToBytes 112.63 ns/op
bytesToInt 88.747 ns/op
bytesToBigInt 104.15 ns/op

by benchmarkbot/action

@dapplion
Copy link
Contributor

Using BigInt in AttesterSlashings and ProposerSlashings caused memory, gc spiked, state transition time spiked and node was not able to recover even 6 days after the incident

Please can you show evidence that proofs that the observed event (gc spike) is actually caused by the bigint field in the slashing messages?

@twoeths
Copy link
Contributor Author

twoeths commented Nov 23, 2023

Using BigInt in AttesterSlashings and ProposerSlashings caused memory, gc spiked, state transition time spiked and node was not able to recover even 6 days after the incident

Please can you show evidence that proofs that the observed event (gc spike) is actually caused by the bigint field in the slashing messages?

@dapplion I couldn't come up with a test to prove it, I'll try to setup a devnet and try to reproduce there. I guess the spike not only come from AttesterSlashings specifically but also some slashing process in state transition too.

In the past there are a lot of issues regarding BigInt so I'd not use it if possible, we switched slot, epoch, effectiveBalanceByIncrement. Also the recent BigInt usage in gossipsub caused issue #5892 cc @wemeetagain

Using Uin8Array in this PR may not be be best choice due to memory, we can use 2 uint32 numbers to model a BigInt similar to what we did in persistent-merkle-tree. But I'll try to reproduce first.

@twoeths
Copy link
Contributor Author

twoeths commented Dec 13, 2023

closing the PR as I couldn't reproduce this issue in devnet, will look into this if performance issue happens again for AttesterSlashing messages, also #6121 could be enough

@twoeths twoeths closed this Dec 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants