Skip to content

Conversation

nazarhussain
Copy link
Contributor

Motivation

Improve the performance of lead node creation during the packing values.

Description

  • Initialize primitive values instead of LeafNode object
  • Create the LeftNode object once with those values.

Based on the work started in this PR #493

Steps to test or reproduce

Run all tests.

ChefBingbong and others added 6 commits August 13, 2025 20:09
* fix: optimise duplicate writing in leafnode creation

* chore: apply same temp array rewriting in packedUintNum64sToLeafNodes

* chore: only anntend to specific dev comment before feedback
Copy link

github-actions bot commented Aug 13, 2025

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 023ffa2 Previous: 7f0eccc Ratio
digestTwoHashObjects 50023 times 48.226 ms/op 47.900 ms/op 1.01
digest2Bytes32 50023 times 55.000 ms/op 54.834 ms/op 1.00
digest 50023 times 53.931 ms/op 52.622 ms/op 1.02
input length 32 1.2500 us/op 1.2030 us/op 1.04
input length 64 1.3770 us/op 1.3360 us/op 1.03
input length 128 2.3140 us/op 2.2780 us/op 1.02
input length 256 3.4860 us/op 3.4290 us/op 1.02
input length 512 5.6410 us/op 5.5680 us/op 1.01
input length 1024 10.781 us/op 10.656 us/op 1.01
digest 1000000 times 858.02 ms/op 845.08 ms/op 1.02
hashObjectToByteArray 50023 times 934.37 us/op 935.09 us/op 1.00
byteArrayToHashObject 50023 times 1.3277 ms/op 1.3176 ms/op 1.01
digest64 200092 times 215.22 ms/op 214.94 ms/op 1.00
hash 200092 times using batchHash4UintArray64s 231.91 ms/op 235.50 ms/op 0.98
digest64HashObjects 200092 times 193.87 ms/op 191.34 ms/op 1.01
hash 200092 times using batchHash4HashObjectInputs 198.11 ms/op 201.99 ms/op 0.98
getGindicesAtDepth 3.6840 us/op 3.5850 us/op 1.03
iterateAtDepth 6.4140 us/op 6.4060 us/op 1.00
getGindexBits 435.00 ns/op 424.00 ns/op 1.03
gindexIterator 890.00 ns/op 895.00 ns/op 0.99
HashComputationLevel.push then loop 25.951 ms/op 25.751 ms/op 1.01
HashComputation[] push then loop 49.860 ms/op 47.774 ms/op 1.04
hash 2 32 bytes Uint8Array 500000 times - hashtree 146.73 ms/op 176.05 ms/op 0.83
batch hash 16 x 64 Uint8Array 31250 times - hashtree 24.412 ms/op 26.389 ms/op 0.93
hashTwoObjects 500000 times - hashtree 163.22 ms/op 194.87 ms/op 0.84
executeHashComputations - hashtree 9.2347 ms/op 8.9813 ms/op 1.03
hash 2 32 bytes Uint8Array 500000 times - as-sha256 492.18 ms/op 495.89 ms/op 0.99
batch hash 16 x 64 Uint8Array 31250 times - as-sha256 502.99 ms/op 501.00 ms/op 1.00
hashTwoObjects 500000 times - as-sha256 502.44 ms/op 503.09 ms/op 1.00
executeHashComputations - as-sha256 45.733 ms/op 45.677 ms/op 1.00
hash 2 32 bytes Uint8Array 500000 times - noble 1.2369 s/op 1.2639 s/op 0.98
batch hash 16 x 64 Uint8Array 31250 times - noble 1.1853 s/op 1.2516 s/op 0.95
hashTwoObjects 500000 times - noble 1.5552 s/op 1.6007 s/op 0.97
executeHashComputations - noble 36.363 ms/op 35.962 ms/op 1.01
getHashComputations 2.4485 ms/op 2.1814 ms/op 1.12
executeHashComputations 9.6951 ms/op 9.7851 ms/op 0.99
get root 12.271 ms/op 14.356 ms/op 0.85
getNodeH() x7812.5 avg hindex 12.050 us/op 12.148 us/op 0.99
getNodeH() x7812.5 index 0 7.5300 us/op 7.5830 us/op 0.99
getNodeH() x7812.5 index 7 7.5310 us/op 7.4800 us/op 1.01
getNodeH() x7812.5 index 7 with key array 6.2530 us/op 6.4140 us/op 0.97
new LeafNode() x7812.5 306.54 us/op 303.94 us/op 1.01
getHashComputations 250000 nodes 14.994 ms/op 16.300 ms/op 0.92
batchHash 250000 nodes 83.811 ms/op 80.003 ms/op 1.05
get root 250000 nodes 91.349 ms/op 107.03 ms/op 0.85
getHashComputations 500000 nodes 32.014 ms/op 32.368 ms/op 0.99
batchHash 500000 nodes 147.65 ms/op 162.24 ms/op 0.91
get root 500000 nodes 182.82 ms/op 212.93 ms/op 0.86
getHashComputations 1000000 nodes 59.631 ms/op 60.381 ms/op 0.99
batchHash 1000000 nodes 343.85 ms/op 321.87 ms/op 1.07
get root 1000000 nodes 364.08 ms/op 425.59 ms/op 0.86
multiproof - depth 15, 1 requested leaves 7.4940 us/op 7.6900 us/op 0.97
tree offset multiproof - depth 15, 1 requested leaves 16.690 us/op 16.512 us/op 1.01
compact multiproof - depth 15, 1 requested leaves 3.1690 us/op 3.2150 us/op 0.99
multiproof - depth 15, 2 requested leaves 10.999 us/op 10.874 us/op 1.01
tree offset multiproof - depth 15, 2 requested leaves 20.149 us/op 20.113 us/op 1.00
compact multiproof - depth 15, 2 requested leaves 3.1210 us/op 3.0850 us/op 1.01
multiproof - depth 15, 3 requested leaves 15.512 us/op 15.697 us/op 0.99
tree offset multiproof - depth 15, 3 requested leaves 26.268 us/op 26.439 us/op 0.99
compact multiproof - depth 15, 3 requested leaves 3.8480 us/op 3.5000 us/op 1.10
multiproof - depth 15, 4 requested leaves 20.906 us/op 20.908 us/op 1.00
tree offset multiproof - depth 15, 4 requested leaves 32.460 us/op 32.795 us/op 0.99
compact multiproof - depth 15, 4 requested leaves 3.7980 us/op 4.0070 us/op 0.95
packedRootsBytesToLeafNodes bytes 4000 offset 0 5.5920 us/op 5.4350 us/op 1.03
packedRootsBytesToLeafNodes bytes 4000 offset 1 5.5780 us/op 5.6010 us/op 1.00
packedRootsBytesToLeafNodes bytes 4000 offset 2 5.5790 us/op 5.4510 us/op 1.02
packedRootsBytesToLeafNodes bytes 4000 offset 3 5.5810 us/op 5.3920 us/op 1.04
subtreeFillToContents depth 40 count 250000 45.900 ms/op 44.917 ms/op 1.02
setRoot - gindexBitstring 21.054 ms/op 20.811 ms/op 1.01
setRoot - gindex 22.058 ms/op 21.353 ms/op 1.03
getRoot - gindexBitstring 2.4556 ms/op 2.4370 ms/op 1.01
getRoot - gindex 3.1067 ms/op 2.9433 ms/op 1.06
getHashObject then setHashObject 22.323 ms/op 21.577 ms/op 1.03
setNodeWithFn 19.881 ms/op 19.582 ms/op 1.02
getNodeAtDepth depth 0 x100000 280.08 us/op 279.96 us/op 1.00
setNodeAtDepth depth 0 x100000 2.7566 ms/op 2.5515 ms/op 1.08
getNodesAtDepth depth 0 x100000 313.29 us/op 312.11 us/op 1.00
setNodesAtDepth depth 0 x100000 771.39 us/op 758.42 us/op 1.02
getNodeAtDepth depth 1 x100000 342.67 us/op 342.52 us/op 1.00
setNodeAtDepth depth 1 x100000 9.0181 ms/op 8.1075 ms/op 1.11
getNodesAtDepth depth 1 x100000 435.82 us/op 435.80 us/op 1.00
setNodesAtDepth depth 1 x100000 7.4013 ms/op 8.6775 ms/op 0.85
getNodeAtDepth depth 2 x100000 997.18 us/op 749.48 us/op 1.33
setNodeAtDepth depth 2 x100000 16.461 ms/op 15.287 ms/op 1.08
getNodesAtDepth depth 2 x100000 18.534 ms/op 16.777 ms/op 1.10
setNodesAtDepth depth 2 x100000 23.147 ms/op 22.149 ms/op 1.05
tree.getNodesAtDepth - gindexes 9.3117 ms/op 8.3602 ms/op 1.11
tree.getNodesAtDepth - push all nodes 2.4508 ms/op 2.3104 ms/op 1.06
tree.getNodesAtDepth - navigation 311.59 us/op 311.13 us/op 1.00
tree.setNodesAtDepth - indexes 763.14 us/op 724.49 us/op 1.05
set at depth 8 919.00 ns/op 812.00 ns/op 1.13
set at depth 16 1.1310 us/op 1.1830 us/op 0.96
set at depth 32 1.9080 us/op 1.9780 us/op 0.96
iterateNodesAtDepth 8 256 13.265 us/op 13.708 us/op 0.97
getNodesAtDepth 8 256 3.5730 us/op 3.6330 us/op 0.98
iterateNodesAtDepth 16 65536 4.2001 ms/op 4.3534 ms/op 0.96
getNodesAtDepth 16 65536 1.1124 ms/op 1.2550 ms/op 0.89
iterateNodesAtDepth 32 250000 15.875 ms/op 16.752 ms/op 0.95
getNodesAtDepth 32 250000 4.4316 ms/op 4.8973 ms/op 0.90
iterateNodesAtDepth 40 250000 15.812 ms/op 16.185 ms/op 0.98
getNodesAtDepth 40 250000 4.5247 ms/op 4.8892 ms/op 0.93
250000 validators root getter 92.388 ms/op 108.10 ms/op 0.85
250000 validators batchHash() 82.022 ms/op 96.618 ms/op 0.85
250000 validators hashComputations 17.253 ms/op 15.295 ms/op 1.13
bitlist bytes to struct (120,90) 510.00 ns/op 484.00 ns/op 1.05
bitlist bytes to tree (120,90) 2.0430 us/op 2.0290 us/op 1.01
bitlist bytes to struct (2048,2048) 850.00 ns/op 872.00 ns/op 0.97
bitlist bytes to tree (2048,2048) 3.3370 us/op 3.4500 us/op 0.97
ByteListType - deserialize 9.3186 ms/op 8.0250 ms/op 1.16
BasicListType - deserialize 9.3011 ms/op 9.9533 ms/op 0.93
ByteListType - serialize 9.7253 ms/op 8.6637 ms/op 1.12
BasicListType - serialize 11.356 ms/op 9.7726 ms/op 1.16
BasicListType - tree_convertToStruct 19.872 ms/op 21.516 ms/op 0.92
List[uint8, 68719476736] len 300000 ViewDU.getAll() + iterate 4.6678 ms/op 5.0822 ms/op 0.92
List[uint8, 68719476736] len 300000 ViewDU.get(i) 4.3771 ms/op 4.3931 ms/op 1.00
Array.push len 300000 empty Array - number 6.5732 ms/op 6.8623 ms/op 0.96
Array.set len 300000 from new Array - number 1.8231 ms/op 2.1911 ms/op 0.83
Array.set len 300000 - number 5.9542 ms/op 6.1572 ms/op 0.97
Uint8Array.set len 300000 377.40 us/op 399.19 us/op 0.95
Uint32Array.set len 300000 444.69 us/op 434.77 us/op 1.02
Container({a: uint8, b: uint8}) getViewDU x300000 30.098 ms/op 29.144 ms/op 1.03
ContainerNodeStruct({a: uint8, b: uint8}) getViewDU x300000 10.518 ms/op 10.418 ms/op 1.01
List(Container) len 300000 ViewDU.getAllReadonly() + iterate 208.24 ms/op 185.30 ms/op 1.12
List(Container) len 300000 ViewDU.getAllReadonlyValues() + iterate 233.16 ms/op 233.77 ms/op 1.00
List(Container) len 300000 ViewDU.get(i) 6.5573 ms/op 6.4991 ms/op 1.01
List(Container) len 300000 ViewDU.getReadonly(i) 6.5348 ms/op 6.5091 ms/op 1.00
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonly() + iterate 37.250 ms/op 36.727 ms/op 1.01
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonlyValues() + iterate 5.2778 ms/op 5.1732 ms/op 1.02
List(ContainerNodeStruct) len 300000 ViewDU.get(i) 6.2051 ms/op 6.1558 ms/op 1.01
List(ContainerNodeStruct) len 300000 ViewDU.getReadonly(i) 6.2073 ms/op 6.1511 ms/op 1.01
Array.push len 300000 empty Array - object 6.2202 ms/op 6.2153 ms/op 1.00
Array.set len 300000 from new Array - object 2.0486 ms/op 2.0358 ms/op 1.01
Array.set len 300000 - object 6.0374 ms/op 6.0974 ms/op 0.99
cachePermanentRootStruct no cache 3.1050 us/op 3.4580 us/op 0.90
cachePermanentRootStruct with cache 161.00 ns/op 171.00 ns/op 0.94
epochParticipation len 250000 rws 7813 2.3002 ms/op 2.4099 ms/op 0.95
Deneb BeaconBlock.hashTreeRoot(), numTransaction=200 4.6856 ms/op 5.1989 ms/op 0.90
BeaconState ViewDU batchHashTreeRoot vc=200000 mod=100000 212.70 ms/op 216.99 ms/op 0.98
BeaconState ViewDU batchHashTreeRoot - commit step vc=200000 mod=100000 178.01 ms/op 191.63 ms/op 0.93
BeaconState ViewDU batchHashTreeRoot - hash step vc=200000 mod=100000 49.062 ms/op 48.741 ms/op 1.01
BeaconState ViewDU hashTreeRoot() vc=200000 mod=100000 692.37 ms/op 747.37 ms/op 0.93
BeaconState ViewDU hashTreeRoot - commit step vc=200000 mod=100000 65.177 ms/op 64.964 ms/op 1.00
BeaconState ViewDU hashTreeRoot - validator tree creation vc=100000 mod=100000 269.49 ms/op 251.01 ms/op 1.07
deserialize Attestation - tree 3.4050 us/op 3.5480 us/op 0.96
deserialize Attestation - struct 1.8990 us/op 1.8320 us/op 1.04
deserialize SignedAggregateAndProof - tree 4.9220 us/op 4.7920 us/op 1.03
deserialize SignedAggregateAndProof - struct 2.9550 us/op 2.8670 us/op 1.03
deserialize SyncCommitteeMessage - tree 1.4310 us/op 1.3930 us/op 1.03
deserialize SyncCommitteeMessage - struct 1.0660 us/op 1.0630 us/op 1.00
deserialize SignedContributionAndProof - tree 3.0840 us/op 2.8190 us/op 1.09
deserialize SignedContributionAndProof - struct 2.2410 us/op 2.2100 us/op 1.01
deserialize SignedBeaconBlock - tree 281.69 us/op 270.92 us/op 1.04
deserialize SignedBeaconBlock - struct 116.03 us/op 115.54 us/op 1.00
BeaconState vc 300000 - deserialize tree 632.27 ms/op 602.70 ms/op 1.05
BeaconState vc 300000 - serialize tree 114.11 ms/op 96.595 ms/op 1.18
BeaconState.historicalRoots vc 300000 - deserialize tree 953.00 ns/op 926.00 ns/op 1.03
BeaconState.historicalRoots vc 300000 - serialize tree 679.00 ns/op 647.00 ns/op 1.05
BeaconState.validators vc 300000 - deserialize tree 606.35 ms/op 589.75 ms/op 1.03
BeaconState.validators vc 300000 - serialize tree 39.127 ms/op 37.193 ms/op 1.05
BeaconState.balances vc 300000 - deserialize tree 26.446 ms/op 24.019 ms/op 1.10
BeaconState.balances vc 300000 - serialize tree 4.1936 ms/op 3.7168 ms/op 1.13
BeaconState.previousEpochParticipation vc 300000 - deserialize tree 1.0299 ms/op 893.77 us/op 1.15
BeaconState.previousEpochParticipation vc 300000 - serialize tree 339.09 us/op 322.83 us/op 1.05
BeaconState.currentEpochParticipation vc 300000 - deserialize tree 1.0449 ms/op 900.43 us/op 1.16
BeaconState.currentEpochParticipation vc 300000 - serialize tree 338.09 us/op 321.22 us/op 1.05
BeaconState.inactivityScores vc 300000 - deserialize tree 28.303 ms/op 25.011 ms/op 1.13
BeaconState.inactivityScores vc 300000 - serialize tree 3.3914 ms/op 3.7017 ms/op 0.92
hashTreeRoot Attestation - struct 9.8860 us/op 10.309 us/op 0.96
hashTreeRoot Attestation - tree 7.2770 us/op 8.3840 us/op 0.87
hashTreeRoot SignedAggregateAndProof - struct 12.862 us/op 13.949 us/op 0.92
hashTreeRoot SignedAggregateAndProof - tree 10.761 us/op 12.593 us/op 0.85
hashTreeRoot SyncCommitteeMessage - struct 3.1970 us/op 3.4030 us/op 0.94
hashTreeRoot SyncCommitteeMessage - tree 2.8350 us/op 3.0510 us/op 0.93
hashTreeRoot SignedContributionAndProof - struct 8.0950 us/op 8.3440 us/op 0.97
hashTreeRoot SignedContributionAndProof - tree 7.4090 us/op 8.7450 us/op 0.85
hashTreeRoot SignedBeaconBlock - struct 777.50 us/op 825.02 us/op 0.94
hashTreeRoot SignedBeaconBlock - tree 653.50 us/op 756.01 us/op 0.86
hashTreeRoot Validator - struct 4.5600 us/op 4.7470 us/op 0.96
hashTreeRoot Validator - tree 5.9230 us/op 6.0900 us/op 0.97
BeaconState vc 300000 - hashTreeRoot tree 2.0074 s/op 2.0810 s/op 0.96
BeaconState vc 300000 - batchHashTreeRoot tree 3.9424 s/op 3.7718 s/op 1.05
BeaconState.historicalRoots vc 300000 - hashTreeRoot tree 849.00 ns/op 880.00 ns/op 0.96
BeaconState.validators vc 300000 - hashTreeRoot tree 2.0907 s/op 2.2687 s/op 0.92
BeaconState.balances vc 300000 - hashTreeRoot tree 27.425 ms/op 32.359 ms/op 0.85
BeaconState.previousEpochParticipation vc 300000 - hashTreeRoot tree 3.4224 ms/op 3.9955 ms/op 0.86
BeaconState.currentEpochParticipation vc 300000 - hashTreeRoot tree 3.4355 ms/op 3.9983 ms/op 0.86
BeaconState.inactivityScores vc 300000 - hashTreeRoot tree 29.770 ms/op 32.359 ms/op 0.92
hash64 x18 7.4940 us/op 8.7160 us/op 0.86
hashTwoObjects x18 6.5370 us/op 7.6480 us/op 0.85
hash64 x1740 670.24 us/op 841.69 us/op 0.80
hashTwoObjects x1740 579.68 us/op 704.51 us/op 0.82
hash64 x2700000 1.0453 s/op 1.2029 s/op 0.87
hashTwoObjects x2700000 904.29 ms/op 1.0997 s/op 0.82
get_exitEpoch - ContainerType 266.00 ns/op 249.00 ns/op 1.07
get_exitEpoch - ContainerNodeStructType 228.00 ns/op 231.00 ns/op 0.99
set_exitEpoch - ContainerType 243.00 ns/op 244.00 ns/op 1.00
set_exitEpoch - ContainerNodeStructType 230.00 ns/op 234.00 ns/op 0.98
get_pubkey - ContainerType 868.00 ns/op 875.00 ns/op 0.99
get_pubkey - ContainerNodeStructType 218.00 ns/op 218.00 ns/op 1.00
hashTreeRoot - ContainerType 430.00 ns/op 406.00 ns/op 1.06
hashTreeRoot - ContainerNodeStructType 412.00 ns/op 415.00 ns/op 0.99
createProof - ContainerType 3.5110 us/op 3.5950 us/op 0.98
createProof - ContainerNodeStructType 18.876 us/op 19.406 us/op 0.97
serialize - ContainerType 1.6190 us/op 1.6170 us/op 1.00
serialize - ContainerNodeStructType 1.0950 us/op 1.0680 us/op 1.03
set_exitEpoch_and_hashTreeRoot - ContainerType 2.6050 us/op 2.6310 us/op 0.99
set_exitEpoch_and_hashTreeRoot - ContainerNodeStructType 6.3800 us/op 6.7780 us/op 0.94
doBatchHashTreeRootValidators 3.6530 us/op 3.8330 us/op 0.95
ContainerNodeStructViewDU hashTreeRoot 21.633 us/op 23.672 us/op 0.91
Array - for of 7.3400 us/op 10.301 us/op 0.71
Array - for(;;) 7.3700 us/op 10.200 us/op 0.72
basicListValue.readonlyValuesArray() 3.6715 ms/op 4.0258 ms/op 0.91
basicListValue.readonlyValuesArray() + loop all 3.8798 ms/op 4.4584 ms/op 0.87
compositeListValue.readonlyValuesArray() 30.677 ms/op 29.817 ms/op 1.03
compositeListValue.readonlyValuesArray() + loop all 31.127 ms/op 30.358 ms/op 1.03
Number64UintType - get balances list 4.8696 ms/op 4.3354 ms/op 1.12
Number64UintType - set balances list 10.033 ms/op 10.102 ms/op 0.99
Number64UintType - get and increase 10 then set 41.631 ms/op 41.595 ms/op 1.00
Number64UintType - increase 10 using applyDelta 16.710 ms/op 16.911 ms/op 0.99
Number64UintType - increase 10 using applyDeltaInBatch 17.118 ms/op 17.528 ms/op 0.98
tree_newTreeFromUint64Deltas 20.401 ms/op 22.238 ms/op 0.92
unsafeUint8ArrayToTree 35.085 ms/op 32.101 ms/op 1.09
bitLength(50) 240.00 ns/op 221.00 ns/op 1.09
bitLengthStr(50) 250.00 ns/op 233.00 ns/op 1.07
bitLength(8000) 239.00 ns/op 223.00 ns/op 1.07
bitLengthStr(8000) 283.00 ns/op 265.00 ns/op 1.07
bitLength(250000) 231.00 ns/op 232.00 ns/op 1.00
bitLengthStr(250000) 314.00 ns/op 291.00 ns/op 1.08
merkleize 32 chunks 12.154 us/op 14.026 us/op 0.87
merkleizeBlocksBytes 32 chunks 3.0470 us/op 3.3640 us/op 0.91
merkleizeBlockArray 32 chunks 5.9630 us/op 6.3570 us/op 0.94
merkleize 128 chunks 46.973 us/op 55.178 us/op 0.85
merkleizeBlocksBytes 128 chunks 7.1320 us/op 7.6120 us/op 0.94
merkleizeBlockArray 128 chunks 17.189 us/op 17.883 us/op 0.96
merkleize 512 chunks 188.88 us/op 222.12 us/op 0.85
merkleizeBlocksBytes 512 chunks 22.575 us/op 23.114 us/op 0.98
merkleizeBlockArray 512 chunks 58.613 us/op 62.959 us/op 0.93
merkleize 1024 chunks 378.78 us/op 446.91 us/op 0.85
merkleizeBlocksBytes 1024 chunks 42.194 us/op 42.745 us/op 0.99
merkleizeBlockArray 1024 chunks 114.14 us/op 120.50 us/op 0.95
floor - Math.floor (53) 1.2440 ns/op 1.2433 ns/op 1.00
floor - << 0 (53) 1.2479 ns/op 1.2449 ns/op 1.00
floor - Math.floor (512) 1.2439 ns/op 1.2441 ns/op 1.00
floor - << 0 (512) 1.2440 ns/op 1.2435 ns/op 1.00
fnIf(0) 1.5574 ns/op 1.5542 ns/op 1.00
fnSwitch(0) 2.1776 ns/op 2.1776 ns/op 1.00
fnObj(0) 1.5650 ns/op 1.5632 ns/op 1.00
fnArr(0) 1.5561 ns/op 1.5541 ns/op 1.00
fnIf(4) 2.1792 ns/op 2.1766 ns/op 1.00
fnSwitch(4) 2.1766 ns/op 2.1756 ns/op 1.00
fnObj(4) 1.5661 ns/op 1.5542 ns/op 1.01
fnArr(4) 1.5541 ns/op 1.5553 ns/op 1.00
fnIf(9) 3.1134 ns/op 3.1141 ns/op 1.00
fnSwitch(9) 2.1759 ns/op 2.1780 ns/op 1.00
fnObj(9) 1.5578 ns/op 1.5612 ns/op 1.00
fnArr(9) 1.5555 ns/op 1.5568 ns/op 1.00
Container {a,b,vec} - as struct x100000 124.50 us/op 124.62 us/op 1.00
Container {a,b,vec} - as tree x100000 560.09 us/op 563.35 us/op 0.99
Container {a,vec,b} - as struct x100000 156.17 us/op 155.66 us/op 1.00
Container {a,vec,b} - as tree x100000 560.03 us/op 560.30 us/op 1.00
get 2 props x1000000 - rawObject 311.05 us/op 311.32 us/op 1.00
get 2 props x1000000 - proxy 73.168 ms/op 73.073 ms/op 1.00
get 2 props x1000000 - customObj 311.00 us/op 311.69 us/op 1.00
Simple object binary -> struct 615.00 ns/op 576.00 ns/op 1.07
Simple object binary -> tree_backed 1.7880 us/op 1.6780 us/op 1.07
Simple object struct -> tree_backed 2.4550 us/op 2.2880 us/op 1.07
Simple object tree_backed -> struct 1.4950 us/op 1.4920 us/op 1.00
Simple object struct -> binary 865.00 ns/op 848.00 ns/op 1.02
Simple object tree_backed -> binary 1.2130 us/op 1.2090 us/op 1.00
aggregationBits binary -> struct 486.00 ns/op 494.00 ns/op 0.98
aggregationBits binary -> tree_backed 2.1180 us/op 2.0500 us/op 1.03
aggregationBits struct -> tree_backed 2.5090 us/op 2.4270 us/op 1.03
aggregationBits tree_backed -> struct 1.1350 us/op 959.00 ns/op 1.18
aggregationBits struct -> binary 716.00 ns/op 676.00 ns/op 1.06
aggregationBits tree_backed -> binary 847.00 ns/op 815.00 ns/op 1.04
List(uint8) 100000 binary -> struct 1.0215 ms/op 899.74 us/op 1.14
List(uint8) 100000 binary -> tree_backed 274.67 us/op 269.49 us/op 1.02
List(uint8) 100000 struct -> tree_backed 1.3417 ms/op 1.3571 ms/op 0.99
List(uint8) 100000 tree_backed -> struct 982.94 us/op 1.0068 ms/op 0.98
List(uint8) 100000 struct -> binary 1.0485 ms/op 1.0679 ms/op 0.98
List(uint8) 100000 tree_backed -> binary 107.65 us/op 109.26 us/op 0.99
List(uint64Number) 100000 binary -> struct 1.2559 ms/op 1.2712 ms/op 0.99
List(uint64Number) 100000 binary -> tree_backed 4.7501 ms/op 4.4708 ms/op 1.06
List(uint64Number) 100000 struct -> tree_backed 6.2049 ms/op 6.3275 ms/op 0.98
List(uint64Number) 100000 tree_backed -> struct 2.3994 ms/op 2.4385 ms/op 0.98
List(uint64Number) 100000 struct -> binary 1.4387 ms/op 1.4360 ms/op 1.00
List(uint64Number) 100000 tree_backed -> binary 1.0795 ms/op 1.0689 ms/op 1.01
List(Uint64Bigint) 100000 binary -> struct 3.8345 ms/op 3.7200 ms/op 1.03
List(Uint64Bigint) 100000 binary -> tree_backed 4.7683 ms/op 4.3032 ms/op 1.11
List(Uint64Bigint) 100000 struct -> tree_backed 6.8492 ms/op 6.5499 ms/op 1.05
List(Uint64Bigint) 100000 tree_backed -> struct 4.7885 ms/op 4.7035 ms/op 1.02
List(Uint64Bigint) 100000 struct -> binary 2.1239 ms/op 2.1057 ms/op 1.01
List(Uint64Bigint) 100000 tree_backed -> binary 1.0872 ms/op 1.1148 ms/op 0.98
Vector(Root) 100000 binary -> struct 32.797 ms/op 34.356 ms/op 0.95
Vector(Root) 100000 binary -> tree_backed 40.198 ms/op 33.613 ms/op 1.20
Vector(Root) 100000 struct -> tree_backed 51.493 ms/op 48.300 ms/op 1.07
Vector(Root) 100000 tree_backed -> struct 49.077 ms/op 47.677 ms/op 1.03
Vector(Root) 100000 struct -> binary 3.6181 ms/op 3.0729 ms/op 1.18
Vector(Root) 100000 tree_backed -> binary 7.1254 ms/op 6.5322 ms/op 1.09
List(Validator) 100000 binary -> struct 104.79 ms/op 99.754 ms/op 1.05
List(Validator) 100000 binary -> tree_backed 340.05 ms/op 316.75 ms/op 1.07
List(Validator) 100000 struct -> tree_backed 364.41 ms/op 355.05 ms/op 1.03
List(Validator) 100000 tree_backed -> struct 209.26 ms/op 203.21 ms/op 1.03
List(Validator) 100000 struct -> binary 30.175 ms/op 29.966 ms/op 1.01
List(Validator) 100000 tree_backed -> binary 108.20 ms/op 106.99 ms/op 1.01
List(Validator-NS) 100000 binary -> struct 112.06 ms/op 102.25 ms/op 1.10
List(Validator-NS) 100000 binary -> tree_backed 137.79 ms/op 151.17 ms/op 0.91
List(Validator-NS) 100000 struct -> tree_backed 184.49 ms/op 176.16 ms/op 1.05
List(Validator-NS) 100000 tree_backed -> struct 150.54 ms/op 143.41 ms/op 1.05
List(Validator-NS) 100000 struct -> binary 7.4438 ms/op 7.8204 ms/op 0.95
List(Validator-NS) 100000 tree_backed -> binary 13.469 ms/op 12.822 ms/op 1.05
get epochStatuses - MutableVector 92.339 us/op 88.876 us/op 1.04
get epochStatuses - ViewDU 209.31 us/op 205.93 us/op 1.02
set epochStatuses - ListTreeView 2.0636 ms/op 2.1535 ms/op 0.96
set epochStatuses - ListTreeView - set() 460.21 us/op 467.27 us/op 0.98
set epochStatuses - ListTreeView - commit() 793.67 us/op 796.38 us/op 1.00
bitstring 513.40 ns/op 512.91 ns/op 1.00
bit mask 13.923 ns/op 13.359 ns/op 1.04
struct - increase slot to 1000000 933.27 us/op 934.45 us/op 1.00
UintNumberType - increase slot to 1000000 27.705 ms/op 28.566 ms/op 0.97
UintBigintType - increase slot to 1000000 171.04 ms/op 172.39 ms/op 0.99
UintBigint8 x 100000 tree_deserialize 5.4997 ms/op 6.1942 ms/op 0.89
UintBigint8 x 100000 tree_serialize 1.1281 ms/op 1.1286 ms/op 1.00
UintBigint16 x 100000 tree_deserialize 6.7858 ms/op 6.1536 ms/op 1.10
UintBigint16 x 100000 tree_serialize 1.3466 ms/op 1.3857 ms/op 0.97
UintBigint32 x 100000 tree_deserialize 5.3966 ms/op 6.3947 ms/op 0.84
UintBigint32 x 100000 tree_serialize 1.7978 ms/op 1.8278 ms/op 0.98
UintBigint64 x 100000 tree_deserialize 6.6403 ms/op 6.8298 ms/op 0.97
UintBigint64 x 100000 tree_serialize 2.4619 ms/op 2.5254 ms/op 0.97
UintBigint8 x 100000 value_deserialize 405.78 us/op 404.64 us/op 1.00
UintBigint8 x 100000 value_serialize 733.34 us/op 767.31 us/op 0.96
UintBigint16 x 100000 value_deserialize 466.77 us/op 466.54 us/op 1.00
UintBigint16 x 100000 value_serialize 763.98 us/op 808.60 us/op 0.94
UintBigint32 x 100000 value_deserialize 498.64 us/op 500.35 us/op 1.00
UintBigint32 x 100000 value_serialize 798.81 us/op 846.66 us/op 0.94
UintBigint64 x 100000 value_deserialize 530.57 us/op 530.78 us/op 1.00
UintBigint64 x 100000 value_serialize 942.67 us/op 987.27 us/op 0.95
UintBigint8 x 100000 deserialize 3.0538 ms/op 3.2308 ms/op 0.95
UintBigint8 x 100000 serialize 1.4970 ms/op 1.5085 ms/op 0.99
UintBigint16 x 100000 deserialize 3.0775 ms/op 3.1603 ms/op 0.97
UintBigint16 x 100000 serialize 1.5804 ms/op 1.5742 ms/op 1.00
UintBigint32 x 100000 deserialize 3.2180 ms/op 3.3410 ms/op 0.96
UintBigint32 x 100000 serialize 2.9339 ms/op 2.8998 ms/op 1.01
UintBigint64 x 100000 deserialize 4.2471 ms/op 4.3320 ms/op 0.98
UintBigint64 x 100000 serialize 1.6772 ms/op 1.6692 ms/op 1.00
UintBigint128 x 100000 deserialize 5.7248 ms/op 5.6923 ms/op 1.01
UintBigint128 x 100000 serialize 14.861 ms/op 15.202 ms/op 0.98
UintBigint256 x 100000 deserialize 8.6778 ms/op 8.6745 ms/op 1.00
UintBigint256 x 100000 serialize 44.832 ms/op 45.189 ms/op 0.99
Slice from Uint8Array x25000 1.4229 ms/op 1.4384 ms/op 0.99
Slice from ArrayBuffer x25000 15.840 ms/op 16.079 ms/op 0.99
Slice from ArrayBuffer x25000 + new Uint8Array 17.442 ms/op 16.791 ms/op 1.04
Copy Uint8Array 100000 iterate 1.6850 ms/op 1.6887 ms/op 1.00
Copy Uint8Array 100000 slice 109.49 us/op 100.97 us/op 1.08
Copy Uint8Array 100000 Uint8Array.prototype.slice.call 117.29 us/op 104.14 us/op 1.13
Copy Buffer 100000 Uint8Array.prototype.slice.call 118.88 us/op 101.59 us/op 1.17
Copy Uint8Array 100000 slice + set 233.97 us/op 202.85 us/op 1.15
Copy Uint8Array 100000 subarray + set 117.73 us/op 103.22 us/op 1.14
Copy Uint8Array 100000 slice arrayBuffer 119.61 us/op 104.53 us/op 1.14
Uint64 deserialize 100000 - iterate Uint8Array 2.1046 ms/op 1.8800 ms/op 1.12
Uint64 deserialize 100000 - by Uint32A 2.0488 ms/op 1.8460 ms/op 1.11
Uint64 deserialize 100000 - by DataView.getUint32 x2 1.9904 ms/op 1.7686 ms/op 1.13
Uint64 deserialize 100000 - by DataView.getBigUint64 4.9206 ms/op 4.8299 ms/op 1.02
Uint64 deserialize 100000 - by byte 40.238 ms/op 40.193 ms/op 1.00

by benchmarkbot/action

Comment on lines +114 to +117
// Precompute final h values once
const hValues = [0, 0, 0, 0, 0, 0, 0, 0];

// Whole 4-byte words we can take directly

Choose a reason for hiding this comment

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

i see here, that the real only thing of note that you only change from my implemtation is

const hValues = new Array(8).fill(0);  

// to

hValues = [0, 0, 0, 0, 0, 0, 0, 0]; 

is there any computation benfit against using Array.fill here?

Copy link
Member

Choose a reason for hiding this comment

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

likely doesn't matter, but using a literal may be faster.

Copy link
Contributor

@twoeths twoeths left a comment

Choose a reason for hiding this comment

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

would be great to know how does this PR impacts the performance through benchmarks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants