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: improve hashBlocks() in as-sha256 #359

Closed
wants to merge 4 commits into from

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Mar 25, 2024

Motivation

  • Improve as-sha256

Description

  • Chain w computation in the same for loop of hashBlocks()
  • Use UintArray.slice()

Closes #357

Copy link

github-actions bot commented Mar 25, 2024

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 832bf67 Previous: 9cf6991 Ratio
digestTwoHashObjects 50023 times 50.828 ms/op 48.285 ms/op 1.05
digest64 50023 times 52.915 ms/op 49.639 ms/op 1.07
digest 50023 times 56.834 ms/op 53.716 ms/op 1.06
input length 32 1.5250 us/op 1.4220 us/op 1.07
input length 64 1.6140 us/op 1.5230 us/op 1.06
input length 128 2.7030 us/op 2.5340 us/op 1.07
input length 256 3.9120 us/op 3.6590 us/op 1.07
input length 512 6.4190 us/op 5.9160 us/op 1.09
input length 1024 12.037 us/op 11.307 us/op 1.06
digest 1000000 times 934.32 ms/op 873.45 ms/op 1.07
hashObjectToByteArray 50023 times 1.4601 ms/op 1.4264 ms/op 1.02
byteArrayToHashObject 50023 times 3.6392 ms/op 3.7377 ms/op 0.97
getGindicesAtDepth 5.0060 us/op 5.0600 us/op 0.99
iterateAtDepth 10.406 us/op 10.233 us/op 1.02
getGindexBits 533.00 ns/op 562.00 ns/op 0.95
gindexIterator 1.2200 us/op 1.2280 us/op 0.99
hash 2 Uint8Array 2250026 times - as-sha256 2.4584 s/op 2.3065 s/op 1.07
hashTwoObjects 2250026 times - as-sha256 2.3612 s/op 2.2279 s/op 1.06
hash 2 Uint8Array 2250026 times - noble 5.7971 s/op 6.0080 s/op 0.96
hashTwoObjects 2250026 times - noble 6.7456 s/op 7.0158 s/op 0.96
getNodeH() x7812.5 avg hindex 15.375 us/op 15.272 us/op 1.01
getNodeH() x7812.5 index 0 5.2040 us/op 5.1960 us/op 1.00
getNodeH() x7812.5 index 7 5.2330 us/op 5.0980 us/op 1.03
getNodeH() x7812.5 index 7 with key array 5.2930 us/op 5.1600 us/op 1.03
new LeafNode() x7812.5 371.49 us/op 207.11 us/op 1.79
multiproof - depth 15, 1 requested leaves 10.209 us/op 10.608 us/op 0.96
tree offset multiproof - depth 15, 1 requested leaves 20.590 us/op 21.220 us/op 0.97
compact multiproof - depth 15, 1 requested leaves 5.5870 us/op 5.4640 us/op 1.02
multiproof - depth 15, 2 requested leaves 13.818 us/op 13.836 us/op 1.00
tree offset multiproof - depth 15, 2 requested leaves 24.902 us/op 24.816 us/op 1.00
compact multiproof - depth 15, 2 requested leaves 3.5200 us/op 3.1640 us/op 1.11
multiproof - depth 15, 3 requested leaves 19.237 us/op 18.999 us/op 1.01
tree offset multiproof - depth 15, 3 requested leaves 32.310 us/op 32.057 us/op 1.01
compact multiproof - depth 15, 3 requested leaves 4.9610 us/op 5.5440 us/op 0.89
multiproof - depth 15, 4 requested leaves 23.589 us/op 24.858 us/op 0.95
tree offset multiproof - depth 15, 4 requested leaves 37.162 us/op 39.442 us/op 0.94
compact multiproof - depth 15, 4 requested leaves 5.5450 us/op 5.4290 us/op 1.02
packedRootsBytesToLeafNodes bytes 4000 offset 0 2.0040 us/op 2.0330 us/op 0.99
packedRootsBytesToLeafNodes bytes 4000 offset 1 1.9920 us/op 2.0190 us/op 0.99
packedRootsBytesToLeafNodes bytes 4000 offset 2 1.9920 us/op 2.0120 us/op 0.99
packedRootsBytesToLeafNodes bytes 4000 offset 3 1.9780 us/op 2.0140 us/op 0.98
subtreeFillToContents depth 40 count 250000 45.478 ms/op 46.683 ms/op 0.97
setRoot - gindexBitstring 8.1071 ms/op 8.8775 ms/op 0.91
setRoot - gindex 8.1833 ms/op 9.5630 ms/op 0.86
getRoot - gindexBitstring 2.2977 ms/op 2.3965 ms/op 0.96
getRoot - gindex 3.1256 ms/op 3.0536 ms/op 1.02
getHashObject then setHashObject 9.2032 ms/op 10.551 ms/op 0.87
setNodeWithFn 7.9147 ms/op 9.4797 ms/op 0.83
getNodeAtDepth depth 0 x100000 1.1789 ms/op 1.1445 ms/op 1.03
setNodeAtDepth depth 0 x100000 2.3446 ms/op 2.7071 ms/op 0.87
getNodesAtDepth depth 0 x100000 1.0856 ms/op 1.0835 ms/op 1.00
setNodesAtDepth depth 0 x100000 1.4936 ms/op 1.4853 ms/op 1.01
getNodeAtDepth depth 1 x100000 1.2066 ms/op 1.2076 ms/op 1.00
setNodeAtDepth depth 1 x100000 5.1425 ms/op 5.9761 ms/op 0.86
getNodesAtDepth depth 1 x100000 1.2078 ms/op 1.2101 ms/op 1.00
setNodesAtDepth depth 1 x100000 4.3430 ms/op 4.7749 ms/op 0.91
getNodeAtDepth depth 2 x100000 1.4836 ms/op 1.4843 ms/op 1.00
setNodeAtDepth depth 2 x100000 8.9238 ms/op 10.028 ms/op 0.89
getNodesAtDepth depth 2 x100000 18.847 ms/op 18.907 ms/op 1.00
setNodesAtDepth depth 2 x100000 12.705 ms/op 15.627 ms/op 0.81
tree.getNodesAtDepth - gindexes 5.9893 ms/op 6.3417 ms/op 0.94
tree.getNodesAtDepth - push all nodes 1.8071 ms/op 2.1973 ms/op 0.82
tree.getNodesAtDepth - navigation 156.10 us/op 157.13 us/op 0.99
tree.setNodesAtDepth - indexes 359.20 us/op 382.17 us/op 0.94
set at depth 8 479.00 ns/op 521.00 ns/op 0.92
set at depth 16 614.00 ns/op 679.00 ns/op 0.90
set at depth 32 941.00 ns/op 1.0670 us/op 0.88
iterateNodesAtDepth 8 256 13.518 us/op 14.517 us/op 0.93
getNodesAtDepth 8 256 3.3830 us/op 3.6240 us/op 0.93
iterateNodesAtDepth 16 65536 4.3005 ms/op 4.6303 ms/op 0.93
getNodesAtDepth 16 65536 1.5676 ms/op 2.0332 ms/op 0.77
iterateNodesAtDepth 32 250000 15.674 ms/op 16.556 ms/op 0.95
getNodesAtDepth 32 250000 4.2258 ms/op 4.7274 ms/op 0.89
iterateNodesAtDepth 40 250000 15.800 ms/op 16.251 ms/op 0.97
getNodesAtDepth 40 250000 4.3108 ms/op 4.7072 ms/op 0.92
250k validators 7.0060 s/op 7.7540 s/op 0.90
bitlist bytes to struct (120,90) 586.00 ns/op 646.00 ns/op 0.91
bitlist bytes to tree (120,90) 2.2600 us/op 2.6890 us/op 0.84
bitlist bytes to struct (2048,2048) 1000.0 ns/op 1.1300 us/op 0.88
bitlist bytes to tree (2048,2048) 3.5870 us/op 3.9720 us/op 0.90
ByteListType - deserialize 7.8718 ms/op 9.0002 ms/op 0.87
BasicListType - deserialize 7.9871 ms/op 9.6526 ms/op 0.83
ByteListType - serialize 8.3611 ms/op 8.1813 ms/op 1.02
BasicListType - serialize 10.365 ms/op 11.206 ms/op 0.92
BasicListType - tree_convertToStruct 28.765 ms/op 29.835 ms/op 0.96
List[uint8, 68719476736] len 300000 ViewDU.getAll() + iterate 4.0835 ms/op 4.0826 ms/op 1.00
List[uint8, 68719476736] len 300000 ViewDU.get(i) 4.1961 ms/op 4.1427 ms/op 1.01
Array.push len 300000 empty Array - number 6.2460 ms/op 6.1768 ms/op 1.01
Array.set len 300000 from new Array - number 1.6375 ms/op 1.6200 ms/op 1.01
Array.set len 300000 - number 5.3994 ms/op 5.3222 ms/op 1.01
Uint8Array.set len 300000 207.61 us/op 211.16 us/op 0.98
Uint32Array.set len 300000 290.34 us/op 282.88 us/op 1.03
Container({a: uint8, b: uint8}) getViewDU x300000 20.233 ms/op 20.067 ms/op 1.01
ContainerNodeStruct({a: uint8, b: uint8}) getViewDU x300000 9.2639 ms/op 9.4835 ms/op 0.98
List(Container) len 300000 ViewDU.getAllReadonly() + iterate 209.62 ms/op 206.96 ms/op 1.01
List(Container) len 300000 ViewDU.getAllReadonlyValues() + iterate 290.88 ms/op 288.70 ms/op 1.01
List(Container) len 300000 ViewDU.get(i) 6.5657 ms/op 6.8438 ms/op 0.96
List(Container) len 300000 ViewDU.getReadonly(i) 6.5797 ms/op 6.3335 ms/op 1.04
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonly() + iterate 36.188 ms/op 37.459 ms/op 0.97
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonlyValues() + iterate 5.0203 ms/op 5.2030 ms/op 0.96
List(ContainerNodeStruct) len 300000 ViewDU.get(i) 6.1520 ms/op 6.1396 ms/op 1.00
List(ContainerNodeStruct) len 300000 ViewDU.getReadonly(i) 5.9589 ms/op 5.9703 ms/op 1.00
Array.push len 300000 empty Array - object 6.0005 ms/op 6.0965 ms/op 0.98
Array.set len 300000 from new Array - object 1.9063 ms/op 1.9658 ms/op 0.97
Array.set len 300000 - object 5.5081 ms/op 5.4572 ms/op 1.01
cachePermanentRootStruct no cache 9.4660 us/op 8.8750 us/op 1.07
cachePermanentRootStruct with cache 221.00 ns/op 219.00 ns/op 1.01
epochParticipation len 250000 rws 7813 2.4116 ms/op 2.2825 ms/op 1.06
deserialize Attestation - tree 2.8750 us/op 2.9240 us/op 0.98
deserialize Attestation - struct 1.9740 us/op 2.0100 us/op 0.98
deserialize SignedAggregateAndProof - tree 3.6350 us/op 3.7010 us/op 0.98
deserialize SignedAggregateAndProof - struct 3.0670 us/op 3.0820 us/op 1.00
deserialize SyncCommitteeMessage - tree 1.1000 us/op 1.1560 us/op 0.95
deserialize SyncCommitteeMessage - struct 1.1940 us/op 1.1800 us/op 1.01
deserialize SignedContributionAndProof - tree 1.9500 us/op 1.9350 us/op 1.01
deserialize SignedContributionAndProof - struct 2.4850 us/op 2.4940 us/op 1.00
deserialize SignedBeaconBlock - tree 207.87 us/op 214.98 us/op 0.97
deserialize SignedBeaconBlock - struct 127.60 us/op 125.93 us/op 1.01
BeaconState vc 300000 - deserialize tree 574.62 ms/op 565.72 ms/op 1.02
BeaconState vc 300000 - serialize tree 110.98 ms/op 127.05 ms/op 0.87
BeaconState.historicalRoots vc 300000 - deserialize tree 860.00 ns/op 853.00 ns/op 1.01
BeaconState.historicalRoots vc 300000 - serialize tree 709.00 ns/op 681.00 ns/op 1.04
BeaconState.validators vc 300000 - deserialize tree 525.27 ms/op 547.79 ms/op 0.96
BeaconState.validators vc 300000 - serialize tree 111.18 ms/op 98.385 ms/op 1.13
BeaconState.balances vc 300000 - deserialize tree 20.140 ms/op 23.017 ms/op 0.88
BeaconState.balances vc 300000 - serialize tree 3.7641 ms/op 2.8993 ms/op 1.30
BeaconState.previousEpochParticipation vc 300000 - deserialize tree 423.60 us/op 330.08 us/op 1.28
BeaconState.previousEpochParticipation vc 300000 - serialize tree 280.87 us/op 269.52 us/op 1.04
BeaconState.currentEpochParticipation vc 300000 - deserialize tree 459.64 us/op 333.11 us/op 1.38
BeaconState.currentEpochParticipation vc 300000 - serialize tree 284.54 us/op 264.88 us/op 1.07
BeaconState.inactivityScores vc 300000 - deserialize tree 19.556 ms/op 16.154 ms/op 1.21
BeaconState.inactivityScores vc 300000 - serialize tree 3.5022 ms/op 3.4338 ms/op 1.02
hashTreeRoot Attestation - struct 32.873 us/op 30.822 us/op 1.07
hashTreeRoot Attestation - tree 19.979 us/op 18.097 us/op 1.10
hashTreeRoot SignedAggregateAndProof - struct 43.735 us/op 42.596 us/op 1.03
hashTreeRoot SignedAggregateAndProof - tree 29.754 us/op 28.453 us/op 1.05
hashTreeRoot SyncCommitteeMessage - struct 10.525 us/op 10.025 us/op 1.05
hashTreeRoot SyncCommitteeMessage - tree 6.5670 us/op 6.2560 us/op 1.05
hashTreeRoot SignedContributionAndProof - struct 30.208 us/op 28.525 us/op 1.06
hashTreeRoot SignedContributionAndProof - tree 21.522 us/op 20.204 us/op 1.07
hashTreeRoot SignedBeaconBlock - struct 2.4970 ms/op 2.3373 ms/op 1.07
hashTreeRoot SignedBeaconBlock - tree 1.7736 ms/op 1.6751 ms/op 1.06
hashTreeRoot Validator - struct 13.710 us/op 12.879 us/op 1.06
hashTreeRoot Validator - tree 11.646 us/op 11.140 us/op 1.05
BeaconState vc 300000 - hashTreeRoot tree 3.8300 s/op 3.6818 s/op 1.04
BeaconState.historicalRoots vc 300000 - hashTreeRoot tree 1.5260 us/op 1.4570 us/op 1.05
BeaconState.validators vc 300000 - hashTreeRoot tree 3.6464 s/op 3.4889 s/op 1.05
BeaconState.balances vc 300000 - hashTreeRoot tree 94.622 ms/op 88.129 ms/op 1.07
BeaconState.previousEpochParticipation vc 300000 - hashTreeRoot tree 9.5696 ms/op 9.0431 ms/op 1.06
BeaconState.currentEpochParticipation vc 300000 - hashTreeRoot tree 9.5696 ms/op 9.1932 ms/op 1.04
BeaconState.inactivityScores vc 300000 - hashTreeRoot tree 87.203 ms/op 82.965 ms/op 1.05
hash64 x18 20.905 us/op 19.748 us/op 1.06
hashTwoObjects x18 19.540 us/op 18.014 us/op 1.08
hash64 x1740 1.9506 ms/op 1.8368 ms/op 1.06
hashTwoObjects x1740 1.8225 ms/op 1.7150 ms/op 1.06
hash64 x2700000 3.0634 s/op 2.8577 s/op 1.07
hashTwoObjects x2700000 2.8204 s/op 2.6681 s/op 1.06
get_exitEpoch - ContainerType 222.00 ns/op 216.00 ns/op 1.03
get_exitEpoch - ContainerNodeStructType 218.00 ns/op 217.00 ns/op 1.00
set_exitEpoch - ContainerType 253.00 ns/op 241.00 ns/op 1.05
set_exitEpoch - ContainerNodeStructType 217.00 ns/op 209.00 ns/op 1.04
get_pubkey - ContainerType 1.0750 us/op 1.0260 us/op 1.05
get_pubkey - ContainerNodeStructType 229.00 ns/op 205.00 ns/op 1.12
hashTreeRoot - ContainerType 419.00 ns/op 402.00 ns/op 1.04
hashTreeRoot - ContainerNodeStructType 443.00 ns/op 447.00 ns/op 0.99
createProof - ContainerType 3.9450 us/op 4.0010 us/op 0.99
createProof - ContainerNodeStructType 22.546 us/op 21.490 us/op 1.05
serialize - ContainerType 1.7610 us/op 1.7770 us/op 0.99
serialize - ContainerNodeStructType 1.4710 us/op 1.5060 us/op 0.98
set_exitEpoch_and_hashTreeRoot - ContainerType 4.2520 us/op 4.0980 us/op 1.04
set_exitEpoch_and_hashTreeRoot - ContainerNodeStructType 12.005 us/op 11.258 us/op 1.07
Array - for of 8.9490 us/op 4.8960 us/op 1.83
Array - for(;;) 7.7090 us/op 4.3240 us/op 1.78
basicListValue.readonlyValuesArray() 3.9653 ms/op 3.9963 ms/op 0.99
basicListValue.readonlyValuesArray() + loop all 4.2874 ms/op 4.0088 ms/op 1.07
compositeListValue.readonlyValuesArray() 29.394 ms/op 29.343 ms/op 1.00
compositeListValue.readonlyValuesArray() + loop all 25.306 ms/op 25.721 ms/op 0.98
Number64UintType - get balances list 4.2063 ms/op 4.1484 ms/op 1.01
Number64UintType - set balances list 10.064 ms/op 10.053 ms/op 1.00
Number64UintType - get and increase 10 then set 38.828 ms/op 39.758 ms/op 0.98
Number64UintType - increase 10 using applyDelta 16.895 ms/op 15.934 ms/op 1.06
Number64UintType - increase 10 using applyDeltaInBatch 16.959 ms/op 16.722 ms/op 1.01
tree_newTreeFromUint64Deltas 16.703 ms/op 15.668 ms/op 1.07
unsafeUint8ArrayToTree 29.681 ms/op 29.900 ms/op 0.99
bitLength(50) 231.00 ns/op 235.00 ns/op 0.98
bitLengthStr(50) 239.00 ns/op 250.00 ns/op 0.96
bitLength(8000) 234.00 ns/op 227.00 ns/op 1.03
bitLengthStr(8000) 280.00 ns/op 285.00 ns/op 0.98
bitLength(250000) 230.00 ns/op 225.00 ns/op 1.02
bitLengthStr(250000) 336.00 ns/op 326.00 ns/op 1.03
floor - Math.floor (53) 0.46372 ns/op 0.46587 ns/op 1.00
floor - << 0 (53) 0.47199 ns/op 0.46457 ns/op 1.02
floor - Math.floor (512) 0.46543 ns/op 0.46432 ns/op 1.00
floor - << 0 (512) 0.46549 ns/op 0.47131 ns/op 0.99
fnIf(0) 1.5678 ns/op 1.5465 ns/op 1.01
fnSwitch(0) 2.4741 ns/op 2.5243 ns/op 0.98
fnObj(0) 0.48051 ns/op 0.46395 ns/op 1.04
fnArr(0) 0.46486 ns/op 0.46537 ns/op 1.00
fnIf(4) 2.1636 ns/op 2.1709 ns/op 1.00
fnSwitch(4) 2.4742 ns/op 2.4745 ns/op 1.00
fnObj(4) 0.47167 ns/op 0.46438 ns/op 1.02
fnArr(4) 0.46381 ns/op 0.46647 ns/op 0.99
fnIf(9) 3.1365 ns/op 3.0910 ns/op 1.01
fnSwitch(9) 2.4738 ns/op 2.4859 ns/op 1.00
fnObj(9) 0.46572 ns/op 0.46528 ns/op 1.00
fnArr(9) 0.46401 ns/op 0.47203 ns/op 0.98
Container {a,b,vec} - as struct x100000 47.254 us/op 46.695 us/op 1.01
Container {a,b,vec} - as tree x100000 372.24 us/op 371.38 us/op 1.00
Container {a,vec,b} - as struct x100000 78.177 us/op 78.555 us/op 1.00
Container {a,vec,b} - as tree x100000 402.22 us/op 402.19 us/op 1.00
get 2 props x1000000 - rawObject 309.41 us/op 309.29 us/op 1.00
get 2 props x1000000 - proxy 71.198 ms/op 72.221 ms/op 0.99
get 2 props x1000000 - customObj 309.42 us/op 310.22 us/op 1.00
Simple object binary -> struct 651.00 ns/op 642.00 ns/op 1.01
Simple object binary -> tree_backed 1.6910 us/op 1.6770 us/op 1.01
Simple object struct -> tree_backed 2.1690 us/op 2.1900 us/op 0.99
Simple object tree_backed -> struct 1.9050 us/op 1.9030 us/op 1.00
Simple object struct -> binary 914.00 ns/op 896.00 ns/op 1.02
Simple object tree_backed -> binary 1.5700 us/op 1.4930 us/op 1.05
aggregationBits binary -> struct 575.00 ns/op 559.00 ns/op 1.03
aggregationBits binary -> tree_backed 2.2180 us/op 2.1680 us/op 1.02
aggregationBits struct -> tree_backed 2.7170 us/op 2.5820 us/op 1.05
aggregationBits tree_backed -> struct 1.0930 us/op 1.0620 us/op 1.03
aggregationBits struct -> binary 782.00 ns/op 765.00 ns/op 1.02
aggregationBits tree_backed -> binary 952.00 ns/op 912.00 ns/op 1.04
List(uint8) 100000 binary -> struct 1.4088 ms/op 1.4138 ms/op 1.00
List(uint8) 100000 binary -> tree_backed 89.376 us/op 92.033 us/op 0.97
List(uint8) 100000 struct -> tree_backed 1.3133 ms/op 1.3474 ms/op 0.97
List(uint8) 100000 tree_backed -> struct 989.11 us/op 935.05 us/op 1.06
List(uint8) 100000 struct -> binary 1.2842 ms/op 1.2047 ms/op 1.07
List(uint8) 100000 tree_backed -> binary 82.913 us/op 85.075 us/op 0.97
List(uint64Number) 100000 binary -> struct 1.1713 ms/op 1.1630 ms/op 1.01
List(uint64Number) 100000 binary -> tree_backed 3.0193 ms/op 3.0756 ms/op 0.98
List(uint64Number) 100000 struct -> tree_backed 4.5752 ms/op 4.6349 ms/op 0.99
List(uint64Number) 100000 tree_backed -> struct 2.0933 ms/op 2.1046 ms/op 0.99
List(uint64Number) 100000 struct -> binary 1.4679 ms/op 1.4424 ms/op 1.02
List(uint64Number) 100000 tree_backed -> binary 777.36 us/op 821.54 us/op 0.95
List(Uint64Bigint) 100000 binary -> struct 3.4830 ms/op 3.4725 ms/op 1.00
List(Uint64Bigint) 100000 binary -> tree_backed 2.9966 ms/op 3.0211 ms/op 0.99
List(Uint64Bigint) 100000 struct -> tree_backed 5.2962 ms/op 5.1078 ms/op 1.04
List(Uint64Bigint) 100000 tree_backed -> struct 4.4014 ms/op 4.3443 ms/op 1.01
List(Uint64Bigint) 100000 struct -> binary 2.0196 ms/op 2.0732 ms/op 0.97
List(Uint64Bigint) 100000 tree_backed -> binary 883.56 us/op 937.51 us/op 0.94
Vector(Root) 100000 binary -> struct 28.156 ms/op 27.678 ms/op 1.02
Vector(Root) 100000 binary -> tree_backed 30.028 ms/op 29.364 ms/op 1.02
Vector(Root) 100000 struct -> tree_backed 33.651 ms/op 33.369 ms/op 1.01
Vector(Root) 100000 tree_backed -> struct 43.420 ms/op 43.151 ms/op 1.01
Vector(Root) 100000 struct -> binary 1.8585 ms/op 1.8679 ms/op 0.99
Vector(Root) 100000 tree_backed -> binary 8.9172 ms/op 8.5358 ms/op 1.04
List(Validator) 100000 binary -> struct 98.688 ms/op 104.69 ms/op 0.94
List(Validator) 100000 binary -> tree_backed 261.56 ms/op 273.37 ms/op 0.96
List(Validator) 100000 struct -> tree_backed 292.98 ms/op 295.71 ms/op 0.99
List(Validator) 100000 tree_backed -> struct 195.61 ms/op 191.71 ms/op 1.02
List(Validator) 100000 struct -> binary 31.259 ms/op 31.039 ms/op 1.01
List(Validator) 100000 tree_backed -> binary 98.499 ms/op 95.991 ms/op 1.03
List(Validator-NS) 100000 binary -> struct 95.346 ms/op 96.884 ms/op 0.98
List(Validator-NS) 100000 binary -> tree_backed 151.93 ms/op 153.07 ms/op 0.99
List(Validator-NS) 100000 struct -> tree_backed 183.18 ms/op 190.48 ms/op 0.96
List(Validator-NS) 100000 tree_backed -> struct 154.78 ms/op 151.71 ms/op 1.02
List(Validator-NS) 100000 struct -> binary 31.996 ms/op 31.352 ms/op 1.02
List(Validator-NS) 100000 tree_backed -> binary 39.304 ms/op 36.683 ms/op 1.07
get epochStatuses - MutableVector 87.713 us/op 89.932 us/op 0.98
get epochStatuses - ViewDU 202.09 us/op 206.80 us/op 0.98
set epochStatuses - ListTreeView 1.4244 ms/op 1.4231 ms/op 1.00
set epochStatuses - ListTreeView - set() 442.73 us/op 436.29 us/op 1.01
set epochStatuses - ListTreeView - commit() 407.38 us/op 445.32 us/op 0.91
bitstring 639.19 ns/op 642.41 ns/op 0.99
bit mask 13.757 ns/op 13.538 ns/op 1.02
struct - increase slot to 1000000 928.16 us/op 928.07 us/op 1.00
UintNumberType - increase slot to 1000000 28.471 ms/op 28.481 ms/op 1.00
UintBigintType - increase slot to 1000000 416.53 ms/op 430.69 ms/op 0.97
UintBigint8 x 100000 tree_deserialize 4.5578 ms/op 5.4886 ms/op 0.83
UintBigint8 x 100000 tree_serialize 1.1856 ms/op 1.1857 ms/op 1.00
UintBigint16 x 100000 tree_deserialize 4.6393 ms/op 4.6997 ms/op 0.99
UintBigint16 x 100000 tree_serialize 1.1509 ms/op 1.1887 ms/op 0.97
UintBigint32 x 100000 tree_deserialize 4.8030 ms/op 5.7579 ms/op 0.83
UintBigint32 x 100000 tree_serialize 1.2275 ms/op 1.2441 ms/op 0.99
UintBigint64 x 100000 tree_deserialize 5.5593 ms/op 6.2432 ms/op 0.89
UintBigint64 x 100000 tree_serialize 1.5860 ms/op 1.6056 ms/op 0.99
UintBigint8 x 100000 value_deserialize 433.06 us/op 433.18 us/op 1.00
UintBigint8 x 100000 value_serialize 618.31 us/op 613.44 us/op 1.01
UintBigint16 x 100000 value_deserialize 463.81 us/op 464.43 us/op 1.00
UintBigint16 x 100000 value_serialize 629.69 us/op 653.41 us/op 0.96
UintBigint32 x 100000 value_deserialize 433.11 us/op 433.40 us/op 1.00
UintBigint32 x 100000 value_serialize 642.47 us/op 651.03 us/op 0.99
UintBigint64 x 100000 value_deserialize 481.28 us/op 465.83 us/op 1.03
UintBigint64 x 100000 value_serialize 810.71 us/op 825.39 us/op 0.98
UintBigint8 x 100000 deserialize 4.8796 ms/op 4.6694 ms/op 1.05
UintBigint8 x 100000 serialize 1.4485 ms/op 1.4428 ms/op 1.00
UintBigint16 x 100000 deserialize 4.5553 ms/op 4.5884 ms/op 0.99
UintBigint16 x 100000 serialize 1.5082 ms/op 1.5044 ms/op 1.00
UintBigint32 x 100000 deserialize 5.5625 ms/op 5.3718 ms/op 1.04
UintBigint32 x 100000 serialize 2.7629 ms/op 2.7840 ms/op 0.99
UintBigint64 x 100000 deserialize 3.6635 ms/op 3.6328 ms/op 1.01
UintBigint64 x 100000 serialize 1.5072 ms/op 1.4816 ms/op 1.02
UintBigint128 x 100000 deserialize 5.8034 ms/op 5.7264 ms/op 1.01
UintBigint128 x 100000 serialize 16.715 ms/op 17.443 ms/op 0.96
UintBigint256 x 100000 deserialize 11.005 ms/op 10.643 ms/op 1.03
UintBigint256 x 100000 serialize 50.832 ms/op 51.289 ms/op 0.99
Slice from Uint8Array x25000 1.0241 ms/op 997.24 us/op 1.03
Slice from ArrayBuffer x25000 17.457 ms/op 17.436 ms/op 1.00
Slice from ArrayBuffer x25000 + new Uint8Array 18.863 ms/op 18.399 ms/op 1.03
Copy Uint8Array 100000 iterate 918.89 us/op 806.68 us/op 1.14
Copy Uint8Array 100000 slice 140.32 us/op 91.493 us/op 1.53
Copy Uint8Array 100000 Uint8Array.prototype.slice.call 130.31 us/op 91.705 us/op 1.42
Copy Buffer 100000 Uint8Array.prototype.slice.call 127.68 us/op 91.953 us/op 1.39
Copy Uint8Array 100000 slice + set 252.52 us/op 151.79 us/op 1.66
Copy Uint8Array 100000 subarray + set 131.61 us/op 91.115 us/op 1.44
Copy Uint8Array 100000 slice arrayBuffer 129.30 us/op 92.415 us/op 1.40
Uint64 deserialize 100000 - iterate Uint8Array 1.7542 ms/op 1.7589 ms/op 1.00
Uint64 deserialize 100000 - by Uint32A 1.7462 ms/op 1.7543 ms/op 1.00
Uint64 deserialize 100000 - by DataView.getUint32 x2 1.7322 ms/op 1.7946 ms/op 0.97
Uint64 deserialize 100000 - by DataView.getBigUint64 4.8168 ms/op 4.8848 ms/op 0.99
Uint64 deserialize 100000 - by byte 65.218 ms/op 65.296 ms/op 1.00

by benchmarkbot/action

@twoeths
Copy link
Contributor Author

twoeths commented Mar 25, 2024

benchmark is consistently worse in CI, however on feat4 mainnet node and my local env it's better

master

 ✓ digestTwoHashObjects 50023 times                                    20.73418 ops/s    48.22953 ms/op        -       1233 runs   60.0 s
 ✓ digest64 50023 times                                                19.74772 ops/s    50.63876 ms/op        -       1175 runs   60.0 s
 ✓ digest 50023 times                                                  19.73773 ops/s    50.66439 ms/op        -       1174 runs   60.0 s

this branch

✓ digestTwoHashObjects 50023 times                                    22.70416 ops/s    44.04479 ms/op        -       1351 runs   60.0 s
✓ digest64 50023 times                                                21.21962 ops/s    47.12619 ms/op        -       1263 runs   60.0 s
✓ digest 50023 times                                                  21.01592 ops/s    47.58299 ms/op        -       1250 runs   60.0 s

@github-actions github-actions bot added the CI label Mar 25, 2024
@twoeths twoeths closed this May 25, 2024
@twoeths twoeths deleted the tuyen/chain_w_computation_2 branch May 25, 2024 01:30
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.

Improve performance of digest64
1 participant