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: use allocUnsafe to allocate hash digests #391

Merged
merged 5 commits into from
Aug 6, 2024

Conversation

wemeetagain
Copy link
Member

Motivation

  • allocation is typically slow, using allocUnsafe to allocate hash digests can help

Description

  • use allocUnsafe where possible to allocate hash digests
  • use subarray to avoid an additional data copy when using digest with long inputs.

@wemeetagain wemeetagain requested a review from a team as a code owner August 5, 2024 22:22
Copy link

github-actions bot commented Aug 5, 2024

Performance Report

✔️ no performance regression detected

Full benchmark results
Benchmark suite Current: 7cb367c Previous: 1578883 Ratio
digestTwoHashObjects 50023 times 48.925 ms/op 48.098 ms/op 1.02
digest64 50023 times 54.286 ms/op 51.043 ms/op 1.06
digest 50023 times 56.297 ms/op 58.931 ms/op 0.96
input length 32 1.2540 us/op 1.4760 us/op 0.85
input length 64 1.3910 us/op 1.6290 us/op 0.85
input length 128 2.3330 us/op 2.6700 us/op 0.87
input length 256 3.5150 us/op 3.8610 us/op 0.91
input length 512 5.7210 us/op 6.2890 us/op 0.91
input length 1024 10.812 us/op 11.592 us/op 0.93
digest 1000000 times 886.29 ms/op 894.07 ms/op 0.99
hashObjectToByteArray 50023 times 1.4343 ms/op 1.4538 ms/op 0.99
byteArrayToHashObject 50023 times 2.6281 ms/op 2.8036 ms/op 0.94
digest64 200092 times 224.70 ms/op 237.79 ms/op 0.94
hash 200092 times using batchHash4UintArray64s 242.15 ms/op 242.40 ms/op 1.00
digest64HashObjects 200092 times 195.01 ms/op 208.10 ms/op 0.94
hash 200092 times using batchHash4HashObjectInputs 200.82 ms/op 223.96 ms/op 0.90
getGindicesAtDepth 4.8700 us/op 4.6070 us/op 1.06
iterateAtDepth 8.1710 us/op 8.5470 us/op 0.96
getGindexBits 488.00 ns/op 543.00 ns/op 0.90
gindexIterator 1.1830 us/op 1.1530 us/op 1.03
hash 2 Uint8Array 500000 times - as-sha256 569.25 ms/op 589.77 ms/op 0.97
hashTwoObjects 500000 times - as-sha256 508.43 ms/op 502.44 ms/op 1.01
executeHashComputations - as-sha256 47.871 ms/op 46.575 ms/op 1.03
hash 2 Uint8Array 500000 times - noble 1.1109 s/op 1.1988 s/op 0.93
hashTwoObjects 500000 times - noble 1.7102 s/op 1.7515 s/op 0.98
executeHashComputations - noble 46.056 ms/op 38.344 ms/op 1.20
hash 2 Uint8Array 500000 times - hashtree 225.54 ms/op 234.30 ms/op 0.96
hashTwoObjects 500000 times - hashtree 211.70 ms/op 219.16 ms/op 0.97
executeHashComputations - hashtree 12.927 ms/op 16.988 ms/op 0.76
getNodeH() x7812.5 avg hindex 12.142 us/op 13.049 us/op 0.93
getNodeH() x7812.5 index 0 6.2520 us/op 6.2460 us/op 1.00
getNodeH() x7812.5 index 7 6.2860 us/op 6.2530 us/op 1.01
getNodeH() x7812.5 index 7 with key array 6.2690 us/op 6.2390 us/op 1.00
new LeafNode() x7812.5 14.714 us/op 14.671 us/op 1.00
getHashComputations 250000 nodes 20.573 ms/op 18.731 ms/op 1.10
batchHash 250000 nodes 343.11 ms/op 351.19 ms/op 0.98
get root 250000 nodes 814.68 ms/op 969.79 ms/op 0.84
getHashComputations 500000 nodes 51.740 ms/op 36.103 ms/op 1.43
batchHash 500000 nodes 683.43 ms/op 621.06 ms/op 1.10
get root 500000 nodes 1.8231 s/op 1.9052 s/op 0.96
getHashComputations 1000000 nodes 90.218 ms/op 85.949 ms/op 1.05
batchHash 1000000 nodes 1.2465 s/op 1.2345 s/op 1.01
get root 1000000 nodes 3.7538 s/op 3.8316 s/op 0.98
multiproof - depth 15, 1 requested leaves 8.8570 us/op 9.6840 us/op 0.91
tree offset multiproof - depth 15, 1 requested leaves 20.112 us/op 20.935 us/op 0.96
compact multiproof - depth 15, 1 requested leaves 4.2090 us/op 4.4030 us/op 0.96
multiproof - depth 15, 2 requested leaves 13.714 us/op 14.202 us/op 0.97
tree offset multiproof - depth 15, 2 requested leaves 24.669 us/op 24.979 us/op 0.99
compact multiproof - depth 15, 2 requested leaves 4.2210 us/op 4.4450 us/op 0.95
multiproof - depth 15, 3 requested leaves 18.675 us/op 19.463 us/op 0.96
tree offset multiproof - depth 15, 3 requested leaves 31.530 us/op 32.084 us/op 0.98
compact multiproof - depth 15, 3 requested leaves 5.5140 us/op 5.9560 us/op 0.93
multiproof - depth 15, 4 requested leaves 24.514 us/op 25.203 us/op 0.97
tree offset multiproof - depth 15, 4 requested leaves 38.963 us/op 39.971 us/op 0.97
compact multiproof - depth 15, 4 requested leaves 6.5800 us/op 7.0430 us/op 0.93
packedRootsBytesToLeafNodes bytes 4000 offset 0 1.9070 us/op 3.4100 us/op 0.56
packedRootsBytesToLeafNodes bytes 4000 offset 1 1.8540 us/op 2.8950 us/op 0.64
packedRootsBytesToLeafNodes bytes 4000 offset 2 1.9040 us/op 2.6660 us/op 0.71
packedRootsBytesToLeafNodes bytes 4000 offset 3 1.8860 us/op 2.4340 us/op 0.77
subtreeFillToContents depth 40 count 250000 46.627 ms/op 45.302 ms/op 1.03
setRoot - gindexBitstring 9.7133 ms/op 11.446 ms/op 0.85
setRoot - gindex 9.6245 ms/op 12.246 ms/op 0.79
getRoot - gindexBitstring 2.7070 ms/op 2.7112 ms/op 1.00
getRoot - gindex 3.6512 ms/op 3.6256 ms/op 1.01
getHashObject then setHashObject 10.621 ms/op 12.206 ms/op 0.87
setNodeWithFn 7.8333 ms/op 9.6518 ms/op 0.81
getNodeAtDepth depth 0 x100000 1.1158 ms/op 1.1147 ms/op 1.00
setNodeAtDepth depth 0 x100000 2.6547 ms/op 2.9412 ms/op 0.90
getNodesAtDepth depth 0 x100000 1.0532 ms/op 1.0527 ms/op 1.00
setNodesAtDepth depth 0 x100000 1.4592 ms/op 1.4598 ms/op 1.00
getNodeAtDepth depth 1 x100000 1.1871 ms/op 1.1820 ms/op 1.00
setNodeAtDepth depth 1 x100000 5.2099 ms/op 6.3041 ms/op 0.83
getNodesAtDepth depth 1 x100000 1.1840 ms/op 1.1771 ms/op 1.01
setNodesAtDepth depth 1 x100000 4.4575 ms/op 5.2765 ms/op 0.84
getNodeAtDepth depth 2 x100000 1.4534 ms/op 1.4545 ms/op 1.00
setNodeAtDepth depth 2 x100000 9.0855 ms/op 11.988 ms/op 0.76
getNodesAtDepth depth 2 x100000 19.984 ms/op 20.101 ms/op 0.99
setNodesAtDepth depth 2 x100000 15.991 ms/op 14.807 ms/op 1.08
tree.getNodesAtDepth - gindexes 9.4050 ms/op 9.9621 ms/op 0.94
tree.getNodesAtDepth - push all nodes 1.9421 ms/op 2.1940 ms/op 0.89
tree.getNodesAtDepth - navigation 234.38 us/op 232.52 us/op 1.01
tree.setNodesAtDepth - indexes 467.35 us/op 487.95 us/op 0.96
set at depth 8 572.00 ns/op 588.00 ns/op 0.97
set at depth 16 701.00 ns/op 807.00 ns/op 0.87
set at depth 32 1.0510 us/op 1.2130 us/op 0.87
iterateNodesAtDepth 8 256 15.008 us/op 14.946 us/op 1.00
getNodesAtDepth 8 256 3.6910 us/op 3.7070 us/op 1.00
iterateNodesAtDepth 16 65536 4.5495 ms/op 4.5803 ms/op 0.99
getNodesAtDepth 16 65536 1.6025 ms/op 1.7377 ms/op 0.92
iterateNodesAtDepth 32 250000 16.441 ms/op 16.474 ms/op 1.00
getNodesAtDepth 32 250000 4.6161 ms/op 5.0082 ms/op 0.92
iterateNodesAtDepth 40 250000 16.251 ms/op 16.404 ms/op 0.99
getNodesAtDepth 40 250000 4.3320 ms/op 5.1320 ms/op 0.84
1600000 validators root getter 5.3082 s/op 6.5100 s/op 0.82
1600000 validators batchHash() 1.9214 s/op 1.9170 s/op 1.00
1600000 validators hashComputations 143.27 ms/op 144.23 ms/op 0.99
bitlist bytes to struct (120,90) 470.00 ns/op 586.00 ns/op 0.80
bitlist bytes to tree (120,90) 1.9100 us/op 2.7340 us/op 0.70
bitlist bytes to struct (2048,2048) 823.00 ns/op 1.2650 us/op 0.65
bitlist bytes to tree (2048,2048) 3.1700 us/op 4.3770 us/op 0.72
ByteListType - deserialize 7.8627 ms/op 10.544 ms/op 0.75
BasicListType - deserialize 10.333 ms/op 14.148 ms/op 0.73
ByteListType - serialize 9.3207 ms/op 10.549 ms/op 0.88
BasicListType - serialize 10.966 ms/op 14.591 ms/op 0.75
BasicListType - tree_convertToStruct 21.200 ms/op 27.925 ms/op 0.76
List[uint8, 68719476736] len 300000 ViewDU.getAll() + iterate 4.3396 ms/op 6.6210 ms/op 0.66
List[uint8, 68719476736] len 300000 ViewDU.get(i) 4.1083 ms/op 3.9754 ms/op 1.03
Array.push len 300000 empty Array - number 5.8696 ms/op 7.9548 ms/op 0.74
Array.set len 300000 from new Array - number 1.8088 ms/op 2.8766 ms/op 0.63
Array.set len 300000 - number 5.7947 ms/op 7.3264 ms/op 0.79
Uint8Array.set len 300000 370.70 us/op 393.20 us/op 0.94
Uint32Array.set len 300000 435.48 us/op 479.10 us/op 0.91
Container({a: uint8, b: uint8}) getViewDU x300000 52.403 ms/op 57.757 ms/op 0.91
ContainerNodeStruct({a: uint8, b: uint8}) getViewDU x300000 10.995 ms/op 11.975 ms/op 0.92
List(Container) len 300000 ViewDU.getAllReadonly() + iterate 209.38 ms/op 222.54 ms/op 0.94
List(Container) len 300000 ViewDU.getAllReadonlyValues() + iterate 269.54 ms/op 281.44 ms/op 0.96
List(Container) len 300000 ViewDU.get(i) 7.1383 ms/op 10.823 ms/op 0.66
List(Container) len 300000 ViewDU.getReadonly(i) 6.4529 ms/op 9.5995 ms/op 0.67
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonly() + iterate 39.625 ms/op 40.461 ms/op 0.98
List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonlyValues() + iterate 5.1961 ms/op 6.7733 ms/op 0.77
List(ContainerNodeStruct) len 300000 ViewDU.get(i) 6.2365 ms/op 10.390 ms/op 0.60
List(ContainerNodeStruct) len 300000 ViewDU.getReadonly(i) 6.1352 ms/op 9.7459 ms/op 0.63
Array.push len 300000 empty Array - object 5.8271 ms/op 7.2653 ms/op 0.80
Array.set len 300000 from new Array - object 2.0067 ms/op 3.4506 ms/op 0.58
Array.set len 300000 - object 5.5232 ms/op 7.1740 ms/op 0.77
cachePermanentRootStruct no cache 9.2060 us/op 9.9890 us/op 0.92
cachePermanentRootStruct with cache 208.00 ns/op 283.00 ns/op 0.73
epochParticipation len 250000 rws 7813 2.1835 ms/op 2.4283 ms/op 0.90
deserialize Attestation - tree 3.9220 us/op 4.7050 us/op 0.83
deserialize Attestation - struct 1.7690 us/op 2.2840 us/op 0.77
deserialize SignedAggregateAndProof - tree 3.6210 us/op 4.8490 us/op 0.75
deserialize SignedAggregateAndProof - struct 2.9240 us/op 4.0770 us/op 0.72
deserialize SyncCommitteeMessage - tree 1.0180 us/op 1.2650 us/op 0.80
deserialize SyncCommitteeMessage - struct 1.0710 us/op 1.1920 us/op 0.90
deserialize SignedContributionAndProof - tree 1.9850 us/op 2.4780 us/op 0.80
deserialize SignedContributionAndProof - struct 2.1990 us/op 2.5910 us/op 0.85
deserialize SignedBeaconBlock - tree 207.58 us/op 245.64 us/op 0.85
deserialize SignedBeaconBlock - struct 117.66 us/op 130.47 us/op 0.90
BeaconState vc 300000 - deserialize tree 567.33 ms/op 606.77 ms/op 0.94
BeaconState vc 300000 - serialize tree 150.20 ms/op 140.97 ms/op 1.07
BeaconState.historicalRoots vc 300000 - deserialize tree 734.00 ns/op 870.00 ns/op 0.84
BeaconState.historicalRoots vc 300000 - serialize tree 611.00 ns/op 744.00 ns/op 0.82
BeaconState.validators vc 300000 - deserialize tree 504.58 ms/op 561.01 ms/op 0.90
BeaconState.validators vc 300000 - serialize tree 103.79 ms/op 99.779 ms/op 1.04
BeaconState.balances vc 300000 - deserialize tree 20.321 ms/op 21.893 ms/op 0.93
BeaconState.balances vc 300000 - serialize tree 3.0311 ms/op 7.1918 ms/op 0.42
BeaconState.previousEpochParticipation vc 300000 - deserialize tree 316.56 us/op 792.47 us/op 0.40
BeaconState.previousEpochParticipation vc 300000 - serialize tree 265.34 us/op 300.54 us/op 0.88
BeaconState.currentEpochParticipation vc 300000 - deserialize tree 324.82 us/op 827.63 us/op 0.39
BeaconState.currentEpochParticipation vc 300000 - serialize tree 267.28 us/op 304.86 us/op 0.88
BeaconState.inactivityScores vc 300000 - deserialize tree 14.796 ms/op 22.522 ms/op 0.66
BeaconState.inactivityScores vc 300000 - serialize tree 4.3513 ms/op 7.3602 ms/op 0.59
hashTreeRoot Attestation - struct 32.460 us/op 62.645 us/op 0.52
hashTreeRoot Attestation - tree 20.398 us/op 23.452 us/op 0.87
hashTreeRoot SignedAggregateAndProof - struct 43.948 us/op 70.788 us/op 0.62
hashTreeRoot SignedAggregateAndProof - tree 30.646 us/op 30.654 us/op 1.00
hashTreeRoot SyncCommitteeMessage - struct 10.157 us/op 18.128 us/op 0.56
hashTreeRoot SyncCommitteeMessage - tree 7.0120 us/op 7.2220 us/op 0.97
hashTreeRoot SignedContributionAndProof - struct 29.832 us/op 38.246 us/op 0.78
hashTreeRoot SignedContributionAndProof - tree 21.282 us/op 20.813 us/op 1.02
hashTreeRoot SignedBeaconBlock - struct 2.4578 ms/op 2.9015 ms/op 0.85
hashTreeRoot SignedBeaconBlock - tree 1.8704 ms/op 1.8997 ms/op 0.98
hashTreeRoot Validator - struct 12.780 us/op 15.298 us/op 0.84
hashTreeRoot Validator - tree 12.140 us/op 13.129 us/op 0.92
BeaconState vc 300000 - hashTreeRoot tree 3.9439 s/op 4.0034 s/op 0.99
BeaconState.historicalRoots vc 300000 - hashTreeRoot tree 1.6060 us/op 1.6540 us/op 0.97
BeaconState.validators vc 300000 - hashTreeRoot tree 3.7643 s/op 3.8062 s/op 0.99
BeaconState.balances vc 300000 - hashTreeRoot tree 86.852 ms/op 83.211 ms/op 1.04
BeaconState.previousEpochParticipation vc 300000 - hashTreeRoot tree 10.193 ms/op 10.045 ms/op 1.01
BeaconState.currentEpochParticipation vc 300000 - hashTreeRoot tree 10.161 ms/op 10.030 ms/op 1.01
BeaconState.inactivityScores vc 300000 - hashTreeRoot tree 82.356 ms/op 81.030 ms/op 1.02
hash64 x18 20.931 us/op 19.871 us/op 1.05
hashTwoObjects x18 20.259 us/op 20.332 us/op 1.00
hash64 x1740 1.9581 ms/op 1.8450 ms/op 1.06
hashTwoObjects x1740 1.9441 ms/op 1.8995 ms/op 1.02
hash64 x2700000 3.0448 s/op 2.8693 s/op 1.06
hashTwoObjects x2700000 3.0205 s/op 2.9436 s/op 1.03
get_exitEpoch - ContainerType 439.00 ns/op 459.00 ns/op 0.96
get_exitEpoch - ContainerNodeStructType 423.00 ns/op 425.00 ns/op 1.00
set_exitEpoch - ContainerType 468.00 ns/op 461.00 ns/op 1.02
set_exitEpoch - ContainerNodeStructType 437.00 ns/op 446.00 ns/op 0.98
get_pubkey - ContainerType 848.00 ns/op 884.00 ns/op 0.96
get_pubkey - ContainerNodeStructType 438.00 ns/op 439.00 ns/op 1.00
hashTreeRoot - ContainerType 721.00 ns/op 720.00 ns/op 1.00
hashTreeRoot - ContainerNodeStructType 777.00 ns/op 759.00 ns/op 1.02
createProof - ContainerType 5.8520 us/op 5.6070 us/op 1.04
createProof - ContainerNodeStructType 23.725 us/op 27.166 us/op 0.87
serialize - ContainerType 2.0340 us/op 2.1220 us/op 0.96
serialize - ContainerNodeStructType 1.6210 us/op 1.7310 us/op 0.94
set_exitEpoch_and_hashTreeRoot - ContainerType 5.3860 us/op 5.5210 us/op 0.98
set_exitEpoch_and_hashTreeRoot - ContainerNodeStructType 13.929 us/op 13.800 us/op 1.01
Array - for of 5.7550 us/op 5.8690 us/op 0.98
Array - for(;;) 5.7260 us/op 5.8750 us/op 0.97
basicListValue.readonlyValuesArray() 5.3617 ms/op 4.9419 ms/op 1.08
basicListValue.readonlyValuesArray() + loop all 4.6897 ms/op 5.1149 ms/op 0.92
compositeListValue.readonlyValuesArray() 27.647 ms/op 29.257 ms/op 0.94
compositeListValue.readonlyValuesArray() + loop all 30.606 ms/op 28.781 ms/op 1.06
Number64UintType - get balances list 4.3499 ms/op 4.6154 ms/op 0.94
Number64UintType - set balances list 8.6850 ms/op 9.7880 ms/op 0.89
Number64UintType - get and increase 10 then set 37.774 ms/op 38.538 ms/op 0.98
Number64UintType - increase 10 using applyDelta 15.511 ms/op 16.731 ms/op 0.93
Number64UintType - increase 10 using applyDeltaInBatch 15.402 ms/op 16.269 ms/op 0.95
tree_newTreeFromUint64Deltas 17.323 ms/op 17.213 ms/op 1.01
unsafeUint8ArrayToTree 32.933 ms/op 31.231 ms/op 1.05
bitLength(50) 228.00 ns/op 233.00 ns/op 0.98
bitLengthStr(50) 221.00 ns/op 217.00 ns/op 1.02
bitLength(8000) 218.00 ns/op 227.00 ns/op 0.96
bitLengthStr(8000) 274.00 ns/op 267.00 ns/op 1.03
bitLength(250000) 228.00 ns/op 228.00 ns/op 1.00
bitLengthStr(250000) 297.00 ns/op 301.00 ns/op 0.99
floor - Math.floor (53) 1.2373 ns/op 1.2385 ns/op 1.00
floor - << 0 (53) 1.2377 ns/op 1.2380 ns/op 1.00
floor - Math.floor (512) 1.2411 ns/op 1.2478 ns/op 0.99
floor - << 0 (512) 1.2486 ns/op 1.2374 ns/op 1.01
fnIf(0) 1.5673 ns/op 1.5457 ns/op 1.01
fnSwitch(0) 2.1647 ns/op 2.1699 ns/op 1.00
fnObj(0) 1.5778 ns/op 1.5492 ns/op 1.02
fnArr(0) 1.5486 ns/op 1.5463 ns/op 1.00
fnIf(4) 2.1680 ns/op 2.1650 ns/op 1.00
fnSwitch(4) 2.1646 ns/op 2.1637 ns/op 1.00
fnObj(4) 1.5490 ns/op 1.5530 ns/op 1.00
fnArr(4) 1.5474 ns/op 1.5476 ns/op 1.00
fnIf(9) 3.0927 ns/op 3.0923 ns/op 1.00
fnSwitch(9) 2.1752 ns/op 2.1645 ns/op 1.00
fnObj(9) 1.5553 ns/op 1.5496 ns/op 1.00
fnArr(9) 1.5465 ns/op 1.5521 ns/op 1.00
Container {a,b,vec} - as struct x100000 123.89 us/op 124.01 us/op 1.00
Container {a,b,vec} - as tree x100000 340.94 us/op 340.82 us/op 1.00
Container {a,vec,b} - as struct x100000 154.88 us/op 155.04 us/op 1.00
Container {a,vec,b} - as tree x100000 376.69 us/op 371.57 us/op 1.01
get 2 props x1000000 - rawObject 309.57 us/op 310.24 us/op 1.00
get 2 props x1000000 - proxy 73.704 ms/op 72.781 ms/op 1.01
get 2 props x1000000 - customObj 309.93 us/op 309.17 us/op 1.00
Simple object binary -> struct 537.00 ns/op 565.00 ns/op 0.95
Simple object binary -> tree_backed 975.00 ns/op 1.0470 us/op 0.93
Simple object struct -> tree_backed 1.4480 us/op 1.6310 us/op 0.89
Simple object tree_backed -> struct 1.5370 us/op 1.5940 us/op 0.96
Simple object struct -> binary 776.00 ns/op 850.00 ns/op 0.91
Simple object tree_backed -> binary 1.2600 us/op 1.3320 us/op 0.95
aggregationBits binary -> struct 449.00 ns/op 470.00 ns/op 0.96
aggregationBits binary -> tree_backed 1.8140 us/op 2.0660 us/op 0.88
aggregationBits struct -> tree_backed 2.2040 us/op 2.4270 us/op 0.91
aggregationBits tree_backed -> struct 922.00 ns/op 1.0350 us/op 0.89
aggregationBits struct -> binary 644.00 ns/op 747.00 ns/op 0.86
aggregationBits tree_backed -> binary 843.00 ns/op 952.00 ns/op 0.89
List(uint8) 100000 binary -> struct 1.4290 ms/op 1.1825 ms/op 1.21
List(uint8) 100000 binary -> tree_backed 88.105 us/op 86.720 us/op 1.02
List(uint8) 100000 struct -> tree_backed 1.1147 ms/op 1.1340 ms/op 0.98
List(uint8) 100000 tree_backed -> struct 1.0214 ms/op 1.0001 ms/op 1.02
List(uint8) 100000 struct -> binary 1.0105 ms/op 987.80 us/op 1.02
List(uint8) 100000 tree_backed -> binary 86.344 us/op 90.795 us/op 0.95
List(uint64Number) 100000 binary -> struct 1.2041 ms/op 1.2471 ms/op 0.97
List(uint64Number) 100000 binary -> tree_backed 3.0320 ms/op 3.3607 ms/op 0.90
List(uint64Number) 100000 struct -> tree_backed 4.5042 ms/op 4.7563 ms/op 0.95
List(uint64Number) 100000 tree_backed -> struct 2.1343 ms/op 2.2367 ms/op 0.95
List(uint64Number) 100000 struct -> binary 1.3483 ms/op 1.5556 ms/op 0.87
List(uint64Number) 100000 tree_backed -> binary 869.87 us/op 869.93 us/op 1.00
List(Uint64Bigint) 100000 binary -> struct 3.6146 ms/op 3.5944 ms/op 1.01
List(Uint64Bigint) 100000 binary -> tree_backed 3.0326 ms/op 3.3181 ms/op 0.91
List(Uint64Bigint) 100000 struct -> tree_backed 5.3456 ms/op 5.4001 ms/op 0.99
List(Uint64Bigint) 100000 tree_backed -> struct 4.4559 ms/op 4.8992 ms/op 0.91
List(Uint64Bigint) 100000 struct -> binary 2.0416 ms/op 2.0607 ms/op 0.99
List(Uint64Bigint) 100000 tree_backed -> binary 940.95 us/op 1.3819 ms/op 0.68
Vector(Root) 100000 binary -> struct 28.643 ms/op 30.789 ms/op 0.93
Vector(Root) 100000 binary -> tree_backed 31.353 ms/op 32.594 ms/op 0.96
Vector(Root) 100000 struct -> tree_backed 29.024 ms/op 35.251 ms/op 0.82
Vector(Root) 100000 tree_backed -> struct 43.153 ms/op 43.491 ms/op 0.99
Vector(Root) 100000 struct -> binary 2.6079 ms/op 2.6369 ms/op 0.99
Vector(Root) 100000 tree_backed -> binary 9.7231 ms/op 10.085 ms/op 0.96
List(Validator) 100000 binary -> struct 102.68 ms/op 94.057 ms/op 1.09
List(Validator) 100000 binary -> tree_backed 284.87 ms/op 291.23 ms/op 0.98
List(Validator) 100000 struct -> tree_backed 300.31 ms/op 302.31 ms/op 0.99
List(Validator) 100000 tree_backed -> struct 194.31 ms/op 197.29 ms/op 0.98
List(Validator) 100000 struct -> binary 26.700 ms/op 26.666 ms/op 1.00
List(Validator) 100000 tree_backed -> binary 101.30 ms/op 102.67 ms/op 0.99
List(Validator-NS) 100000 binary -> struct 94.899 ms/op 105.55 ms/op 0.90
List(Validator-NS) 100000 binary -> tree_backed 127.63 ms/op 144.09 ms/op 0.89
List(Validator-NS) 100000 struct -> tree_backed 173.83 ms/op 172.04 ms/op 1.01
List(Validator-NS) 100000 tree_backed -> struct 145.27 ms/op 149.45 ms/op 0.97
List(Validator-NS) 100000 struct -> binary 26.733 ms/op 26.850 ms/op 1.00
List(Validator-NS) 100000 tree_backed -> binary 32.470 ms/op 31.772 ms/op 1.02
get epochStatuses - MutableVector 90.609 us/op 91.125 us/op 0.99
get epochStatuses - ViewDU 203.04 us/op 203.25 us/op 1.00
set epochStatuses - ListTreeView 1.5896 ms/op 1.4927 ms/op 1.06
set epochStatuses - ListTreeView - set() 444.33 us/op 432.51 us/op 1.03
set epochStatuses - ListTreeView - commit() 510.15 us/op 520.98 us/op 0.98
bitstring 645.01 ns/op 636.31 ns/op 1.01
bit mask 13.570 ns/op 13.900 ns/op 0.98
struct - increase slot to 1000000 928.00 us/op 928.09 us/op 1.00
UintNumberType - increase slot to 1000000 24.130 ms/op 23.525 ms/op 1.03
UintBigintType - increase slot to 1000000 172.98 ms/op 155.34 ms/op 1.11
UintBigint8 x 100000 tree_deserialize 5.1452 ms/op 4.7437 ms/op 1.08
UintBigint8 x 100000 tree_serialize 1.0963 ms/op 1.1149 ms/op 0.98
UintBigint16 x 100000 tree_deserialize 5.3409 ms/op 4.8136 ms/op 1.11
UintBigint16 x 100000 tree_serialize 1.2260 ms/op 1.1636 ms/op 1.05
UintBigint32 x 100000 tree_deserialize 5.2127 ms/op 5.0074 ms/op 1.04
UintBigint32 x 100000 tree_serialize 1.3470 ms/op 1.1815 ms/op 1.14
UintBigint64 x 100000 tree_deserialize 5.4024 ms/op 5.2460 ms/op 1.03
UintBigint64 x 100000 tree_serialize 1.7376 ms/op 1.5897 ms/op 1.09
UintBigint8 x 100000 value_deserialize 432.89 us/op 433.00 us/op 1.00
UintBigint8 x 100000 value_serialize 661.29 us/op 595.68 us/op 1.11
UintBigint16 x 100000 value_deserialize 463.69 us/op 468.20 us/op 0.99
UintBigint16 x 100000 value_serialize 735.75 us/op 661.48 us/op 1.11
UintBigint32 x 100000 value_deserialize 433.11 us/op 433.32 us/op 1.00
UintBigint32 x 100000 value_serialize 709.16 us/op 630.69 us/op 1.12
UintBigint64 x 100000 value_deserialize 500.98 us/op 498.13 us/op 1.01
UintBigint64 x 100000 value_serialize 880.91 us/op 833.07 us/op 1.06
UintBigint8 x 100000 deserialize 2.9641 ms/op 3.0272 ms/op 0.98
UintBigint8 x 100000 serialize 1.7342 ms/op 1.4133 ms/op 1.23
UintBigint16 x 100000 deserialize 2.9805 ms/op 3.1150 ms/op 0.96
UintBigint16 x 100000 serialize 1.4620 ms/op 1.4402 ms/op 1.02
UintBigint32 x 100000 deserialize 3.0789 ms/op 3.2150 ms/op 0.96
UintBigint32 x 100000 serialize 2.7273 ms/op 2.7030 ms/op 1.01
UintBigint64 x 100000 deserialize 4.1621 ms/op 3.6790 ms/op 1.13
UintBigint64 x 100000 serialize 1.5041 ms/op 1.5052 ms/op 1.00
UintBigint128 x 100000 deserialize 5.0246 ms/op 5.2996 ms/op 0.95
UintBigint128 x 100000 serialize 15.339 ms/op 15.174 ms/op 1.01
UintBigint256 x 100000 deserialize 8.0570 ms/op 8.0697 ms/op 1.00
UintBigint256 x 100000 serialize 45.397 ms/op 45.420 ms/op 1.00
Slice from Uint8Array x25000 1.2854 ms/op 1.1276 ms/op 1.14
Slice from ArrayBuffer x25000 16.291 ms/op 16.514 ms/op 0.99
Slice from ArrayBuffer x25000 + new Uint8Array 16.813 ms/op 17.645 ms/op 0.95
Copy Uint8Array 100000 iterate 1.6688 ms/op 1.8561 ms/op 0.90
Copy Uint8Array 100000 slice 121.36 us/op 177.74 us/op 0.68
Copy Uint8Array 100000 Uint8Array.prototype.slice.call 122.37 us/op 164.50 us/op 0.74
Copy Buffer 100000 Uint8Array.prototype.slice.call 124.02 us/op 173.89 us/op 0.71
Copy Uint8Array 100000 slice + set 199.35 us/op 315.78 us/op 0.63
Copy Uint8Array 100000 subarray + set 120.68 us/op 168.51 us/op 0.72
Copy Uint8Array 100000 slice arrayBuffer 121.31 us/op 175.35 us/op 0.69
Uint64 deserialize 100000 - iterate Uint8Array 1.8418 ms/op 1.8257 ms/op 1.01
Uint64 deserialize 100000 - by Uint32A 1.9064 ms/op 1.7573 ms/op 1.08
Uint64 deserialize 100000 - by DataView.getUint32 x2 1.8313 ms/op 1.7824 ms/op 1.03
Uint64 deserialize 100000 - by DataView.getBigUint64 4.9273 ms/op 4.9919 ms/op 0.99
Uint64 deserialize 100000 - by byte 40.086 ms/op 39.996 ms/op 1.00

by benchmarkbot/action

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.

looks good to me, I think we should apply alloc utils to ssz hashTreeRoot() too

@wemeetagain
Copy link
Member Author

we should apply alloc utils to ssz hashTreeRoot() too

looks like the ssz lib will be using the digest functions that have been updated here

@wemeetagain wemeetagain merged commit 8ea1bb4 into master Aug 6, 2024
8 checks passed
@wemeetagain wemeetagain deleted the cayman/alloc-unsafe branch August 6, 2024 20:28
@wemeetagain wemeetagain mentioned this pull request Aug 6, 2024
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