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: allocate shared buffer at runtime to fix browser compatibility #7023

Closed
wants to merge 1 commit into from

Conversation

nflaig
Copy link
Member

@nflaig nflaig commented Aug 14, 2024

Motivation

In #7016 we added a shared buffer which is allocated at load time in the utils packages. This is problematic as it breaks browser compatibility if Buffer is not polyfilled for every package that imports @lodestar/utils which is pretty much all of our packages.

Description

Allocate shared buffer at runtime to avoid running into ReferenceError: Buffer is not defined when importing utils packages in a browser environment without polyfills.

@nflaig nflaig requested a review from a team as a code owner August 14, 2024 08:59
Copy link

codecov bot commented Aug 14, 2024

Codecov Report

Attention: Patch coverage is 25.00000% with 3 lines in your changes missing coverage. Please review.

Project coverage is 49.23%. Comparing base (44b2156) to head (8063ac7).
Report is 1 commits behind head on unstable.

Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #7023      +/-   ##
============================================
- Coverage     49.24%   49.23%   -0.01%     
============================================
  Files           578      578              
  Lines         37438    37441       +3     
  Branches       2162     2162              
============================================
  Hits          18435    18435              
- Misses        18963    18966       +3     
  Partials         40       40              

Copy link
Contributor

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: d5c779a Previous: 44b2156 Ratio
getPubkeys - index2pubkey - req 1000 vs - 250000 vc 1.8320 ms/op 1.9590 ms/op 0.94
getPubkeys - validatorsArr - req 1000 vs - 250000 vc 51.045 us/op 46.281 us/op 1.10
BLS verify - blst 863.17 us/op 972.89 us/op 0.89
BLS verifyMultipleSignatures 3 - blst 1.2835 ms/op 1.3127 ms/op 0.98
BLS verifyMultipleSignatures 8 - blst 1.7063 ms/op 2.7331 ms/op 0.62
BLS verifyMultipleSignatures 32 - blst 5.2814 ms/op 5.7513 ms/op 0.92
BLS verifyMultipleSignatures 64 - blst 9.3223 ms/op 10.740 ms/op 0.87
BLS verifyMultipleSignatures 128 - blst 18.438 ms/op 17.450 ms/op 1.06
BLS deserializing 10000 signatures 694.06 ms/op 685.81 ms/op 1.01
BLS deserializing 100000 signatures 6.8862 s/op 6.7876 s/op 1.01
BLS verifyMultipleSignatures - same message - 3 - blst 837.32 us/op 989.51 us/op 0.85
BLS verifyMultipleSignatures - same message - 8 - blst 988.05 us/op 1.1029 ms/op 0.90
BLS verifyMultipleSignatures - same message - 32 - blst 1.6572 ms/op 1.7297 ms/op 0.96
BLS verifyMultipleSignatures - same message - 64 - blst 2.5185 ms/op 2.6244 ms/op 0.96
BLS verifyMultipleSignatures - same message - 128 - blst 4.2433 ms/op 4.4438 ms/op 0.95
BLS aggregatePubkeys 32 - blst 19.538 us/op 20.411 us/op 0.96
BLS aggregatePubkeys 128 - blst 69.073 us/op 70.806 us/op 0.98
notSeenSlots=1 numMissedVotes=1 numBadVotes=10 54.251 ms/op 55.740 ms/op 0.97
notSeenSlots=1 numMissedVotes=0 numBadVotes=4 53.328 ms/op 58.814 ms/op 0.91
notSeenSlots=2 numMissedVotes=1 numBadVotes=10 36.655 ms/op 43.064 ms/op 0.85
getSlashingsAndExits - default max 140.79 us/op 102.27 us/op 1.38
getSlashingsAndExits - 2k 413.24 us/op 315.71 us/op 1.31
proposeBlockBody type=full, size=empty 6.7937 ms/op 5.9005 ms/op 1.15
isKnown best case - 1 super set check 573.00 ns/op 344.00 ns/op 1.67
isKnown normal case - 2 super set checks 637.00 ns/op 305.00 ns/op 2.09
isKnown worse case - 16 super set checks 632.00 ns/op 304.00 ns/op 2.08
InMemoryCheckpointStateCache - add get delete 3.6950 us/op 3.5060 us/op 1.05
validate api signedAggregateAndProof - struct 1.5649 ms/op 1.4184 ms/op 1.10
validate gossip signedAggregateAndProof - struct 1.5232 ms/op 1.4589 ms/op 1.04
validate gossip attestation - vc 640000 1.0838 ms/op 1.0471 ms/op 1.04
batch validate gossip attestation - vc 640000 - chunk 32 154.05 us/op 135.04 us/op 1.14
batch validate gossip attestation - vc 640000 - chunk 64 132.38 us/op 116.85 us/op 1.13
batch validate gossip attestation - vc 640000 - chunk 128 131.37 us/op 106.93 us/op 1.23
batch validate gossip attestation - vc 640000 - chunk 256 130.42 us/op 102.59 us/op 1.27
pickEth1Vote - no votes 1.3270 ms/op 1.0423 ms/op 1.27
pickEth1Vote - max votes 11.827 ms/op 10.840 ms/op 1.09
pickEth1Vote - Eth1Data hashTreeRoot value x2048 19.051 ms/op 16.639 ms/op 1.15
pickEth1Vote - Eth1Data hashTreeRoot tree x2048 22.937 ms/op 25.490 ms/op 0.90
pickEth1Vote - Eth1Data fastSerialize value x2048 659.58 us/op 497.20 us/op 1.33
pickEth1Vote - Eth1Data fastSerialize tree x2048 5.3427 ms/op 7.2266 ms/op 0.74
bytes32 toHexString 656.00 ns/op 426.00 ns/op 1.54
bytes32 Buffer.toString(hex) 299.00 ns/op 248.00 ns/op 1.21
bytes32 Buffer.toString(hex) from Uint8Array 502.00 ns/op 394.00 ns/op 1.27
bytes32 Buffer.toString(hex) + 0x 291.00 ns/op 252.00 ns/op 1.15
Object access 1 prop 0.21800 ns/op 0.12500 ns/op 1.74
Map access 1 prop 0.14900 ns/op 0.12200 ns/op 1.22
Object get x1000 6.1220 ns/op 5.8060 ns/op 1.05
Map get x1000 6.6250 ns/op 6.2710 ns/op 1.06
Object set x1000 38.506 ns/op 31.958 ns/op 1.20
Map set x1000 24.694 ns/op 21.484 ns/op 1.15
Return object 10000 times 0.29900 ns/op 0.28620 ns/op 1.04
Throw Error 10000 times 3.3878 us/op 3.2846 us/op 1.03
toHex 171.88 ns/op 149.60 ns/op 1.15
Buffer.from 139.43 ns/op 138.10 ns/op 1.01
shared Buffer 92.474 ns/op 92.252 ns/op 1.00
fastMsgIdFn sha256 / 200 bytes 2.3680 us/op 2.1690 us/op 1.09
fastMsgIdFn h32 xxhash / 200 bytes 248.00 ns/op 229.00 ns/op 1.08
fastMsgIdFn h64 xxhash / 200 bytes 289.00 ns/op 276.00 ns/op 1.05
fastMsgIdFn sha256 / 1000 bytes 7.4060 us/op 7.1800 us/op 1.03
fastMsgIdFn h32 xxhash / 1000 bytes 412.00 ns/op 348.00 ns/op 1.18
fastMsgIdFn h64 xxhash / 1000 bytes 365.00 ns/op 338.00 ns/op 1.08
fastMsgIdFn sha256 / 10000 bytes 66.425 us/op 63.259 us/op 1.05
fastMsgIdFn h32 xxhash / 10000 bytes 1.9600 us/op 1.7750 us/op 1.10
fastMsgIdFn h64 xxhash / 10000 bytes 1.2760 us/op 1.1840 us/op 1.08
send data - 1000 256B messages 13.448 ms/op 13.083 ms/op 1.03
send data - 1000 512B messages 16.723 ms/op 16.863 ms/op 0.99
send data - 1000 1024B messages 25.442 ms/op 25.975 ms/op 0.98
send data - 1000 1200B messages 19.131 ms/op 27.766 ms/op 0.69
send data - 1000 2048B messages 32.652 ms/op 32.313 ms/op 1.01
send data - 1000 4096B messages 32.772 ms/op 31.138 ms/op 1.05
send data - 1000 16384B messages 70.766 ms/op 73.084 ms/op 0.97
send data - 1000 65536B messages 222.69 ms/op 216.93 ms/op 1.03
enrSubnets - fastDeserialize 64 bits 1.2390 us/op 1.0440 us/op 1.19
enrSubnets - ssz BitVector 64 bits 451.00 ns/op 351.00 ns/op 1.28
enrSubnets - fastDeserialize 4 bits 166.00 ns/op 149.00 ns/op 1.11
enrSubnets - ssz BitVector 4 bits 362.00 ns/op 359.00 ns/op 1.01
prioritizePeers score -10:0 att 32-0.1 sync 2-0 145.39 us/op 142.12 us/op 1.02
prioritizePeers score 0:0 att 32-0.25 sync 2-0.25 155.61 us/op 157.14 us/op 0.99
prioritizePeers score 0:0 att 32-0.5 sync 2-0.5 255.40 us/op 317.74 us/op 0.80
prioritizePeers score 0:0 att 64-0.75 sync 4-0.75 398.12 us/op 598.86 us/op 0.66
prioritizePeers score 0:0 att 64-1 sync 4-1 596.53 us/op 786.92 us/op 0.76
array of 16000 items push then shift 1.6221 us/op 1.5993 us/op 1.01
LinkedList of 16000 items push then shift 6.9420 ns/op 6.9320 ns/op 1.00
array of 16000 items push then pop 115.79 ns/op 103.37 ns/op 1.12
LinkedList of 16000 items push then pop 6.8740 ns/op 6.8100 ns/op 1.01
array of 24000 items push then shift 2.3637 us/op 2.3516 us/op 1.01
LinkedList of 24000 items push then shift 6.9990 ns/op 6.9940 ns/op 1.00
array of 24000 items push then pop 148.23 ns/op 132.45 ns/op 1.12
LinkedList of 24000 items push then pop 7.3820 ns/op 6.7780 ns/op 1.09
intersect bitArray bitLen 8 6.2970 ns/op 6.2410 ns/op 1.01
intersect array and set length 8 51.557 ns/op 42.565 ns/op 1.21
intersect bitArray bitLen 128 30.028 ns/op 29.270 ns/op 1.03
intersect array and set length 128 724.60 ns/op 640.68 ns/op 1.13
bitArray.getTrueBitIndexes() bitLen 128 2.0200 us/op 2.1120 us/op 0.96
bitArray.getTrueBitIndexes() bitLen 248 2.9380 us/op 3.9030 us/op 0.75
bitArray.getTrueBitIndexes() bitLen 512 6.2410 us/op 9.1720 us/op 0.68
Buffer.concat 32 items 957.00 ns/op 1.0040 us/op 0.95
Uint8Array.set 32 items 2.1770 us/op 1.5180 us/op 1.43
Buffer.copy 2.1070 us/op 1.7540 us/op 1.20
Uint8Array.set - with subarray 2.7420 us/op 2.4750 us/op 1.11
Uint8Array.set - without subarray 2.2000 us/op 1.3820 us/op 1.59
getUint32 - dataview 247.00 ns/op 220.00 ns/op 1.12
getUint32 - manual 185.00 ns/op 149.00 ns/op 1.24
Set add up to 64 items then delete first 2.4231 us/op 2.1145 us/op 1.15
OrderedSet add up to 64 items then delete first 3.3894 us/op 3.2732 us/op 1.04
Set add up to 64 items then delete last 2.5863 us/op 2.4122 us/op 1.07
OrderedSet add up to 64 items then delete last 3.8235 us/op 3.5126 us/op 1.09
Set add up to 64 items then delete middle 2.6158 us/op 2.4670 us/op 1.06
OrderedSet add up to 64 items then delete middle 5.2463 us/op 5.0407 us/op 1.04
Set add up to 128 items then delete first 5.3573 us/op 5.0045 us/op 1.07
OrderedSet add up to 128 items then delete first 8.1109 us/op 7.5310 us/op 1.08
Set add up to 128 items then delete last 5.1292 us/op 4.8128 us/op 1.07
OrderedSet add up to 128 items then delete last 7.8588 us/op 7.0736 us/op 1.11
Set add up to 128 items then delete middle 5.4775 us/op 4.7660 us/op 1.15
OrderedSet add up to 128 items then delete middle 14.676 us/op 13.204 us/op 1.11
Set add up to 256 items then delete first 12.189 us/op 10.331 us/op 1.18
OrderedSet add up to 256 items then delete first 16.571 us/op 15.525 us/op 1.07
Set add up to 256 items then delete last 10.438 us/op 9.8579 us/op 1.06
OrderedSet add up to 256 items then delete last 15.845 us/op 14.068 us/op 1.13
Set add up to 256 items then delete middle 10.081 us/op 9.4902 us/op 1.06
OrderedSet add up to 256 items then delete middle 41.067 us/op 39.828 us/op 1.03
transfer serialized Status (84 B) 1.5290 us/op 1.3250 us/op 1.15
copy serialized Status (84 B) 1.2910 us/op 1.0660 us/op 1.21
transfer serialized SignedVoluntaryExit (112 B) 1.8050 us/op 1.4030 us/op 1.29
copy serialized SignedVoluntaryExit (112 B) 1.3830 us/op 1.1030 us/op 1.25
transfer serialized ProposerSlashing (416 B) 2.4130 us/op 1.6410 us/op 1.47
copy serialized ProposerSlashing (416 B) 2.7440 us/op 1.6440 us/op 1.67
transfer serialized Attestation (485 B) 2.6600 us/op 1.6110 us/op 1.65
copy serialized Attestation (485 B) 2.7590 us/op 1.7570 us/op 1.57
transfer serialized AttesterSlashing (33232 B) 3.0970 us/op 2.2900 us/op 1.35
copy serialized AttesterSlashing (33232 B) 6.9740 us/op 4.9120 us/op 1.42
transfer serialized Small SignedBeaconBlock (128000 B) 3.8170 us/op 2.4640 us/op 1.55
copy serialized Small SignedBeaconBlock (128000 B) 24.594 us/op 13.920 us/op 1.77
transfer serialized Avg SignedBeaconBlock (200000 B) 4.4620 us/op 2.8700 us/op 1.55
copy serialized Avg SignedBeaconBlock (200000 B) 29.280 us/op 21.493 us/op 1.36
transfer serialized BlobsSidecar (524380 B) 4.2270 us/op 3.8550 us/op 1.10
copy serialized BlobsSidecar (524380 B) 113.88 us/op 83.281 us/op 1.37
transfer serialized Big SignedBeaconBlock (1000000 B) 3.8120 us/op 3.7640 us/op 1.01
copy serialized Big SignedBeaconBlock (1000000 B) 171.32 us/op 349.45 us/op 0.49
pass gossip attestations to forkchoice per slot 2.8465 ms/op 2.7715 ms/op 1.03
forkChoice updateHead vc 100000 bc 64 eq 0 496.71 us/op 491.62 us/op 1.01
forkChoice updateHead vc 600000 bc 64 eq 0 3.0642 ms/op 3.1007 ms/op 0.99
forkChoice updateHead vc 1000000 bc 64 eq 0 5.1841 ms/op 5.2833 ms/op 0.98
forkChoice updateHead vc 600000 bc 320 eq 0 3.8645 ms/op 3.0324 ms/op 1.27
forkChoice updateHead vc 600000 bc 1200 eq 0 3.1942 ms/op 3.0453 ms/op 1.05
forkChoice updateHead vc 600000 bc 7200 eq 0 3.7840 ms/op 3.4924 ms/op 1.08
forkChoice updateHead vc 600000 bc 64 eq 1000 10.604 ms/op 10.571 ms/op 1.00
forkChoice updateHead vc 600000 bc 64 eq 10000 10.720 ms/op 10.549 ms/op 1.02
forkChoice updateHead vc 600000 bc 64 eq 300000 15.007 ms/op 15.234 ms/op 0.99
computeDeltas 500000 validators 300 proto nodes 3.6963 ms/op 3.4841 ms/op 1.06
computeDeltas 500000 validators 1200 proto nodes 3.7847 ms/op 3.5321 ms/op 1.07
computeDeltas 500000 validators 7200 proto nodes 3.8658 ms/op 3.4393 ms/op 1.12
computeDeltas 750000 validators 300 proto nodes 5.7492 ms/op 5.2497 ms/op 1.10
computeDeltas 750000 validators 1200 proto nodes 6.7012 ms/op 5.2264 ms/op 1.28
computeDeltas 750000 validators 7200 proto nodes 6.8957 ms/op 5.2975 ms/op 1.30
computeDeltas 1400000 validators 300 proto nodes 12.674 ms/op 10.045 ms/op 1.26
computeDeltas 1400000 validators 1200 proto nodes 11.881 ms/op 10.169 ms/op 1.17
computeDeltas 1400000 validators 7200 proto nodes 14.004 ms/op 10.195 ms/op 1.37
computeDeltas 2100000 validators 300 proto nodes 18.714 ms/op 15.281 ms/op 1.22
computeDeltas 2100000 validators 1200 proto nodes 19.078 ms/op 15.428 ms/op 1.24
computeDeltas 2100000 validators 7200 proto nodes 16.634 ms/op 15.570 ms/op 1.07
altair processAttestation - 250000 vs - 7PWei normalcase 2.0996 ms/op 1.9685 ms/op 1.07
altair processAttestation - 250000 vs - 7PWei worstcase 3.9368 ms/op 2.7677 ms/op 1.42
altair processAttestation - setStatus - 1/6 committees join 128.84 us/op 124.56 us/op 1.03
altair processAttestation - setStatus - 1/3 committees join 219.15 us/op 237.98 us/op 0.92
altair processAttestation - setStatus - 1/2 committees join 312.93 us/op 332.55 us/op 0.94
altair processAttestation - setStatus - 2/3 committees join 358.98 us/op 423.52 us/op 0.85
altair processAttestation - setStatus - 4/5 committees join 596.13 us/op 567.68 us/op 1.05
altair processAttestation - setStatus - 100% committees join 660.05 us/op 672.15 us/op 0.98
altair processBlock - 250000 vs - 7PWei normalcase 4.9481 ms/op 4.8210 ms/op 1.03
altair processBlock - 250000 vs - 7PWei normalcase hashState 29.070 ms/op 27.050 ms/op 1.07
altair processBlock - 250000 vs - 7PWei worstcase 39.967 ms/op 46.701 ms/op 0.86
altair processBlock - 250000 vs - 7PWei worstcase hashState 89.497 ms/op 73.121 ms/op 1.22
phase0 processBlock - 250000 vs - 7PWei normalcase 2.3047 ms/op 2.3527 ms/op 0.98
phase0 processBlock - 250000 vs - 7PWei worstcase 24.004 ms/op 25.684 ms/op 0.93
altair processEth1Data - 250000 vs - 7PWei normalcase 354.79 us/op 297.75 us/op 1.19
getExpectedWithdrawals 250000 eb:1,eth1:1,we:0,wn:0,smpl:15 8.4340 us/op 6.8080 us/op 1.24
getExpectedWithdrawals 250000 eb:0.95,eth1:0.1,we:0.05,wn:0,smpl:219 34.946 us/op 26.253 us/op 1.33
getExpectedWithdrawals 250000 eb:0.95,eth1:0.3,we:0.05,wn:0,smpl:42 13.233 us/op 11.352 us/op 1.17
getExpectedWithdrawals 250000 eb:0.95,eth1:0.7,we:0.05,wn:0,smpl:18 8.3170 us/op 5.5820 us/op 1.49
getExpectedWithdrawals 250000 eb:0.1,eth1:0.1,we:0,wn:0,smpl:1020 128.43 us/op 132.47 us/op 0.97
getExpectedWithdrawals 250000 eb:0.03,eth1:0.03,we:0,wn:0,smpl:11777 742.78 us/op 764.77 us/op 0.97
getExpectedWithdrawals 250000 eb:0.01,eth1:0.01,we:0,wn:0,smpl:16384 1.0480 ms/op 1.6529 ms/op 0.63
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,smpl:16384 1.0904 ms/op 1.1007 ms/op 0.99
getExpectedWithdrawals 250000 eb:0,eth1:0,we:0,wn:0,nocache,smpl:16384 3.3229 ms/op 2.5217 ms/op 1.32
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,smpl:16384 1.8686 ms/op 1.7969 ms/op 1.04
getExpectedWithdrawals 250000 eb:0,eth1:1,we:0,wn:0,nocache,smpl:16384 5.5987 ms/op 3.9080 ms/op 1.43
Tree 40 250000 create 655.48 ms/op 243.07 ms/op 2.70
Tree 40 250000 get(125000) 220.81 ns/op 148.78 ns/op 1.48
Tree 40 250000 set(125000) 2.5576 us/op 664.33 ns/op 3.85
Tree 40 250000 toArray() 29.108 ms/op 15.686 ms/op 1.86
Tree 40 250000 iterate all - toArray() + loop 24.614 ms/op 15.308 ms/op 1.61
Tree 40 250000 iterate all - get(i) 76.937 ms/op 52.357 ms/op 1.47
MutableVector 250000 create 17.867 ms/op 11.139 ms/op 1.60
MutableVector 250000 get(125000) 7.0030 ns/op 6.9560 ns/op 1.01
MutableVector 250000 set(125000) 681.03 ns/op 198.96 ns/op 3.42
MutableVector 250000 toArray() 6.3804 ms/op 3.7430 ms/op 1.70
MutableVector 250000 iterate all - toArray() + loop 6.2359 ms/op 3.7670 ms/op 1.66
MutableVector 250000 iterate all - get(i) 1.7167 ms/op 1.6276 ms/op 1.05
Array 250000 create 5.4037 ms/op 3.1830 ms/op 1.70
Array 250000 clone - spread 5.3296 ms/op 1.4801 ms/op 3.60
Array 250000 get(125000) 0.47900 ns/op 0.40200 ns/op 1.19
Array 250000 set(125000) 0.48600 ns/op 0.42500 ns/op 1.14
Array 250000 iterate all - loop 120.38 us/op 81.543 us/op 1.48
effectiveBalanceIncrements clone Uint8Array 300000 88.256 us/op 31.396 us/op 2.81
effectiveBalanceIncrements clone MutableVector 300000 147.00 ns/op 117.00 ns/op 1.26
effectiveBalanceIncrements rw all Uint8Array 300000 217.79 us/op 196.67 us/op 1.11
effectiveBalanceIncrements rw all MutableVector 300000 127.02 ms/op 65.295 ms/op 1.95
phase0 afterProcessEpoch - 250000 vs - 7PWei 103.88 ms/op 84.627 ms/op 1.23
Array.fill - length 1000000 9.0593 ms/op 3.6730 ms/op 2.47
Array push - length 1000000 30.242 ms/op 16.914 ms/op 1.79
Array.get 0.36709 ns/op 0.27006 ns/op 1.36
Uint8Array.get 0.52646 ns/op 0.43547 ns/op 1.21
phase0 beforeProcessEpoch - 250000 vs - 7PWei 28.123 ms/op 15.012 ms/op 1.87
altair processEpoch - mainnet_e81889 382.34 ms/op 358.06 ms/op 1.07
mainnet_e81889 - altair beforeProcessEpoch 19.808 ms/op 18.362 ms/op 1.08
mainnet_e81889 - altair processJustificationAndFinalization 17.572 us/op 12.903 us/op 1.36
mainnet_e81889 - altair processInactivityUpdates 7.1995 ms/op 5.3351 ms/op 1.35
mainnet_e81889 - altair processRewardsAndPenalties 38.751 ms/op 61.537 ms/op 0.63
mainnet_e81889 - altair processRegistryUpdates 2.1490 us/op 3.1440 us/op 0.68
mainnet_e81889 - altair processSlashings 576.00 ns/op 653.00 ns/op 0.88
mainnet_e81889 - altair processEth1DataReset 348.00 ns/op 991.00 ns/op 0.35
mainnet_e81889 - altair processEffectiveBalanceUpdates 1.2232 ms/op 1.9234 ms/op 0.64
mainnet_e81889 - altair processSlashingsReset 3.0340 us/op 5.7890 us/op 0.52
mainnet_e81889 - altair processRandaoMixesReset 4.5480 us/op 6.8030 us/op 0.67
mainnet_e81889 - altair processHistoricalRootsUpdate 513.00 ns/op 829.00 ns/op 0.62
mainnet_e81889 - altair processParticipationFlagUpdates 1.9990 us/op 2.7740 us/op 0.72
mainnet_e81889 - altair processSyncCommitteeUpdates 376.00 ns/op 692.00 ns/op 0.54
mainnet_e81889 - altair afterProcessEpoch 98.780 ms/op 95.585 ms/op 1.03
capella processEpoch - mainnet_e217614 1.1717 s/op 1.1978 s/op 0.98
mainnet_e217614 - capella beforeProcessEpoch 69.648 ms/op 69.947 ms/op 1.00
mainnet_e217614 - capella processJustificationAndFinalization 15.466 us/op 22.334 us/op 0.69
mainnet_e217614 - capella processInactivityUpdates 17.947 ms/op 17.669 ms/op 1.02
mainnet_e217614 - capella processRewardsAndPenalties 227.20 ms/op 285.62 ms/op 0.80
mainnet_e217614 - capella processRegistryUpdates 11.955 us/op 18.388 us/op 0.65
mainnet_e217614 - capella processSlashings 538.00 ns/op 518.00 ns/op 1.04
mainnet_e217614 - capella processEth1DataReset 297.00 ns/op 549.00 ns/op 0.54
mainnet_e217614 - capella processEffectiveBalanceUpdates 10.239 ms/op 11.979 ms/op 0.85
mainnet_e217614 - capella processSlashingsReset 3.0870 us/op 5.2060 us/op 0.59
mainnet_e217614 - capella processRandaoMixesReset 4.2980 us/op 6.7850 us/op 0.63
mainnet_e217614 - capella processHistoricalRootsUpdate 728.00 ns/op 544.00 ns/op 1.34
mainnet_e217614 - capella processParticipationFlagUpdates 2.1290 us/op 2.5870 us/op 0.82
mainnet_e217614 - capella afterProcessEpoch 242.11 ms/op 234.39 ms/op 1.03
phase0 processEpoch - mainnet_e58758 432.26 ms/op 441.84 ms/op 0.98
mainnet_e58758 - phase0 beforeProcessEpoch 78.355 ms/op 93.381 ms/op 0.84
mainnet_e58758 - phase0 processJustificationAndFinalization 15.485 us/op 21.817 us/op 0.71
mainnet_e58758 - phase0 processRewardsAndPenalties 36.578 ms/op 39.237 ms/op 0.93
mainnet_e58758 - phase0 processRegistryUpdates 7.8520 us/op 11.394 us/op 0.69
mainnet_e58758 - phase0 processSlashings 324.00 ns/op 527.00 ns/op 0.61
mainnet_e58758 - phase0 processEth1DataReset 343.00 ns/op 546.00 ns/op 0.63
mainnet_e58758 - phase0 processEffectiveBalanceUpdates 935.89 us/op 2.6070 ms/op 0.36
mainnet_e58758 - phase0 processSlashingsReset 3.0590 us/op 3.2090 us/op 0.95
mainnet_e58758 - phase0 processRandaoMixesReset 4.4320 us/op 5.9460 us/op 0.75
mainnet_e58758 - phase0 processHistoricalRootsUpdate 334.00 ns/op 921.00 ns/op 0.36
mainnet_e58758 - phase0 processParticipationRecordUpdates 4.1960 us/op 3.3200 us/op 1.26
mainnet_e58758 - phase0 afterProcessEpoch 88.067 ms/op 77.279 ms/op 1.14
phase0 processEffectiveBalanceUpdates - 250000 normalcase 1.8025 ms/op 1.0979 ms/op 1.64
phase0 processEffectiveBalanceUpdates - 250000 worstcase 0.5 1.6782 ms/op 1.9427 ms/op 0.86
altair processInactivityUpdates - 250000 normalcase 15.211 ms/op 23.879 ms/op 0.64
altair processInactivityUpdates - 250000 worstcase 15.219 ms/op 25.791 ms/op 0.59
phase0 processRegistryUpdates - 250000 normalcase 7.1410 us/op 9.8920 us/op 0.72
phase0 processRegistryUpdates - 250000 badcase_full_deposits 288.16 us/op 456.79 us/op 0.63
phase0 processRegistryUpdates - 250000 worstcase 0.5 108.67 ms/op 129.33 ms/op 0.84
altair processRewardsAndPenalties - 250000 normalcase 39.005 ms/op 48.382 ms/op 0.81
altair processRewardsAndPenalties - 250000 worstcase 39.855 ms/op 54.469 ms/op 0.73
phase0 getAttestationDeltas - 250000 normalcase 7.9618 ms/op 7.4189 ms/op 1.07
phase0 getAttestationDeltas - 250000 worstcase 7.8363 ms/op 7.3482 ms/op 1.07
phase0 processSlashings - 250000 worstcase 87.326 us/op 123.14 us/op 0.71
altair processSyncCommitteeUpdates - 250000 118.55 ms/op 118.07 ms/op 1.00
BeaconState.hashTreeRoot - No change 234.00 ns/op 267.00 ns/op 0.88
BeaconState.hashTreeRoot - 1 full validator 137.26 us/op 113.22 us/op 1.21
BeaconState.hashTreeRoot - 32 full validator 1.3110 ms/op 1.2300 ms/op 1.07
BeaconState.hashTreeRoot - 512 full validator 10.522 ms/op 12.822 ms/op 0.82
BeaconState.hashTreeRoot - 1 validator.effectiveBalance 137.75 us/op 138.79 us/op 0.99
BeaconState.hashTreeRoot - 32 validator.effectiveBalance 1.7945 ms/op 2.0273 ms/op 0.89
BeaconState.hashTreeRoot - 512 validator.effectiveBalance 24.714 ms/op 29.670 ms/op 0.83
BeaconState.hashTreeRoot - 1 balances 100.41 us/op 110.39 us/op 0.91
BeaconState.hashTreeRoot - 32 balances 952.47 us/op 1.3334 ms/op 0.71
BeaconState.hashTreeRoot - 512 balances 11.630 ms/op 9.6819 ms/op 1.20
BeaconState.hashTreeRoot - 250000 balances 149.26 ms/op 168.89 ms/op 0.88
aggregationBits - 2048 els - zipIndexesInBitList 22.499 us/op 24.670 us/op 0.91
byteArrayEquals 32 53.024 ns/op 55.393 ns/op 0.96
Buffer.compare 32 18.598 ns/op 17.623 ns/op 1.06
byteArrayEquals 1024 1.5646 us/op 1.6149 us/op 0.97
Buffer.compare 1024 25.378 ns/op 26.333 ns/op 0.96
byteArrayEquals 16384 24.898 us/op 25.928 us/op 0.96
Buffer.compare 16384 207.97 ns/op 196.81 ns/op 1.06
byteArrayEquals 123687377 186.91 ms/op 192.16 ms/op 0.97
Buffer.compare 123687377 6.5097 ms/op 6.1811 ms/op 1.05
byteArrayEquals 32 - diff last byte 52.360 ns/op 53.257 ns/op 0.98
Buffer.compare 32 - diff last byte 17.558 ns/op 17.353 ns/op 1.01
byteArrayEquals 1024 - diff last byte 1.5754 us/op 1.5961 us/op 0.99
Buffer.compare 1024 - diff last byte 25.992 ns/op 26.226 ns/op 0.99
byteArrayEquals 16384 - diff last byte 25.140 us/op 25.399 us/op 0.99
Buffer.compare 16384 - diff last byte 190.93 ns/op 208.86 ns/op 0.91
byteArrayEquals 123687377 - diff last byte 193.36 ms/op 191.68 ms/op 1.01
Buffer.compare 123687377 - diff last byte 7.2581 ms/op 6.1438 ms/op 1.18
byteArrayEquals 32 - random bytes 5.2940 ns/op 5.1040 ns/op 1.04
Buffer.compare 32 - random bytes 17.988 ns/op 16.991 ns/op 1.06
byteArrayEquals 1024 - random bytes 5.2410 ns/op 5.1500 ns/op 1.02
Buffer.compare 1024 - random bytes 18.208 ns/op 17.502 ns/op 1.04
byteArrayEquals 16384 - random bytes 5.6680 ns/op 5.0370 ns/op 1.13
Buffer.compare 16384 - random bytes 18.324 ns/op 16.960 ns/op 1.08
byteArrayEquals 123687377 - random bytes 6.5100 ns/op 6.3600 ns/op 1.02
Buffer.compare 123687377 - random bytes 19.320 ns/op 18.220 ns/op 1.06
regular array get 100000 times 44.763 us/op 32.536 us/op 1.38
wrappedArray get 100000 times 33.545 us/op 32.851 us/op 1.02
arrayWithProxy get 100000 times 14.144 ms/op 13.980 ms/op 1.01
ssz.Root.equals 46.590 ns/op 46.153 ns/op 1.01
byteArrayEquals 45.791 ns/op 45.727 ns/op 1.00
Buffer.compare 11.494 ns/op 10.454 ns/op 1.10
shuffle list - 16384 els 6.1352 ms/op 6.3395 ms/op 0.97
shuffle list - 250000 els 91.145 ms/op 92.764 ms/op 0.98
processSlot - 1 slots 14.405 us/op 13.748 us/op 1.05
processSlot - 32 slots 2.4843 ms/op 3.0642 ms/op 0.81
getEffectiveBalanceIncrementsZeroInactive - 250000 vs - 7PWei 37.526 ms/op 43.314 ms/op 0.87
getCommitteeAssignments - req 1 vs - 250000 vc 2.1722 ms/op 2.1050 ms/op 1.03
getCommitteeAssignments - req 100 vs - 250000 vc 4.1561 ms/op 4.0806 ms/op 1.02
getCommitteeAssignments - req 1000 vs - 250000 vc 4.4566 ms/op 4.3683 ms/op 1.02
findModifiedValidators - 10000 modified validators 243.73 ms/op 228.82 ms/op 1.07
findModifiedValidators - 1000 modified validators 187.75 ms/op 161.53 ms/op 1.16
findModifiedValidators - 100 modified validators 160.69 ms/op 138.52 ms/op 1.16
findModifiedValidators - 10 modified validators 194.21 ms/op 132.32 ms/op 1.47
findModifiedValidators - 1 modified validators 161.57 ms/op 142.52 ms/op 1.13
findModifiedValidators - no difference 169.61 ms/op 144.40 ms/op 1.17
compare ViewDUs 3.0222 s/op 3.0804 s/op 0.98
compare each validator Uint8Array 1.3838 s/op 1.6767 s/op 0.83
compare ViewDU to Uint8Array 1.2964 s/op 958.97 ms/op 1.35
migrate state 1000000 validators, 24 modified, 0 new 694.64 ms/op 633.30 ms/op 1.10
migrate state 1000000 validators, 1700 modified, 1000 new 1.0817 s/op 913.31 ms/op 1.18
migrate state 1000000 validators, 3400 modified, 2000 new 1.2948 s/op 1.0948 s/op 1.18
migrate state 1500000 validators, 24 modified, 0 new 785.36 ms/op 643.59 ms/op 1.22
migrate state 1500000 validators, 1700 modified, 1000 new 936.87 ms/op 909.21 ms/op 1.03
migrate state 1500000 validators, 3400 modified, 2000 new 1.0237 s/op 1.0869 s/op 0.94
RootCache.getBlockRootAtSlot - 250000 vs - 7PWei 4.9400 ns/op 4.4100 ns/op 1.12
state getBlockRootAtSlot - 250000 vs - 7PWei 589.99 ns/op 793.31 ns/op 0.74
computeProposers - vc 250000 7.7333 ms/op 7.4416 ms/op 1.04
computeEpochShuffling - vc 250000 94.719 ms/op 90.245 ms/op 1.05
getNextSyncCommittee - vc 250000 123.08 ms/op 120.26 ms/op 1.02
computeSigningRoot for AttestationData 17.627 us/op 25.671 us/op 0.69
hash AttestationData serialized data then Buffer.toString(base64) 1.6081 us/op 1.5348 us/op 1.05
toHexString serialized data 913.47 ns/op 876.45 ns/op 1.04
Buffer.toString(base64) 185.64 ns/op 182.29 ns/op 1.02
block root to RootHex using toHex 164.87 ns/op 137.33 ns/op 1.20
block root to RootHex using toRootHex 99.792 ns/op 95.156 ns/op 1.05

by benchmarkbot/action

@twoeths
Copy link
Contributor

twoeths commented Aug 15, 2024

I prefer having a new export @lodestar/utils/nodejs for nodejs specific utils so it'll not affect browser and we don't need to handle nodejs specific code in each of the util

@nflaig
Copy link
Member Author

nflaig commented Aug 15, 2024

I prefer having a new export @lodestar/utils/nodejs for nodejs specific utils so it'll not affect browser and we don't need to handle nodejs specific code in each of the util

We can make it similar to api package which has /server, it is probably the best long-term solution

@nflaig nflaig closed this Aug 15, 2024
@nflaig nflaig deleted the nflaig/runtime-buffer-alloc branch August 15, 2024 20:42
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