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: convert getStateV2 response to Buffer without memory copy #6687

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Apr 18, 2024

Motivation

Improve fetching state as SSZ response, and reduce memory increase per request.

Currently we copy the underlying ArrayBuffer when converting the serialized state (Uint8Array) to a Buffer when returning it in the response.

The Buffer conversion is required by Fastify but newer versions will do this internally in an efficient way already, so we can even just return the Uint8Array in the handler.

Description

Convert getStateV2 response to Buffer without memory copy

Benchmarks

From unstable...nflaig/bench-buffer-from

Buffer utils
✔ Buffer.from - copy                  7.286412 ops/s    137.2418 ms/op   x1.024         38 runs   5.82 s
✔ Buffer.from - no copy                1117318 ops/s    895.0000 ns/op   x0.982     723013 runs   1.11 s
✔ Buffer.from - no copy with offset    1179245 ops/s    848.0000 ns/op        -    2699558 runs   3.85 s

This should also reduce GC after fetching state but don't have good metrics to showcase here.


We generally might also wanna review our usage of Buffer.from, e.g. here it's not quite clear why we even convert to Buffer

value: Buffer.from(this.type.serialize(block)),

Or if we know it safe to not copy memory as it won't be mutated further, we can just convert to Buffer without memory copy.

@nflaig nflaig requested a review from a team as a code owner April 18, 2024 17:11
Copy link
Contributor

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 7f05693 Previous: 252fd2f Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 494.68 us/op 566.87 us/op 0.87
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 98.536 us/op 81.670 us/op 1.21
BLS verify - blst-native 1.3154 ms/op 1.1785 ms/op 1.12
BLS verifyMultipleSignatures 3 - blst-native 2.7625 ms/op 2.5326 ms/op 1.09
BLS verifyMultipleSignatures 8 - blst-native 6.0856 ms/op 5.8895 ms/op 1.03
BLS verifyMultipleSignatures 32 - blst-native 22.280 ms/op 20.616 ms/op 1.08
BLS verifyMultipleSignatures 64 - blst-native 43.838 ms/op 45.714 ms/op 0.96
BLS verifyMultipleSignatures 128 - blst-native 86.838 ms/op 84.313 ms/op 1.03
BLS deserializing 10000 signatures 900.32 ms/op 947.50 ms/op 0.95
BLS deserializing 100000 signatures 9.3623 s/op 9.1973 s/op 1.02
BLS verifyMultipleSignatures - same message - 3 - blst-native 1.3192 ms/op 1.2641 ms/op 1.04
BLS verifyMultipleSignatures - same message - 8 - blst-native 1.6294 ms/op 1.4485 ms/op 1.12
BLS verifyMultipleSignatures - same message - 32 - blst-native 2.8346 ms/op 2.8686 ms/op 0.99
BLS verifyMultipleSignatures - same message - 64 - blst-native 3.5682 ms/op 4.7418 ms/op 0.75
BLS verifyMultipleSignatures - same message - 128 - blst-native 7.5271 ms/op 5.5378 ms/op 1.36
BLS aggregatePubkeys 32 - blst-native 27.296 us/op 26.180 us/op 1.04
BLS aggregatePubkeys 128 - blst-native 101.84 us/op 97.736 us/op 1.04
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 63.946 ms/op 71.249 ms/op 0.90
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 65.731 ms/op 64.362 ms/op 1.02
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 40.962 ms/op 31.246 ms/op 1.31
getSlashingsAndExits - default max 218.08 us/op 194.88 us/op 1.12
getSlashingsAndExits - 2k 404.02 us/op 478.38 us/op 0.84
proposeBlockBody type=full, size=empty 6.3109 ms/op 4.4344 ms/op 1.42
isKnown best case - 1 super set check 328.00 ns/op 359.00 ns/op 0.91
isKnown normal case - 2 super set checks 316.00 ns/op 360.00 ns/op 0.88
isKnown worse case - 16 super set checks 323.00 ns/op 352.00 ns/op 0.92
InMemoryCheckpointStateCache - add get delete 6.0030 us/op 6.1730 us/op 0.97
validate api signedAggregateAndProof - struct 2.7768 ms/op 2.4041 ms/op 1.15
validate gossip signedAggregateAndProof - struct 2.7778 ms/op 2.4828 ms/op 1.12
validate gossip attestation - vc 640000 1.3541 ms/op 1.1698 ms/op 1.16
batch validate gossip attestation - vc 640000 - chunk 32 164.98 us/op 141.80 us/op 1.16
batch validate gossip attestation - vc 640000 - chunk 64 150.62 us/op 132.74 us/op 1.13
batch validate gossip attestation - vc 640000 - chunk 128 147.74 us/op 120.99 us/op 1.22
batch validate gossip attestation - vc 640000 - chunk 256 142.09 us/op 118.72 us/op 1.20
pickEth1Vote - no votes 1.3234 ms/op 1.0448 ms/op 1.27
pickEth1Vote - max votes 10.854 ms/op 6.9255 ms/op 1.57
pickEth1Vote - Eth1Data hashTreeRoot value x2048 23.011 ms/op 23.283 ms/op 0.99
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 30.717 ms/op 29.421 ms/op 1.04
pickEth1Vote - Eth1Data fastSerialize value x2048 715.53 us/op 446.41 us/op 1.60
pickEth1Vote - Eth1Data fastSerialize tree x2048 8.6995 ms/op 9.3451 ms/op 0.93
bytes32 toHexString 773.00 ns/op 535.00 ns/op 1.44
bytes32 Buffer.toString(hex) 324.00 ns/op 361.00 ns/op 0.90
bytes32 Buffer.toString(hex) from Uint8Array 549.00 ns/op 462.00 ns/op 1.19
bytes32 Buffer.toString(hex) + 0x 329.00 ns/op 350.00 ns/op 0.94
Object access 1 prop 0.23100 ns/op 0.22300 ns/op 1.04
Map access 1 prop 0.15900 ns/op 0.20400 ns/op 0.78
Object get x1000 7.5730 ns/op 5.6410 ns/op 1.34
Map get x1000 0.87400 ns/op 0.78200 ns/op 1.12
Object set x1000 70.059 ns/op 29.539 ns/op 2.37
Map set x1000 50.255 ns/op 18.426 ns/op 2.73
Return object 10000 times 0.25750 ns/op 0.24140 ns/op 1.07
Throw Error 10000 times 4.0477 us/op 2.7729 us/op 1.46
fastMsgIdFn sha256 / 200 bytes 3.5260 us/op 2.0130 us/op 1.75
fastMsgIdFn h32 xxhash / 200 bytes 359.00 ns/op 335.00 ns/op 1.07
fastMsgIdFn h64 xxhash / 200 bytes 405.00 ns/op 361.00 ns/op 1.12
fastMsgIdFn sha256 / 1000 bytes 11.984 us/op 6.2110 us/op 1.93
fastMsgIdFn h32 xxhash / 1000 bytes 499.00 ns/op 459.00 ns/op 1.09
fastMsgIdFn h64 xxhash / 1000 bytes 491.00 ns/op 427.00 ns/op 1.15
fastMsgIdFn sha256 / 10000 bytes 107.04 us/op 56.526 us/op 1.89
fastMsgIdFn h32 xxhash / 10000 bytes 2.0630 us/op 1.9620 us/op 1.05
fastMsgIdFn h64 xxhash / 10000 bytes 1.4140 us/op 1.3140 us/op 1.08
send data - 1000 256B messages 22.023 ms/op 13.340 ms/op 1.65
send data - 1000 512B messages 30.234 ms/op 17.958 ms/op 1.68
send data - 1000 1024B messages 42.625 ms/op 22.743 ms/op 1.87
send data - 1000 1200B messages 40.544 ms/op 33.643 ms/op 1.21
send data - 1000 2048B messages 55.198 ms/op 40.091 ms/op 1.38
send data - 1000 4096B messages 48.514 ms/op 38.559 ms/op 1.26
send data - 1000 16384B messages 128.37 ms/op 97.027 ms/op 1.32
send data - 1000 65536B messages 479.96 ms/op 469.38 ms/op 1.02
enrSubnets - fastDeserialize 64 bits 1.6020 us/op 1.6980 us/op 0.94
enrSubnets - ssz BitVector 64 bits 551.00 ns/op 716.00 ns/op 0.77
enrSubnets - fastDeserialize 4 bits 237.00 ns/op 335.00 ns/op 0.71
enrSubnets - ssz BitVector 4 bits 549.00 ns/op 715.00 ns/op 0.77
prioritizePeers score -10:0 att 32-0.1 sync 2-0 236.10 us/op 178.60 us/op 1.32
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 338.93 us/op 282.53 us/op 1.20
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 406.61 us/op 336.95 us/op 1.21
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 661.57 us/op 448.56 us/op 1.47
prioritizePeers score 0:0 att 64-1 sync 4-1 781.93 us/op 558.34 us/op 1.40
array of 16000 items push then shift 1.7109 us/op 1.3884 us/op 1.23
LinkedList of 16000 items push then shift 9.6270 ns/op 7.9850 ns/op 1.21
array of 16000 items push then pop 111.36 ns/op 114.50 ns/op 0.97
LinkedList of 16000 items push then pop 9.5210 ns/op 6.4860 ns/op 1.47
array of 24000 items push then shift 2.7365 us/op 2.0793 us/op 1.32
LinkedList of 24000 items push then shift 10.333 ns/op 7.2610 ns/op 1.42
array of 24000 items push then pop 166.67 ns/op 170.95 ns/op 0.97
LinkedList of 24000 items push then pop 9.1150 ns/op 6.3720 ns/op 1.43
intersect bitArray bitLen 8 6.0530 ns/op 5.3270 ns/op 1.14
intersect array and set length 8 72.763 ns/op 52.329 ns/op 1.39
intersect bitArray bitLen 128 41.564 ns/op 30.762 ns/op 1.35
intersect array and set length 128 1.1201 us/op 988.54 ns/op 1.13
bitArray.getTrueBitIndexes() bitLen 128 1.7270 us/op 1.9830 us/op 0.87
bitArray.getTrueBitIndexes() bitLen 248 3.2030 us/op 3.1020 us/op 1.03
bitArray.getTrueBitIndexes() bitLen 512 6.3420 us/op 5.9750 us/op 1.06
Buffer.concat 32 items 1.1420 us/op 1.1560 us/op 0.99
Uint8Array.set 32 items 2.4010 us/op 1.9300 us/op 1.24
Set add up to 64 items then delete first 5.1362 us/op 2.3782 us/op 2.16
OrderedSet add up to 64 items then delete first 6.5313 us/op 3.8579 us/op 1.69
Set add up to 64 items then delete last 5.9082 us/op 2.3227 us/op 2.54
OrderedSet add up to 64 items then delete last 7.2103 us/op 3.4879 us/op 2.07
Set add up to 64 items then delete middle 5.6421 us/op 2.0338 us/op 2.77
OrderedSet add up to 64 items then delete middle 9.1913 us/op 4.4347 us/op 2.07
Set add up to 128 items then delete first 11.428 us/op 4.0395 us/op 2.83
OrderedSet add up to 128 items then delete first 15.808 us/op 6.3152 us/op 2.50
Set add up to 128 items then delete last 11.562 us/op 3.9543 us/op 2.92
OrderedSet add up to 128 items then delete last 15.584 us/op 6.1687 us/op 2.53
Set add up to 128 items then delete middle 10.954 us/op 4.0958 us/op 2.67
OrderedSet add up to 128 items then delete middle 20.952 us/op 12.588 us/op 1.66
Set add up to 256 items then delete first 22.575 us/op 11.080 us/op 2.04
OrderedSet add up to 256 items then delete first 31.513 us/op 14.530 us/op 2.17
Set add up to 256 items then delete last 21.228 us/op 11.201 us/op 1.90
OrderedSet add up to 256 items then delete last 28.196 us/op 13.998 us/op 2.01
Set add up to 256 items then delete middle 22.410 us/op 11.816 us/op 1.90
OrderedSet add up to 256 items then delete middle 53.617 us/op 40.848 us/op 1.31
transfer serialized Status (84 B) 1.9300 us/op 2.1300 us/op 0.91
copy serialized Status (84 B) 1.4320 us/op 1.7310 us/op 0.83
transfer serialized SignedVoluntaryExit (112 B) 2.0340 us/op 2.1750 us/op 0.94
copy serialized SignedVoluntaryExit (112 B) 1.5070 us/op 1.5740 us/op 0.96
transfer serialized ProposerSlashing (416 B) 2.5020 us/op 3.1980 us/op 0.78
copy serialized ProposerSlashing (416 B) 2.0250 us/op 3.0420 us/op 0.67
transfer serialized Attestation (485 B) 2.4130 us/op 3.0480 us/op 0.79
copy serialized Attestation (485 B) 3.1180 us/op 2.6890 us/op 1.16
transfer serialized AttesterSlashing (33232 B) 3.2380 us/op 3.4780 us/op 0.93
copy serialized AttesterSlashing (33232 B) 7.2610 us/op 11.060 us/op 0.66
transfer serialized Small SignedBeaconBlock (128000 B) 3.3740 us/op 2.8760 us/op 1.17
copy serialized Small SignedBeaconBlock (128000 B) 16.143 us/op 20.296 us/op 0.80
transfer serialized Avg SignedBeaconBlock (200000 B) 3.2960 us/op 3.0490 us/op 1.08
copy serialized Avg SignedBeaconBlock (200000 B) 24.375 us/op 21.391 us/op 1.14
transfer serialized BlobsSidecar (524380 B) 3.0570 us/op 3.6180 us/op 0.84
copy serialized BlobsSidecar (524380 B) 153.44 us/op 137.21 us/op 1.12
transfer serialized Big SignedBeaconBlock (1000000 B) 3.5560 us/op 5.3710 us/op 0.66
copy serialized Big SignedBeaconBlock (1000000 B) 173.52 us/op 176.85 us/op 0.98
pass gossip attestations to forkchoice per slot 4.4481 ms/op 4.5379 ms/op 0.98
forkChoice updateHead vc 100000 bc 64 eq 0 693.75 us/op 580.99 us/op 1.19
forkChoice updateHead vc 600000 bc 64 eq 0 4.3406 ms/op 3.6899 ms/op 1.18
forkChoice updateHead vc 1000000 bc 64 eq 0 7.1823 ms/op 5.8912 ms/op 1.22
forkChoice updateHead vc 600000 bc 320 eq 0 4.3604 ms/op 3.6865 ms/op 1.18
forkChoice updateHead vc 600000 bc 1200 eq 0 4.4696 ms/op 3.9500 ms/op 1.13
forkChoice updateHead vc 600000 bc 7200 eq 0 6.3314 ms/op 5.4483 ms/op 1.16
forkChoice updateHead vc 600000 bc 64 eq 1000 11.762 ms/op 12.411 ms/op 0.95
forkChoice updateHead vc 600000 bc 64 eq 10000 12.595 ms/op 11.544 ms/op 1.09
forkChoice updateHead vc 600000 bc 64 eq 300000 27.661 ms/op 17.031 ms/op 1.62
computeDeltas 500000 validators 300 proto nodes 7.5312 ms/op 3.9894 ms/op 1.89
computeDeltas 500000 validators 1200 proto nodes 7.1832 ms/op 3.7844 ms/op 1.90
computeDeltas 500000 validators 7200 proto nodes 7.4530 ms/op 3.3322 ms/op 2.24
computeDeltas 750000 validators 300 proto nodes 11.611 ms/op 4.8492 ms/op 2.39
computeDeltas 750000 validators 1200 proto nodes 11.284 ms/op 4.8294 ms/op 2.34
computeDeltas 750000 validators 7200 proto nodes 10.860 ms/op 4.7821 ms/op 2.27
computeDeltas 1400000 validators 300 proto nodes 21.459 ms/op 8.7676 ms/op 2.45
computeDeltas 1400000 validators 1200 proto nodes 20.164 ms/op 9.4489 ms/op 2.13
computeDeltas 1400000 validators 7200 proto nodes 20.291 ms/op 9.9820 ms/op 2.03
computeDeltas 2100000 validators 300 proto nodes 28.987 ms/op 14.233 ms/op 2.04
computeDeltas 2100000 validators 1200 proto nodes 28.366 ms/op 15.358 ms/op 1.85
computeDeltas 2100000 validators 7200 proto nodes 29.879 ms/op 15.561 ms/op 1.92
altair processAttestation - 250000 vs - 7PWei normalcase 3.1129 ms/op 2.2035 ms/op 1.41
altair processAttestation - 250000 vs - 7PWei worstcase 4.8176 ms/op 3.8982 ms/op 1.24
altair processAttestation - setStatus - 1/6 committees join 162.66 us/op 85.567 us/op 1.90
altair processAttestation - setStatus - 1/3 committees join 334.31 us/op 161.15 us/op 2.07
altair processAttestation - setStatus - 1/2 committees join 425.28 us/op 237.31 us/op 1.79
altair processAttestation - setStatus - 2/3 committees join 533.14 us/op 333.05 us/op 1.60
altair processAttestation - setStatus - 4/5 committees join 738.08 us/op 469.51 us/op 1.57
altair processAttestation - setStatus - 100% committees join 885.67 us/op 537.08 us/op 1.65
altair processBlock - 250000 vs - 7PWei normalcase 9.7152 ms/op 5.6541 ms/op 1.72
altair processBlock - 250000 vs - 7PWei normalcase hashState 39.737 ms/op 25.822 ms/op 1.54
altair processBlock - 250000 vs - 7PWei worstcase 47.203 ms/op 39.950 ms/op 1.18
altair processBlock - 250000 vs - 7PWei worstcase hashState 102.80 ms/op 83.897 ms/op 1.23
phase0 processBlock - 250000 vs - 7PWei normalcase 3.6575 ms/op 1.8920 ms/op 1.93
phase0 processBlock - 250000 vs - 7PWei worstcase 35.051 ms/op 25.374 ms/op 1.38
altair processEth1Data - 250000 vs - 7PWei normalcase 696.82 us/op 273.14 us/op 2.55
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 23.809 us/op 8.6640 us/op 2.75
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 98.980 us/op 60.543 us/op 1.63
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 30.461 us/op 21.051 us/op 1.45
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 19.571 us/op 11.864 us/op 1.65
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 243.33 us/op 195.56 us/op 1.24
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 1.7499 ms/op 1.1173 ms/op 1.57
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.8615 ms/op 1.4652 ms/op 1.27
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 2.0270 ms/op 1.4676 ms/op 1.38
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 4.5751 ms/op 3.4344 ms/op 1.33
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 3.4768 ms/op 1.8887 ms/op 1.84
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 6.9650 ms/op 4.9283 ms/op 1.41
Tree 40 250000 create 513.02 ms/op 325.94 ms/op 1.57
Tree 40 250000 get(125000) 223.26 ns/op 119.82 ns/op 1.86
Tree 40 250000 set(125000) 1.2370 us/op 1.1768 us/op 1.05
Tree 40 250000 toArray() 27.628 ms/op 21.707 ms/op 1.27
Tree 40 250000 iterate all - toArray() + loop 24.278 ms/op 20.142 ms/op 1.21
Tree 40 250000 iterate all - get(i) 83.904 ms/op 49.845 ms/op 1.68
MutableVector 250000 create 18.079 ms/op 9.0131 ms/op 2.01
MutableVector 250000 get(125000) 7.4880 ns/op 6.4510 ns/op 1.16
MutableVector 250000 set(125000) 349.04 ns/op 200.55 ns/op 1.74
MutableVector 250000 toArray() 4.1739 ms/op 2.5162 ms/op 1.66
MutableVector 250000 iterate all - toArray() + loop 4.4090 ms/op 3.1021 ms/op 1.42
MutableVector 250000 iterate all - get(i) 1.6354 ms/op 1.3900 ms/op 1.18
Array 250000 create 3.7968 ms/op 3.1373 ms/op 1.21
Array 250000 clone - spread 1.6408 ms/op 1.1218 ms/op 1.46
Array 250000 get(125000) 2.2240 ns/op 1.0570 ns/op 2.10
Array 250000 set(125000) 5.3310 ns/op 1.2590 ns/op 4.23
Array 250000 iterate all - loop 183.97 us/op 159.22 us/op 1.16
effectiveBalanceIncrements clone Uint8Array 300000 41.924 us/op 13.933 us/op 3.01
effectiveBalanceIncrements clone MutableVector 300000 372.00 ns/op 397.00 ns/op 0.94
effectiveBalanceIncrements rw all Uint8Array 300000 209.02 us/op 191.63 us/op 1.09
effectiveBalanceIncrements rw all MutableVector 300000 90.513 ms/op 65.280 ms/op 1.39
phase0 afterProcessEpoch - 250000 vs - 7PWei 123.23 ms/op 82.004 ms/op 1.50
phase0 beforeProcessEpoch - 250000 vs - 7PWei 56.878 ms/op 52.814 ms/op 1.08
altair processEpoch - mainnet_e81889 551.88 ms/op 442.94 ms/op 1.25
mainnet_e81889 - altair beforeProcessEpoch 84.452 ms/op 87.568 ms/op 0.96
mainnet_e81889 - altair processJustificationAndFinalization 18.410 us/op 18.469 us/op 1.00
mainnet_e81889 - altair processInactivityUpdates 6.5103 ms/op 7.9189 ms/op 0.82
mainnet_e81889 - altair processRewardsAndPenalties 96.006 ms/op 73.412 ms/op 1.31
mainnet_e81889 - altair processRegistryUpdates 2.9980 us/op 2.8570 us/op 1.05
mainnet_e81889 - altair processSlashings 550.00 ns/op 798.00 ns/op 0.69
mainnet_e81889 - altair processEth1DataReset 824.00 ns/op 783.00 ns/op 1.05
mainnet_e81889 - altair processEffectiveBalanceUpdates 2.6790 ms/op 1.2597 ms/op 2.13
mainnet_e81889 - altair processSlashingsReset 6.5870 us/op 3.6990 us/op 1.78
mainnet_e81889 - altair processRandaoMixesReset 7.2870 us/op 6.9880 us/op 1.04
mainnet_e81889 - altair processHistoricalRootsUpdate 771.00 ns/op 898.00 ns/op 0.86
mainnet_e81889 - altair processParticipationFlagUpdates 2.0670 us/op 2.7760 us/op 0.74
mainnet_e81889 - altair processSyncCommitteeUpdates 932.00 ns/op 1.0380 us/op 0.90
mainnet_e81889 - altair afterProcessEpoch 124.18 ms/op 83.031 ms/op 1.50
capella processEpoch - mainnet_e217614 2.3724 s/op 2.4467 s/op 0.97
mainnet_e217614 - capella beforeProcessEpoch 639.27 ms/op 476.45 ms/op 1.34
mainnet_e217614 - capella processJustificationAndFinalization 28.244 us/op 24.471 us/op 1.15
mainnet_e217614 - capella processInactivityUpdates 33.140 ms/op 24.559 ms/op 1.35
mainnet_e217614 - capella processRewardsAndPenalties 837.04 ms/op 452.98 ms/op 1.85
mainnet_e217614 - capella processRegistryUpdates 43.338 us/op 16.485 us/op 2.63
mainnet_e217614 - capella processSlashings 2.1120 us/op 657.00 ns/op 3.21
mainnet_e217614 - capella processEth1DataReset 1.4770 us/op 540.00 ns/op 2.74
mainnet_e217614 - capella processEffectiveBalanceUpdates 13.094 ms/op 3.5611 ms/op 3.68
mainnet_e217614 - capella processSlashingsReset 10.110 us/op 1.9920 us/op 5.08
mainnet_e217614 - capella processRandaoMixesReset 13.999 us/op 3.5020 us/op 4.00
mainnet_e217614 - capella processHistoricalRootsUpdate 1.4580 us/op 660.00 ns/op 2.21
mainnet_e217614 - capella processParticipationFlagUpdates 3.1820 us/op 2.4470 us/op 1.30
mainnet_e217614 - capella afterProcessEpoch 334.67 ms/op 232.64 ms/op 1.44
phase0 processEpoch - mainnet_e58758 834.54 ms/op 394.91 ms/op 2.11
mainnet_e58758 - phase0 beforeProcessEpoch 276.35 ms/op 133.67 ms/op 2.07
mainnet_e58758 - phase0 processJustificationAndFinalization 40.686 us/op 15.333 us/op 2.65
mainnet_e58758 - phase0 processRewardsAndPenalties 89.248 ms/op 60.780 ms/op 1.47
mainnet_e58758 - phase0 processRegistryUpdates 20.461 us/op 10.497 us/op 1.95
mainnet_e58758 - phase0 processSlashings 815.00 ns/op 805.00 ns/op 1.01
mainnet_e58758 - phase0 processEth1DataReset 700.00 ns/op 823.00 ns/op 0.85
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 1.3804 ms/op 1.2337 ms/op 1.12
mainnet_e58758 - phase0 processSlashingsReset 4.4850 us/op 5.9480 us/op 0.75
mainnet_e58758 - phase0 processRandaoMixesReset 7.1980 us/op 6.8040 us/op 1.06
mainnet_e58758 - phase0 processHistoricalRootsUpdate 1.3080 us/op 1.5930 us/op 0.82
mainnet_e58758 - phase0 processParticipationRecordUpdates 7.7600 us/op 8.6220 us/op 0.90
mainnet_e58758 - phase0 afterProcessEpoch 119.38 ms/op 97.326 ms/op 1.23
phase0 processEffectiveBalanceUpdates - 250000 normalcase 2.2430 ms/op 1.8539 ms/op 1.21
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.9324 ms/op 2.0410 ms/op 0.95
altair processInactivityUpdates - 250000 normalcase 44.078 ms/op 51.205 ms/op 0.86
altair processInactivityUpdates - 250000 worstcase 34.394 ms/op 39.708 ms/op 0.87
phase0 processRegistryUpdates - 250000 normalcase 20.132 us/op 12.071 us/op 1.67
phase0 processRegistryUpdates - 250000 badcase_full_deposits 608.80 us/op 450.28 us/op 1.35
phase0 processRegistryUpdates - 250000 worstcase 0.5 209.61 ms/op 137.73 ms/op 1.52
altair processRewardsAndPenalties - 250000 normalcase 100.63 ms/op 72.814 ms/op 1.38
altair processRewardsAndPenalties - 250000 worstcase 94.975 ms/op 87.078 ms/op 1.09
phase0 getAttestationDeltas - 250000 normalcase 16.645 ms/op 12.575 ms/op 1.32
phase0 getAttestationDeltas - 250000 worstcase 18.240 ms/op 12.005 ms/op 1.52
phase0 processSlashings - 250000 worstcase 165.64 us/op 98.542 us/op 1.68
altair processSyncCommitteeUpdates - 250000 276.53 ms/op 211.52 ms/op 1.31
BeaconState.hashTreeRoot - No change 1.3670 us/op 1.1940 us/op 1.14
BeaconState.hashTreeRoot - 1 full validator 229.23 us/op 217.92 us/op 1.05
BeaconState.hashTreeRoot - 32 full validator 2.1346 ms/op 2.2034 ms/op 0.97
BeaconState.hashTreeRoot - 512 full validator 32.863 ms/op 32.870 ms/op 1.00
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 343.39 us/op 245.77 us/op 1.40
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 4.8434 ms/op 3.1670 ms/op 1.53
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 50.107 ms/op 52.649 ms/op 0.95
BeaconState.hashTreeRoot - 1 balances 178.06 us/op 197.86 us/op 0.90
BeaconState.hashTreeRoot - 32 balances 1.9670 ms/op 1.4612 ms/op 1.35
BeaconState.hashTreeRoot - 512 balances 18.193 ms/op 18.399 ms/op 0.99
BeaconState.hashTreeRoot - 250000 balances 366.86 ms/op 299.93 ms/op 1.22
aggregationBits - 2048 els - zipIndexesInBitList 60.550 us/op 39.423 us/op 1.54
byteArrayEquals 32 100.85 ns/op 66.433 ns/op 1.52
Buffer.compare 32 95.541 ns/op 62.545 ns/op 1.53
byteArrayEquals 1024 4.7776 us/op 2.4819 us/op 1.92
Buffer.compare 1024 110.80 ns/op 74.323 ns/op 1.49
byteArrayEquals 16384 53.572 us/op 28.363 us/op 1.89
Buffer.compare 16384 408.20 ns/op 283.30 ns/op 1.44
byteArrayEquals 123687377 339.26 ms/op 232.71 ms/op 1.46
Buffer.compare 123687377 16.706 ms/op 7.5544 ms/op 2.21
byteArrayEquals 32 - diff last byte 106.72 ns/op 63.179 ns/op 1.69
Buffer.compare 32 - diff last byte 75.470 ns/op 40.672 ns/op 1.86
byteArrayEquals 1024 - diff last byte 2.9813 us/op 1.8868 us/op 1.58
Buffer.compare 1024 - diff last byte 83.241 ns/op 45.652 ns/op 1.82
byteArrayEquals 16384 - diff last byte 38.436 us/op 30.003 us/op 1.28
Buffer.compare 16384 - diff last byte 337.82 ns/op 249.79 ns/op 1.35
byteArrayEquals 123687377 - diff last byte 264.75 ms/op 237.42 ms/op 1.12
Buffer.compare 123687377 - diff last byte 9.2391 ms/op 7.8759 ms/op 1.17
byteArrayEquals 32 - random bytes 6.8740 ns/op 6.1700 ns/op 1.11
Buffer.compare 32 - random bytes 64.749 ns/op 48.167 ns/op 1.34
byteArrayEquals 1024 - random bytes 6.6840 ns/op 6.2860 ns/op 1.06
Buffer.compare 1024 - random bytes 64.447 ns/op 39.557 ns/op 1.63
byteArrayEquals 16384 - random bytes 6.6530 ns/op 6.8750 ns/op 0.97
Buffer.compare 16384 - random bytes 64.704 ns/op 37.635 ns/op 1.72
byteArrayEquals 123687377 - random bytes 9.9800 ns/op 13.320 ns/op 0.75
Buffer.compare 123687377 - random bytes 76.250 ns/op 50.250 ns/op 1.52
regular array get 100000 times 49.529 us/op 42.320 us/op 1.17
wrappedArray get 100000 times 48.447 us/op 42.949 us/op 1.13
arrayWithProxy get 100000 times 16.929 ms/op 9.5275 ms/op 1.78
ssz.Root.equals 60.390 ns/op 64.207 ns/op 0.94
byteArrayEquals 58.951 ns/op 70.231 ns/op 0.84
Buffer.compare 13.011 ns/op 18.267 ns/op 0.71
shuffle list - 16384 els 9.4198 ms/op 7.0347 ms/op 1.34
shuffle list - 250000 els 137.60 ms/op 100.26 ms/op 1.37
processSlot - 1 slots 19.938 us/op 25.867 us/op 0.77
processSlot - 32 slots 3.8650 ms/op 4.1816 ms/op 0.92
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 68.136 ms/op 50.741 ms/op 1.34
getCommitteeAssignments - req 1 vs - 250000 vc 2.8309 ms/op 2.4998 ms/op 1.13
getCommitteeAssignments - req 100 vs - 250000 vc 4.0730 ms/op 3.7041 ms/op 1.10
getCommitteeAssignments - req 1000 vs - 250000 vc 4.4972 ms/op 4.0043 ms/op 1.12
findModifiedValidators - 10000 modified validators 420.07 ms/op 298.35 ms/op 1.41
findModifiedValidators - 1000 modified validators 275.45 ms/op 215.82 ms/op 1.28
findModifiedValidators - 100 modified validators 238.66 ms/op 163.24 ms/op 1.46
findModifiedValidators - 10 modified validators 286.20 ms/op 149.75 ms/op 1.91
findModifiedValidators - 1 modified validators 253.83 ms/op 164.81 ms/op 1.54
findModifiedValidators - no difference 246.14 ms/op 162.90 ms/op 1.51
compare ViewDUs 5.8629 s/op 4.4133 s/op 1.33
compare each validator Uint8Array 2.0778 s/op 1.7363 s/op 1.20
compare ViewDU to Uint8Array 1.9149 s/op 1.2366 s/op 1.55
migrate state 1000000 validators, 24 modified, 0 new 1.0813 s/op 793.12 ms/op 1.36
migrate state 1000000 validators, 1700 modified, 1000 new 1.4317 s/op 1.3683 s/op 1.05
migrate state 1000000 validators, 3400 modified, 2000 new 1.6005 s/op 1.3009 s/op 1.23
migrate state 1500000 validators, 24 modified, 0 new 844.45 ms/op 875.52 ms/op 0.96
migrate state 1500000 validators, 1700 modified, 1000 new 1.2962 s/op 1.0928 s/op 1.19
migrate state 1500000 validators, 3400 modified, 2000 new 1.7638 s/op 1.3817 s/op 1.28
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 6.4200 ns/op 5.0000 ns/op 1.28
state getBlockRootAtSlot - 250000 vs - 7PWei 962.94 ns/op 715.58 ns/op 1.35
computeProposers - vc 250000 12.800 ms/op 7.3965 ms/op 1.73
computeEpochShuffling - vc 250000 145.73 ms/op 99.203 ms/op 1.47
getNextSyncCommittee - vc 250000 191.88 ms/op 125.42 ms/op 1.53
computeSigningRoot for AttestationData 34.110 us/op 28.155 us/op 1.21
hash AttestationData serialized data then Buffer.toString(base64) 2.5930 us/op 1.4209 us/op 1.82
toHexString serialized data 1.8208 us/op 1.0722 us/op 1.70
Buffer.toString(base64) 291.03 ns/op 205.91 ns/op 1.41

by benchmarkbot/action

Copy link

codecov bot commented Apr 18, 2024

Codecov Report

Merging #6687 (733881c) into unstable (252fd2f) will not change coverage.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff            @@
##           unstable    #6687   +/-   ##
=========================================
  Coverage     61.80%   61.80%           
=========================================
  Files           556      556           
  Lines         59103    59103           
  Branches       1898     1898           
=========================================
  Hits          36526    36526           
  Misses        22534    22534           
  Partials         43       43           

@nflaig nflaig merged commit a3cb2cd into unstable Apr 19, 2024
20 checks passed
@nflaig nflaig deleted the nflaig/statev2-no-copy branch April 19, 2024 07:45
@nflaig nflaig mentioned this pull request Apr 19, 2024
@wemeetagain
Copy link
Member

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

3 participants