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

feat: implement ViewDU.batchHashTreeRoot() #392

Merged
merged 5 commits into from
Sep 4, 2024

Conversation

twoeths
Copy link
Contributor

@twoeths twoeths commented Aug 9, 2024

Motivation

  • Implement batchHashTreeRoot() for ViewDU type based on HashComputation

Description

  • hashTreeRoot() is still great because it does not allocate any memory so we need a new method to compute batch
  • in packages/ssz/src/viewDU/abstract.ts, add batchHashTreeRoot() method
    • param is HashComputationGroup in previous PR 389
    • param is designed to be reused
  • add new params to commit() method:
    • hcOffset: offset from the top level
    • hcByLevel: an array of HashComputationLevel[] or null.
    • when hcByLevel is null, it means it was called from hashTreeRoot(), commit() method should be backward compatible in this case
    • ContainerNodeStructTreeViewDU:
      • when commit(), it's unchanged
      • if there is a not null hcByLevel, it should compute root because this ViewDU does not support HashComputation

cherry picked from #378

Unit Tests

  • I added a bunch of tests to make sure batchHashTreeRoot() returns the same value to hashTreeRoot, please suggest if we need more

part of #355

@github-actions github-actions bot added the ssz label Aug 9, 2024
Copy link

github-actions bot commented Aug 9, 2024

Performance Report

✔️ no performance regression detected

🚀🚀 Significant benchmark improvement detected

Benchmark suite Current: 7b85830 Previous: 9ddd92e Ratio
batchHash 250000 nodes 79.628 ms/op 330.93 ms/op 0.24
get root 250000 nodes 117.03 ms/op 941.57 ms/op 0.12
batchHash 500000 nodes 146.17 ms/op 588.78 ms/op 0.25
get root 500000 nodes 243.82 ms/op 1.8408 s/op 0.13
batchHash 1000000 nodes 354.54 ms/op 1.1791 s/op 0.30
get root 1000000 nodes 468.08 ms/op 3.4866 s/op 0.13
250000 validators root getter 117.22 ms/op 843.44 ms/op 0.14
250000 validators batchHash() 80.605 ms/op 301.57 ms/op 0.27
Full benchmark results
Benchmark suite Current: 7b85830 Previous: 9ddd92e Ratio
digestTwoHashObjects 50023 times 47.693 ms/op 48.207 ms/op 0.99
digest64 50023 times 53.641 ms/op 54.508 ms/op 0.98
digest 50023 times 54.523 ms/op 58.536 ms/op 0.93
input length 32 1.2020 us/op 1.2390 us/op 0.97
input length 64 1.3460 us/op 1.3750 us/op 0.98
input length 128 2.2880 us/op 2.3930 us/op 0.96
input length 256 3.3730 us/op 3.5360 us/op 0.95
input length 512 5.5920 us/op 5.8520 us/op 0.96
input length 1024 10.680 us/op 11.052 us/op 0.97
digest 1000000 times 889.92 ms/op 971.28 ms/op 0.92
hashObjectToByteArray 50023 times 1.4299 ms/op 1.4329 ms/op 1.00
byteArrayToHashObject 50023 times 2.4397 ms/op 2.5370 ms/op 0.96
digest64 200092 times 217.89 ms/op 232.56 ms/op 0.94
hash 200092 times using batchHash4UintArray64s 236.26 ms/op 253.19 ms/op 0.93
digest64HashObjects 200092 times 191.49 ms/op 198.92 ms/op 0.96
hash 200092 times using batchHash4HashObjectInputs 208.72 ms/op 217.80 ms/op 0.96
getGindicesAtDepth 4.4070 us/op 4.2860 us/op 1.03
iterateAtDepth 7.5750 us/op 7.6520 us/op 0.99
getGindexBits 460.00 ns/op 467.00 ns/op 0.99
gindexIterator 1.0600 us/op 1.0710 us/op 0.99
HashComputationLevel.push then loop 25.849 ms/op 28.086 ms/op 0.92
HashComputation[] push then loop 47.473 ms/op 39.696 ms/op 1.20
hash 2 Uint8Array 500000 times - as-sha256 540.25 ms/op 548.64 ms/op 0.98
hashTwoObjects 500000 times - as-sha256 504.36 ms/op 504.10 ms/op 1.00
executeHashComputations - as-sha256 46.389 ms/op 47.872 ms/op 0.97
hash 2 Uint8Array 500000 times - noble 1.0595 s/op 1.1972 s/op 0.89
hashTwoObjects 500000 times - noble 1.4865 s/op 1.6944 s/op 0.88
executeHashComputations - noble 40.966 ms/op 42.299 ms/op 0.97
hash 2 Uint8Array 500000 times - hashtree 224.04 ms/op 234.10 ms/op 0.96
hashTwoObjects 500000 times - hashtree 213.85 ms/op 215.17 ms/op 0.99
executeHashComputations - hashtree 10.654 ms/op 11.889 ms/op 0.90
getHashComputations 2.8532 ms/op
executeHashComputations 11.315 ms/op
get root 15.797 ms/op
getNodeH() x7812.5 avg hindex 12.163 us/op 12.114 us/op 1.00
getNodeH() x7812.5 index 0 6.2380 us/op 6.3570 us/op 0.98
getNodeH() x7812.5 index 7 6.2940 us/op 6.3110 us/op 1.00
getNodeH() x7812.5 index 7 with key array 6.2320 us/op 6.2750 us/op 0.99
new LeafNode() x7812.5 14.728 us/op 14.743 us/op 1.00
getHashComputations 250000 nodes 14.737 ms/op 21.088 ms/op 0.70
batchHash 250000 nodes 79.628 ms/op 330.93 ms/op 0.24
get root 250000 nodes 117.03 ms/op 941.57 ms/op 0.12
getHashComputations 500000 nodes 28.106 ms/op 31.264 ms/op 0.90
batchHash 500000 nodes 146.17 ms/op 588.78 ms/op 0.25
get root 500000 nodes 243.82 ms/op 1.8408 s/op 0.13
getHashComputations 1000000 nodes 69.885 ms/op 56.534 ms/op 1.24
batchHash 1000000 nodes 354.54 ms/op 1.1791 s/op 0.30
get root 1000000 nodes 468.08 ms/op 3.4866 s/op 0.13
multiproof - depth 15, 1 requested leaves 8.5840 us/op 8.9930 us/op 0.95
tree offset multiproof - depth 15, 1 requested leaves 18.273 us/op 19.928 us/op 0.92
compact multiproof - depth 15, 1 requested leaves 3.4490 us/op 4.0510 us/op 0.85
multiproof - depth 15, 2 requested leaves 11.899 us/op 13.415 us/op 0.89
tree offset multiproof - depth 15, 2 requested leaves 21.784 us/op 24.558 us/op 0.89
compact multiproof - depth 15, 2 requested leaves 3.3880 us/op 4.1850 us/op 0.81
multiproof - depth 15, 3 requested leaves 17.082 us/op 18.186 us/op 0.94
tree offset multiproof - depth 15, 3 requested leaves 27.808 us/op 30.439 us/op 0.91
compact multiproof - depth 15, 3 requested leaves 4.1010 us/op 5.4710 us/op 0.75
multiproof - depth 15, 4 requested leaves 22.115 us/op 23.773 us/op 0.93
tree offset multiproof - depth 15, 4 requested leaves 34.495 us/op 38.363 us/op 0.90
compact multiproof - depth 15, 4 requested leaves 4.7120 us/op 5.8120 us/op 0.81
packedRootsBytesToLeafNodes bytes 4000 offset 0 2.0140 us/op 2.1070 us/op 0.96
packedRootsBytesToLeafNodes bytes 4000 offset 1 1.9980 us/op 2.0840 us/op 0.96
packedRootsBytesToLeafNodes bytes 4000 offset 2 2.0410 us/op 2.1210 us/op 0.96
packedRootsBytesToLeafNodes bytes 4000 offset 3 2.0220 us/op 2.0860 us/op 0.97
subtreeFillToContents depth 40 count 250000 42.848 ms/op 41.442 ms/op 1.03
setRoot - gindexBitstring 8.9377 ms/op 10.870 ms/op 0.82
setRoot - gindex 9.1325 ms/op 11.565 ms/op 0.79
getRoot - gindexBitstring 2.3909 ms/op 2.7848 ms/op 0.86
getRoot - gindex 3.2643 ms/op 3.7252 ms/op 0.88
getHashObject then setHashObject 10.016 ms/op 12.298 ms/op 0.81
setNodeWithFn 7.6391 ms/op 9.7927 ms/op 0.78
getNodeAtDepth depth 0 x100000 1.1138 ms/op 1.1129 ms/op 1.00
setNodeAtDepth depth 0 x100000 2.4037 ms/op 2.9984 ms/op 0.80
getNodesAtDepth depth 0 x100000 1.0672 ms/op 1.0527 ms/op 1.01
setNodesAtDepth depth 0 x100000 1.5156 ms/op 1.5160 ms/op 1.00
getNodeAtDepth depth 1 x100000 1.1822 ms/op 1.1871 ms/op 1.00
setNodeAtDepth depth 1 x100000 6.6439 ms/op 6.3005 ms/op 1.05
getNodesAtDepth depth 1 x100000 1.1789 ms/op 1.1842 ms/op 1.00
setNodesAtDepth depth 1 x100000 4.7586 ms/op 5.2877 ms/op 0.90
getNodeAtDepth depth 2 x100000 1.4553 ms/op 1.4571 ms/op 1.00
setNodeAtDepth depth 2 x100000 9.2897 ms/op 10.632 ms/op 0.87
getNodesAtDepth depth 2 x100000 17.666 ms/op 21.886 ms/op 0.81
setNodesAtDepth depth 2 x100000 13.503 ms/op 15.969 ms/op 0.85
tree.getNodesAtDepth - gindexes 7.5686 ms/op 8.2350 ms/op 0.92
tree.getNodesAtDepth - push all nodes 1.8907 ms/op 1.8288 ms/op 1.03
tree.getNodesAtDepth - navigation 234.15 us/op 237.85 us/op 0.98
tree.setNodesAtDepth - indexes 427.61 us/op 405.54 us/op 1.05
set at depth 8 448.00 ns/op 483.00 ns/op 0.93
set at depth 16 583.00 ns/op 625.00 ns/op 0.93
set at depth 32 910.00 ns/op 943.00 ns/op 0.97
iterateNodesAtDepth 8 256 13.121 us/op 13.727 us/op 0.96
getNodesAtDepth 8 256 3.3400 us/op 3.5450 us/op 0.94
iterateNodesAtDepth 16 65536 4.1979 ms/op 4.4479 ms/op 0.94
getNodesAtDepth 16 65536 1.5259 ms/op 1.4732 ms/op 1.04
iterateNodesAtDepth 32 250000 14.991 ms/op 16.033 ms/op 0.94
getNodesAtDepth 32 250000 4.2592 ms/op 4.2836 ms/op 0.99
iterateNodesAtDepth 40 250000 15.386 ms/op 15.722 ms/op 0.98
getNodesAtDepth 40 250000 4.2689 ms/op 4.5197 ms/op 0.94
250000 validators root getter 117.22 ms/op 843.44 ms/op 0.14
250000 validators batchHash() 80.605 ms/op 301.57 ms/op 0.27
250000 validators hashComputations 13.770 ms/op 15.302 ms/op 0.90
bitlist bytes to struct (120,90) 986.00 ns/op 732.00 ns/op 1.35
bitlist bytes to tree (120,90) 3.7770 us/op 2.8910 us/op 1.31
bitlist bytes to struct (2048,2048) 1.4070 us/op 1.1820 us/op 1.19
bitlist bytes to tree (2048,2048) 4.3150 us/op 4.3820 us/op 0.98
ByteListType - deserialize 7.9896 ms/op 8.6762 ms/op 0.92
BasicListType - deserialize 18.053 ms/op 18.295 ms/op 0.99
ByteListType - serialize 7.9675 ms/op 8.6726 ms/op 0.92
BasicListType - serialize 11.045 ms/op 11.335 ms/op 0.97
BasicListType - tree_convertToStruct 29.648 ms/op 30.654 ms/op 0.97
List[uint8, 68719476736] len 300000 ViewDU.getAll() + iterate 4.6553 ms/op 5.4730 ms/op 0.85
List[uint8, 68719476736] len 300000 ViewDU.get(i) 3.9786 ms/op 4.0056 ms/op 0.99
Array.push len 300000 empty Array - number 6.4065 ms/op 7.4131 ms/op 0.86
Array.set len 300000 from new Array - number 1.7325 ms/op 2.2360 ms/op 0.77
Array.set len 300000 - number 5.3255 ms/op 6.8112 ms/op 0.78
Uint8Array.set len 300000 367.71 us/op 385.98 us/op 0.95
Uint32Array.set len 300000 434.92 us/op 476.84 us/op 0.91
Container({a: uint8, b: uint8}) getViewDU x300000 49.926 ms/op 54.519 ms/op 0.92
ContainerNodeStruct({a: uint8, b: uint8}) getViewDU x300000 10.664 ms/op 11.662 ms/op 0.91
List(Container) len 300000 ViewDU.getAllReadonly() + iterate 200.79 ms/op 221.55 ms/op 0.91
List(Container) len 300000 ViewDU.getAllReadonlyValues() + iterate 236.84 ms/op 275.28 ms/op 0.86
List(Container) len 300000 ViewDU.get(i) 6.1509 ms/op 7.2031 ms/op 0.85
List(Container) len 300000 ViewDU.getReadonly(i) 6.0512 ms/op 7.0788 ms/op 0.85
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonly() + iterate 33.521 ms/op 40.098 ms/op 0.84
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonlyValues() + iterate 5.6289 ms/op 5.2443 ms/op 1.07
List(ContainerNodeStruct) len 300000 ViewDU.get(i) 5.8633 ms/op 6.7769 ms/op 0.87
List(ContainerNodeStruct) len 300000 ViewDU.getReadonly(i) 5.7204 ms/op 6.7594 ms/op 0.85
Array.push len 300000 empty Array - object 5.9801 ms/op 6.8533 ms/op 0.87
Array.set len 300000 from new Array - object 2.1864 ms/op 2.1301 ms/op 1.03
Array.set len 300000 - object 6.5348 ms/op 6.6165 ms/op 0.99
cachePermanentRootStruct no cache 5.0950 us/op 5.9120 us/op 0.86
cachePermanentRootStruct with cache 196.00 ns/op 250.00 ns/op 0.78
epochParticipation len 250000 rws 7813 2.1165 ms/op 2.1873 ms/op 0.97
BeaconState ViewDU hashTreeRoot() vc=200000 102.56 ms/op
BeaconState ViewDU recursive hash - commit step vc=200000 4.2929 ms/op
BeaconState ViewDU validator tree creation vc=10000 33.848 ms/op
BeaconState ViewDU batchHashTreeRoot vc=200000 91.820 ms/op
BeaconState ViewDU hashTreeRoot - commit step vc=200000 80.318 ms/op
BeaconState ViewDU hashTreeRoot - hash step vc=200000 14.936 ms/op
deserialize Attestation - tree 4.0160 us/op 4.3940 us/op 0.91
deserialize Attestation - struct 1.7490 us/op 2.0750 us/op 0.84
deserialize SignedAggregateAndProof - tree 3.7260 us/op 4.3020 us/op 0.87
deserialize SignedAggregateAndProof - struct 2.8160 us/op 3.3540 us/op 0.84
deserialize SyncCommitteeMessage - tree 1.0260 us/op 1.1870 us/op 0.86
deserialize SyncCommitteeMessage - struct 1.0730 us/op 1.2440 us/op 0.86
deserialize SignedContributionAndProof - tree 2.0330 us/op 2.4320 us/op 0.84
deserialize SignedContributionAndProof - struct 2.1890 us/op 2.6260 us/op 0.83
deserialize SignedBeaconBlock - tree 206.84 us/op 240.15 us/op 0.86
deserialize SignedBeaconBlock - struct 114.66 us/op 136.40 us/op 0.84
BeaconState vc 300000 - deserialize tree 615.10 ms/op 619.83 ms/op 0.99
BeaconState vc 300000 - serialize tree 167.92 ms/op 139.41 ms/op 1.20
BeaconState.historicalRoots vc 300000 - deserialize tree 777.00 ns/op 814.00 ns/op 0.95
BeaconState.historicalRoots vc 300000 - serialize tree 623.00 ns/op 696.00 ns/op 0.90
BeaconState.validators vc 300000 - deserialize tree 573.22 ms/op 554.70 ms/op 1.03
BeaconState.validators vc 300000 - serialize tree 104.58 ms/op 95.358 ms/op 1.10
BeaconState.balances vc 300000 - deserialize tree 23.232 ms/op 21.411 ms/op 1.09
BeaconState.balances vc 300000 - serialize tree 3.2732 ms/op 4.7876 ms/op 0.68
BeaconState.previousEpochParticipation vc 300000 - deserialize tree 337.50 us/op 485.70 us/op 0.69
BeaconState.previousEpochParticipation vc 300000 - serialize tree 274.42 us/op 276.64 us/op 0.99
BeaconState.currentEpochParticipation vc 300000 - deserialize tree 339.71 us/op 483.02 us/op 0.70
BeaconState.currentEpochParticipation vc 300000 - serialize tree 269.97 us/op 256.88 us/op 1.05
BeaconState.inactivityScores vc 300000 - deserialize tree 23.449 ms/op 17.028 ms/op 1.38
BeaconState.inactivityScores vc 300000 - serialize tree 3.3314 ms/op 8.2712 ms/op 0.40
hashTreeRoot Attestation - struct 19.191 us/op 22.558 us/op 0.85
hashTreeRoot Attestation - tree 8.9470 us/op 10.752 us/op 0.83
hashTreeRoot SignedAggregateAndProof - struct 23.745 us/op 31.712 us/op 0.75
hashTreeRoot SignedAggregateAndProof - tree 12.832 us/op 13.212 us/op 0.97
hashTreeRoot SyncCommitteeMessage - struct 6.1250 us/op 9.0310 us/op 0.68
hashTreeRoot SyncCommitteeMessage - tree 3.1340 us/op 3.1700 us/op 0.99
hashTreeRoot SignedContributionAndProof - struct 14.610 us/op 22.300 us/op 0.66
hashTreeRoot SignedContributionAndProof - tree 8.8150 us/op 8.7980 us/op 1.00
hashTreeRoot SignedBeaconBlock - struct 1.2517 ms/op 1.6746 ms/op 0.75
hashTreeRoot SignedBeaconBlock - tree 760.23 us/op 780.47 us/op 0.97
hashTreeRoot Validator - struct 7.6980 us/op 10.701 us/op 0.72
hashTreeRoot Validator - tree 6.2310 us/op 7.9550 us/op 0.78
BeaconState vc 300000 - hashTreeRoot tree 2.0641 s/op 2.1302 s/op 0.97
BeaconState vc 300000 - batchHashTreeRoot tree 3.3556 s/op
BeaconState.historicalRoots vc 300000 - hashTreeRoot tree 963.00 ns/op 1.0670 us/op 0.90
BeaconState.validators vc 300000 - hashTreeRoot tree 2.0616 s/op 2.0591 s/op 1.00
BeaconState.balances vc 300000 - hashTreeRoot tree 32.858 ms/op 36.258 ms/op 0.91
BeaconState.previousEpochParticipation vc 300000 - hashTreeRoot tree 4.2633 ms/op 4.0742 ms/op 1.05
BeaconState.currentEpochParticipation vc 300000 - hashTreeRoot tree 4.0554 ms/op 4.0698 ms/op 1.00
BeaconState.inactivityScores vc 300000 - hashTreeRoot tree 32.790 ms/op 33.270 ms/op 0.99
hash64 x18 9.1570 us/op 9.6220 us/op 0.95
hashTwoObjects x18 8.6040 us/op 8.7250 us/op 0.99
hash64 x1740 828.30 us/op 881.87 us/op 0.94
hashTwoObjects x1740 797.24 us/op 803.07 us/op 0.99
hash64 x2700000 1.2742 s/op 1.3884 s/op 0.92
hashTwoObjects x2700000 1.2381 s/op 1.2535 s/op 0.99
get_exitEpoch - ContainerType 211.00 ns/op 259.00 ns/op 0.81
get_exitEpoch - ContainerNodeStructType 221.00 ns/op 251.00 ns/op 0.88
set_exitEpoch - ContainerType 219.00 ns/op 286.00 ns/op 0.77
set_exitEpoch - ContainerNodeStructType 220.00 ns/op 272.00 ns/op 0.81
get_pubkey - ContainerType 857.00 ns/op 1.1690 us/op 0.73
get_pubkey - ContainerNodeStructType 210.00 ns/op 274.00 ns/op 0.77
hashTreeRoot - ContainerType 374.00 ns/op 448.00 ns/op 0.83
hashTreeRoot - ContainerNodeStructType 416.00 ns/op 505.00 ns/op 0.82
createProof - ContainerType 4.0380 us/op 4.8590 us/op 0.83
createProof - ContainerNodeStructType 19.869 us/op 23.913 us/op 0.83
serialize - ContainerType 1.7590 us/op 1.8460 us/op 0.95
serialize - ContainerNodeStructType 1.3610 us/op 1.5260 us/op 0.89
set_exitEpoch_and_hashTreeRoot - ContainerType 2.4460 us/op 2.8020 us/op 0.87
set_exitEpoch_and_hashTreeRoot - ContainerNodeStructType 6.7500 us/op 7.2320 us/op 0.93
Array - for of 5.5880 us/op 5.6760 us/op 0.98
Array - for(;;) 5.5040 us/op 5.6540 us/op 0.97
basicListValue.readonlyValuesArray() 4.2022 ms/op 5.3683 ms/op 0.78
basicListValue.readonlyValuesArray() + loop all 4.2638 ms/op 5.7700 ms/op 0.74
compositeListValue.readonlyValuesArray() 31.396 ms/op 30.603 ms/op 1.03
compositeListValue.readonlyValuesArray() + loop all 29.808 ms/op 29.153 ms/op 1.02
Number64UintType - get balances list 3.9569 ms/op 4.5792 ms/op 0.86
Number64UintType - set balances list 10.029 ms/op 9.7039 ms/op 1.03
Number64UintType - get and increase 10 then set 38.382 ms/op 39.273 ms/op 0.98
Number64UintType - increase 10 using applyDelta 15.946 ms/op 16.164 ms/op 0.99
Number64UintType - increase 10 using applyDeltaInBatch 15.797 ms/op 16.097 ms/op 0.98
tree_newTreeFromUint64Deltas 17.061 ms/op 17.018 ms/op 1.00
unsafeUint8ArrayToTree 32.397 ms/op 33.472 ms/op 0.97
bitLength(50) 225.00 ns/op 259.00 ns/op 0.87
bitLengthStr(50) 217.00 ns/op 236.00 ns/op 0.92
bitLength(8000) 220.00 ns/op 261.00 ns/op 0.84
bitLengthStr(8000) 260.00 ns/op 277.00 ns/op 0.94
bitLength(250000) 224.00 ns/op 254.00 ns/op 0.88
bitLengthStr(250000) 299.00 ns/op 308.00 ns/op 0.97
floor - Math.floor (53) 1.2365 ns/op 1.2552 ns/op 0.99
floor - << 0 (53) 1.2378 ns/op 1.2371 ns/op 1.00
floor - Math.floor (512) 1.2373 ns/op 1.2384 ns/op 1.00
floor - << 0 (512) 1.2369 ns/op 1.2374 ns/op 1.00
fnIf(0) 1.5458 ns/op 1.5477 ns/op 1.00
fnSwitch(0) 2.1652 ns/op 2.1881 ns/op 0.99
fnObj(0) 1.5490 ns/op 1.5536 ns/op 1.00
fnArr(0) 1.5464 ns/op 1.5703 ns/op 0.98
fnIf(4) 2.2004 ns/op 2.1651 ns/op 1.02
fnSwitch(4) 2.1655 ns/op 2.1992 ns/op 0.98
fnObj(4) 1.5562 ns/op 1.5667 ns/op 0.99
fnArr(4) 1.5484 ns/op 1.5491 ns/op 1.00
fnIf(9) 3.0930 ns/op 3.0923 ns/op 1.00
fnSwitch(9) 2.1672 ns/op 2.1758 ns/op 1.00
fnObj(9) 1.5486 ns/op 1.5549 ns/op 1.00
fnArr(9) 1.5714 ns/op 1.5479 ns/op 1.02
Container {a,b,vec} - as struct x100000 124.27 us/op 123.80 us/op 1.00
Container {a,b,vec} - as tree x100000 340.29 us/op 340.58 us/op 1.00
Container {a,vec,b} - as struct x100000 155.12 us/op 154.78 us/op 1.00
Container {a,vec,b} - as tree x100000 402.13 us/op 371.32 us/op 1.08
get 2 props x1000000 - rawObject 309.56 us/op 309.33 us/op 1.00
get 2 props x1000000 - proxy 73.337 ms/op 72.865 ms/op 1.01
get 2 props x1000000 - customObj 309.48 us/op 309.55 us/op 1.00
Simple object binary -> struct 888.00 ns/op 586.00 ns/op 1.52
Simple object binary -> tree_backed 1.8130 us/op 1.1140 us/op 1.63
Simple object struct -> tree_backed 2.5340 us/op 1.6660 us/op 1.52
Simple object tree_backed -> struct 2.3810 us/op 1.6460 us/op 1.45
Simple object struct -> binary 1.2350 us/op 909.00 ns/op 1.36
Simple object tree_backed -> binary 1.6740 us/op 1.4520 us/op 1.15
aggregationBits binary -> struct 634.00 ns/op 512.00 ns/op 1.24
aggregationBits binary -> tree_backed 2.4740 us/op 2.1280 us/op 1.16
aggregationBits struct -> tree_backed 2.9250 us/op 2.5520 us/op 1.15
aggregationBits tree_backed -> struct 1.2430 us/op 1.0990 us/op 1.13
aggregationBits struct -> binary 786.00 ns/op 820.00 ns/op 0.96
aggregationBits tree_backed -> binary 1.0640 us/op 986.00 ns/op 1.08
List(uint8) 100000 binary -> struct 1.3868 ms/op 1.4596 ms/op 0.95
List(uint8) 100000 binary -> tree_backed 89.907 us/op 93.082 us/op 0.97
List(uint8) 100000 struct -> tree_backed 1.1324 ms/op 1.1233 ms/op 1.01
List(uint8) 100000 tree_backed -> struct 994.29 us/op 1.0093 ms/op 0.99
List(uint8) 100000 struct -> binary 998.80 us/op 998.56 us/op 1.00
List(uint8) 100000 tree_backed -> binary 89.032 us/op 91.351 us/op 0.97
List(uint64Number) 100000 binary -> struct 1.1692 ms/op 1.2310 ms/op 0.95
List(uint64Number) 100000 binary -> tree_backed 2.5316 ms/op 3.2458 ms/op 0.78
List(uint64Number) 100000 struct -> tree_backed 4.1170 ms/op 4.9157 ms/op 0.84
List(uint64Number) 100000 tree_backed -> struct 2.1288 ms/op 2.2266 ms/op 0.96
List(uint64Number) 100000 struct -> binary 1.3376 ms/op 1.3503 ms/op 0.99
List(uint64Number) 100000 tree_backed -> binary 869.80 us/op 797.71 us/op 1.09
List(Uint64Bigint) 100000 binary -> struct 3.6085 ms/op 3.3551 ms/op 1.08
List(Uint64Bigint) 100000 binary -> tree_backed 3.4534 ms/op 3.1879 ms/op 1.08
List(Uint64Bigint) 100000 struct -> tree_backed 5.5571 ms/op 5.3882 ms/op 1.03
List(Uint64Bigint) 100000 tree_backed -> struct 4.4199 ms/op 4.6579 ms/op 0.95
List(Uint64Bigint) 100000 struct -> binary 2.0399 ms/op 2.0435 ms/op 1.00
List(Uint64Bigint) 100000 tree_backed -> binary 928.94 us/op 998.03 us/op 0.93
Vector(Root) 100000 binary -> struct 33.181 ms/op 29.198 ms/op 1.14
Vector(Root) 100000 binary -> tree_backed 33.245 ms/op 27.003 ms/op 1.23
Vector(Root) 100000 struct -> tree_backed 42.192 ms/op 38.016 ms/op 1.11
Vector(Root) 100000 tree_backed -> struct 49.999 ms/op 44.576 ms/op 1.12
Vector(Root) 100000 struct -> binary 2.6481 ms/op 2.6361 ms/op 1.00
Vector(Root) 100000 tree_backed -> binary 9.3016 ms/op 9.5955 ms/op 0.97
List(Validator) 100000 binary -> struct 106.15 ms/op 99.953 ms/op 1.06
List(Validator) 100000 binary -> tree_backed 297.79 ms/op 293.75 ms/op 1.01
List(Validator) 100000 struct -> tree_backed 319.02 ms/op 302.59 ms/op 1.05
List(Validator) 100000 tree_backed -> struct 222.37 ms/op 197.56 ms/op 1.13
List(Validator) 100000 struct -> binary 28.033 ms/op 26.926 ms/op 1.04
List(Validator) 100000 tree_backed -> binary 121.55 ms/op 102.15 ms/op 1.19
List(Validator-NS) 100000 binary -> struct 98.991 ms/op 106.45 ms/op 0.93
List(Validator-NS) 100000 binary -> tree_backed 142.34 ms/op 142.84 ms/op 1.00
List(Validator-NS) 100000 struct -> tree_backed 185.59 ms/op 169.62 ms/op 1.09
List(Validator-NS) 100000 tree_backed -> struct 166.01 ms/op 148.68 ms/op 1.12
List(Validator-NS) 100000 struct -> binary 28.874 ms/op 27.397 ms/op 1.05
List(Validator-NS) 100000 tree_backed -> binary 34.489 ms/op 30.866 ms/op 1.12
get epochStatuses - MutableVector 119.79 us/op 104.75 us/op 1.14
get epochStatuses - ViewDU 202.10 us/op 201.87 us/op 1.00
set epochStatuses - ListTreeView 1.6600 ms/op 1.6494 ms/op 1.01
set epochStatuses - ListTreeView - set() 475.14 us/op 439.55 us/op 1.08
set epochStatuses - ListTreeView - commit() 566.04 us/op 525.82 us/op 1.08
bitstring 642.72 ns/op 639.94 ns/op 1.00
bit mask 14.303 ns/op 13.410 ns/op 1.07
struct - increase slot to 1000000 929.18 us/op 927.30 us/op 1.00
UintNumberType - increase slot to 1000000 21.413 ms/op 21.689 ms/op 0.99
UintBigintType - increase slot to 1000000 169.78 ms/op 187.02 ms/op 0.91
UintBigint8 x 100000 tree_deserialize 5.0233 ms/op 4.7670 ms/op 1.05
UintBigint8 x 100000 tree_serialize 1.1109 ms/op 1.0964 ms/op 1.01
UintBigint16 x 100000 tree_deserialize 4.5040 ms/op 5.1864 ms/op 0.87
UintBigint16 x 100000 tree_serialize 1.2610 ms/op 1.2030 ms/op 1.05
UintBigint32 x 100000 tree_deserialize 4.9767 ms/op 4.7562 ms/op 1.05
UintBigint32 x 100000 tree_serialize 1.2588 ms/op 1.2245 ms/op 1.03
UintBigint64 x 100000 tree_deserialize 5.7015 ms/op 5.4879 ms/op 1.04
UintBigint64 x 100000 tree_serialize 1.6626 ms/op 1.6466 ms/op 1.01
UintBigint8 x 100000 value_deserialize 433.32 us/op 433.20 us/op 1.00
UintBigint8 x 100000 value_serialize 717.37 us/op 640.73 us/op 1.12
UintBigint16 x 100000 value_deserialize 464.22 us/op 464.13 us/op 1.00
UintBigint16 x 100000 value_serialize 781.59 us/op 706.54 us/op 1.11
UintBigint32 x 100000 value_deserialize 433.20 us/op 433.18 us/op 1.00
UintBigint32 x 100000 value_serialize 747.81 us/op 680.53 us/op 1.10
UintBigint64 x 100000 value_deserialize 496.44 us/op 495.76 us/op 1.00
UintBigint64 x 100000 value_serialize 924.40 us/op 878.21 us/op 1.05
UintBigint8 x 100000 deserialize 3.0619 ms/op 2.9509 ms/op 1.04
UintBigint8 x 100000 serialize 1.6567 ms/op 1.4989 ms/op 1.11
UintBigint16 x 100000 deserialize 3.2806 ms/op 2.9540 ms/op 1.11
UintBigint16 x 100000 serialize 1.6791 ms/op 1.5223 ms/op 1.10
UintBigint32 x 100000 deserialize 3.2818 ms/op 3.0105 ms/op 1.09
UintBigint32 x 100000 serialize 2.9210 ms/op 2.7477 ms/op 1.06
UintBigint64 x 100000 deserialize 4.1608 ms/op 3.7888 ms/op 1.10
UintBigint64 x 100000 serialize 1.5178 ms/op 1.4984 ms/op 1.01
UintBigint128 x 100000 deserialize 4.8890 ms/op 5.1456 ms/op 0.95
UintBigint128 x 100000 serialize 14.172 ms/op 15.372 ms/op 0.92
UintBigint256 x 100000 deserialize 7.7756 ms/op 8.4180 ms/op 0.92
UintBigint256 x 100000 serialize 42.933 ms/op 43.922 ms/op 0.98
Slice from Uint8Array x25000 1.1997 ms/op 1.1392 ms/op 1.05
Slice from ArrayBuffer x25000 14.765 ms/op 16.281 ms/op 0.91
Slice from ArrayBuffer x25000 + new Uint8Array 15.337 ms/op 17.933 ms/op 0.86
Copy Uint8Array 100000 iterate 1.6592 ms/op 1.6447 ms/op 1.01
Copy Uint8Array 100000 slice 117.03 us/op 107.71 us/op 1.09
Copy Uint8Array 100000 Uint8Array.prototype.slice.call 117.46 us/op 108.86 us/op 1.08
Copy Buffer 100000 Uint8Array.prototype.slice.call 119.53 us/op 111.21 us/op 1.07
Copy Uint8Array 100000 slice + set 182.83 us/op 173.90 us/op 1.05
Copy Uint8Array 100000 subarray + set 117.83 us/op 109.06 us/op 1.08
Copy Uint8Array 100000 slice arrayBuffer 120.33 us/op 111.40 us/op 1.08
Uint64 deserialize 100000 - iterate Uint8Array 1.8000 ms/op 1.8928 ms/op 0.95
Uint64 deserialize 100000 - by Uint32A 1.7601 ms/op 1.8694 ms/op 0.94
Uint64 deserialize 100000 - by DataView.getUint32 x2 1.8240 ms/op 1.9222 ms/op 0.95
Uint64 deserialize 100000 - by DataView.getBigUint64 4.8981 ms/op 4.9864 ms/op 0.98
Uint64 deserialize 100000 - by byte 40.069 ms/op 40.212 ms/op 1.00

by benchmarkbot/action

@twoeths twoeths marked this pull request as ready for review August 9, 2024 13:13
@twoeths twoeths requested a review from a team as a code owner August 9, 2024 13:13
@twoeths
Copy link
Contributor Author

twoeths commented Sep 3, 2024

I should have mentioned the new ViewDU.batchHashTreeRoot() does not affect hashTreeRoot(), that's one of the criterias to merge these PRs

@twoeths twoeths merged commit 8dd6600 into master Sep 4, 2024
8 checks passed
@twoeths twoeths deleted the te/viewdu_batch_hash_tree_root branch September 4, 2024 01:18
@wemeetagain wemeetagain mentioned this pull request Sep 4, 2024
@twoeths
Copy link
Contributor Author

twoeths commented Sep 4, 2024

this is part 1 of ViewDU.batchHashTreeRoot(), part 2 is to batch hash at commit() for ListValidator which requires the new type.hashTreeRootInto() api which comes next

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.

2 participants