ChainSafe / ssz

Typescript implementation of Simple Serialize (SSZ)
https://simpleserialize.com/
Other
44 stars 17 forks source link

feat: improve ViewDU.serialize() #350

Closed twoeths closed 4 months ago

twoeths commented 4 months ago

Motivation

Description Define serialize() in ViewDU to go through the new serializeToBytes() method instead of its respective type class

Test New serialize() implementation in ViewDU is scanned through spec tests

github-actions[bot] commented 4 months ago

Performance Report

✔️ no performance regression detected

Full benchmark results | Benchmark suite | Current: 5ddcdc11e942ce8830dc9a9820526eb116d36843 | Previous: 14c4457026a9fbea5bfe5c66580f7c8a8bee790a | Ratio | |-|-|-|-| | digestTwoHashObjects 50023 times | 48.651 ms/op | 48.065 ms/op | 1.01 | | digest64 50023 times | 50.295 ms/op | 48.664 ms/op | 1.03 | | digest 50023 times | 50.389 ms/op | 48.850 ms/op | 1.03 | | input length 32 | 1.2110 us/op | 1.1640 us/op | 1.04 | | input length 64 | 1.3440 us/op | 1.2600 us/op | 1.07 | | input length 128 | 2.2870 us/op | 2.2230 us/op | 1.03 | | input length 256 | 3.3470 us/op | 3.3090 us/op | 1.01 | | input length 512 | 5.5220 us/op | 5.4790 us/op | 1.01 | | input length 1024 | 10.771 us/op | 10.791 us/op | 1.00 | | digest 1000000 times | 822.81 ms/op | 799.66 ms/op | 1.03 | | hashObjectToByteArray 50023 times | 1.4396 ms/op | 1.4274 ms/op | 1.01 | | byteArrayToHashObject 50023 times | 1.6957 ms/op | 1.6548 ms/op | 1.02 | | getGindicesAtDepth | 4.0110 us/op | 3.8600 us/op | 1.04 | | iterateAtDepth | 8.5500 us/op | 8.5150 us/op | 1.00 | | getGindexBits | 422.00 ns/op | 421.00 ns/op | 1.00 | | gindexIterator | 986.00 ns/op | 933.00 ns/op | 1.06 | | hash 2 Uint8Array 2250026 times - as-sha256 | 2.2106 s/op | 2.2362 s/op | 0.99 | | hashTwoObjects 2250026 times - as-sha256 | 2.1533 s/op | 2.1564 s/op | 1.00 | | hash 2 Uint8Array 2250026 times - noble | 4.8420 s/op | 4.7406 s/op | 1.02 | | hashTwoObjects 2250026 times - noble | 6.9942 s/op | 6.7332 s/op | 1.04 | | getNodeH() x7812.5 avg hindex | 14.459 us/op | 14.409 us/op | 1.00 | | getNodeH() x7812.5 index 0 | 5.0860 us/op | 5.1250 us/op | 0.99 | | getNodeH() x7812.5 index 7 | 5.0800 us/op | 5.1680 us/op | 0.98 | | getNodeH() x7812.5 index 7 with key array | 5.0690 us/op | 5.1390 us/op | 0.99 | | new LeafNode() x7812.5 | 119.10 us/op | 111.39 us/op | 1.07 | | multiproof - depth 15, 1 requested leaves | 9.3630 us/op | 9.3550 us/op | 1.00 | | tree offset multiproof - depth 15, 1 requested leaves | 20.766 us/op | 20.399 us/op | 1.02 | | compact multiproof - depth 15, 1 requested leaves | 5.6220 us/op | 4.4130 us/op | 1.27 | | multiproof - depth 15, 2 requested leaves | 12.977 us/op | 12.830 us/op | 1.01 | | tree offset multiproof - depth 15, 2 requested leaves | 23.301 us/op | 22.875 us/op | 1.02 | | compact multiproof - depth 15, 2 requested leaves | 3.3030 us/op | 3.3090 us/op | 1.00 | | multiproof - depth 15, 3 requested leaves | 17.792 us/op | 18.287 us/op | 0.97 | | tree offset multiproof - depth 15, 3 requested leaves | 30.561 us/op | 30.574 us/op | 1.00 | | compact multiproof - depth 15, 3 requested leaves | 4.5420 us/op | 4.4640 us/op | 1.02 | | multiproof - depth 15, 4 requested leaves | 23.598 us/op | 24.365 us/op | 0.97 | | tree offset multiproof - depth 15, 4 requested leaves | 37.445 us/op | 37.778 us/op | 0.99 | | compact multiproof - depth 15, 4 requested leaves | 5.2690 us/op | 5.2210 us/op | 1.01 | | packedRootsBytesToLeafNodes bytes 4000 offset 0 | 2.0420 us/op | 1.9800 us/op | 1.03 | | packedRootsBytesToLeafNodes bytes 4000 offset 1 | 2.0330 us/op | 1.9590 us/op | 1.04 | | packedRootsBytesToLeafNodes bytes 4000 offset 2 | 2.0400 us/op | 1.9800 us/op | 1.03 | | packedRootsBytesToLeafNodes bytes 4000 offset 3 | 2.0350 us/op | 1.9560 us/op | 1.04 | | subtreeFillToContents depth 40 count 250000 | 39.266 ms/op | 39.368 ms/op | 1.00 | | setRoot - gindexBitstring | 9.2181 ms/op | 8.5172 ms/op | 1.08 | | setRoot - gindex | 9.8306 ms/op | 9.0764 ms/op | 1.08 | | getRoot - gindexBitstring | 2.5231 ms/op | 2.5640 ms/op | 0.98 | | getRoot - gindex | 3.2445 ms/op | 3.1508 ms/op | 1.03 | | getHashObject then setHashObject | 10.631 ms/op | 10.166 ms/op | 1.05 | | setNodeWithFn | 9.3886 ms/op | 9.0640 ms/op | 1.04 | | getNodeAtDepth depth 0 x100000 | 1.1447 ms/op | 1.1438 ms/op | 1.00 | | setNodeAtDepth depth 0 x100000 | 2.7060 ms/op | 2.5510 ms/op | 1.06 | | getNodesAtDepth depth 0 x100000 | 1.0844 ms/op | 1.0842 ms/op | 1.00 | | setNodesAtDepth depth 0 x100000 | 1.4840 ms/op | 1.4858 ms/op | 1.00 | | getNodeAtDepth depth 1 x100000 | 1.2074 ms/op | 1.2074 ms/op | 1.00 | | setNodeAtDepth depth 1 x100000 | 5.9417 ms/op | 5.7563 ms/op | 1.03 | | getNodesAtDepth depth 1 x100000 | 1.2071 ms/op | 1.2102 ms/op | 1.00 | | setNodesAtDepth depth 1 x100000 | 4.7575 ms/op | 4.7858 ms/op | 0.99 | | getNodeAtDepth depth 2 x100000 | 1.5158 ms/op | 1.4851 ms/op | 1.02 | | setNodeAtDepth depth 2 x100000 | 10.033 ms/op | 10.353 ms/op | 0.97 | | getNodesAtDepth depth 2 x100000 | 18.646 ms/op | 20.052 ms/op | 0.93 | | setNodesAtDepth depth 2 x100000 | 13.877 ms/op | 15.723 ms/op | 0.88 | | tree.getNodesAtDepth - gindexes | 6.1358 ms/op | 6.6621 ms/op | 0.92 | | tree.getNodesAtDepth - push all nodes | 2.2968 ms/op | 2.1262 ms/op | 1.08 | | tree.getNodesAtDepth - navigation | 157.50 us/op | 159.47 us/op | 0.99 | | tree.setNodesAtDepth - indexes | 339.78 us/op | 373.75 us/op | 0.91 | | set at depth 8 | 525.00 ns/op | 502.00 ns/op | 1.05 | | set at depth 16 | 675.00 ns/op | 654.00 ns/op | 1.03 | | set at depth 32 | 1.0790 us/op | 1.0130 us/op | 1.07 | | iterateNodesAtDepth 8 256 | 14.133 us/op | 15.787 us/op | 0.90 | | getNodesAtDepth 8 256 | 3.4200 us/op | 3.3960 us/op | 1.01 | | iterateNodesAtDepth 16 65536 | 4.4570 ms/op | 4.7877 ms/op | 0.93 | | getNodesAtDepth 16 65536 | 2.1116 ms/op | 1.9030 ms/op | 1.11 | | iterateNodesAtDepth 32 250000 | 17.237 ms/op | 17.954 ms/op | 0.96 | | getNodesAtDepth 32 250000 | 4.2649 ms/op | 4.5617 ms/op | 0.93 | | iterateNodesAtDepth 40 250000 | 15.272 ms/op | 17.781 ms/op | 0.86 | | getNodesAtDepth 40 250000 | 4.2399 ms/op | 4.5609 ms/op | 0.93 | | 250k validators | 7.2027 s/op | 7.5290 s/op | 0.96 | | bitlist bytes to struct (120,90) | 589.00 ns/op | 631.00 ns/op | 0.93 | | bitlist bytes to tree (120,90) | 2.3680 us/op | 2.4810 us/op | 0.95 | | bitlist bytes to struct (2048,2048) | 1.0100 us/op | 1.0710 us/op | 0.94 | | bitlist bytes to tree (2048,2048) | 3.6480 us/op | 3.8530 us/op | 0.95 | | ByteListType - deserialize | 8.2260 ms/op | 8.0300 ms/op | 1.02 | | BasicListType - deserialize | 7.7838 ms/op | 9.2722 ms/op | 0.84 | | ByteListType - serialize | 8.2417 ms/op | 8.2821 ms/op | 1.00 | | BasicListType - serialize | 10.245 ms/op | 10.934 ms/op | 0.94 | | BasicListType - tree_convertToStruct | 21.433 ms/op | 23.362 ms/op | 0.92 | | List[uint8, 68719476736] len 300000 ViewDU.getAll() + iterate | 4.1978 ms/op | 4.2532 ms/op | 0.99 | | List[uint8, 68719476736] len 300000 ViewDU.get(i) | 4.1372 ms/op | 4.1441 ms/op | 1.00 | | Array.push len 300000 empty Array - number | 5.6326 ms/op | 6.2390 ms/op | 0.90 | | Array.set len 300000 from new Array - number | 1.8363 ms/op | 1.5957 ms/op | 1.15 | | Array.set len 300000 - number | 5.6161 ms/op | 5.1734 ms/op | 1.09 | | Uint8Array.set len 300000 | 205.46 us/op | 211.81 us/op | 0.97 | | Uint32Array.set len 300000 | 279.40 us/op | 284.65 us/op | 0.98 | | Container({a: uint8, b: uint8}) getViewDU x300000 | 22.068 ms/op | 19.899 ms/op | 1.11 | | ContainerNodeStruct({a: uint8, b: uint8}) getViewDU x300000 | 9.2973 ms/op | 9.2207 ms/op | 1.01 | | List(Container) len 300000 ViewDU.getAllReadonly() + iterate | 198.96 ms/op | 209.18 ms/op | 0.95 | | List(Container) len 300000 ViewDU.getAllReadonlyValues() + iterate | 304.98 ms/op | 296.48 ms/op | 1.03 | | List(Container) len 300000 ViewDU.get(i) | 6.6822 ms/op | 6.3656 ms/op | 1.05 | | List(Container) len 300000 ViewDU.getReadonly(i) | 6.5784 ms/op | 6.2410 ms/op | 1.05 | | List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonly() + iterate | 39.170 ms/op | 36.206 ms/op | 1.08 | | List(ContainerNodeStruct) len 300000 ViewDU.getAllReadonlyValues() + iterate | 6.0570 ms/op | 5.2422 ms/op | 1.16 | | List(ContainerNodeStruct) len 300000 ViewDU.get(i) | 6.6072 ms/op | 5.9607 ms/op | 1.11 | | List(ContainerNodeStruct) len 300000 ViewDU.getReadonly(i) | 6.0370 ms/op | 5.8236 ms/op | 1.04 | | Array.push len 300000 empty Array - object | 5.9150 ms/op | 5.9937 ms/op | 0.99 | | Array.set len 300000 from new Array - object | 2.1686 ms/op | 1.9119 ms/op | 1.13 | | Array.set len 300000 - object | 6.2750 ms/op | 6.1610 ms/op | 1.02 | | cachePermanentRootStruct no cache | 8.8410 us/op | 8.6480 us/op | 1.02 | | cachePermanentRootStruct with cache | 211.00 ns/op | 213.00 ns/op | 0.99 | | epochParticipation len 250000 rws 7813 | 2.3077 ms/op | 2.2801 ms/op | 1.01 | | deserialize Attestation - tree | 2.9730 us/op | 3.2170 us/op | 0.92 | | deserialize Attestation - struct | 1.9580 us/op | 2.0820 us/op | 0.94 | | deserialize SignedAggregateAndProof - tree | 3.6940 us/op | 3.6060 us/op | 1.02 | | deserialize SignedAggregateAndProof - struct | 3.1460 us/op | 3.0420 us/op | 1.03 | | deserialize SyncCommitteeMessage - tree | 1.1480 us/op | 1.1750 us/op | 0.98 | | deserialize SyncCommitteeMessage - struct | 1.2420 us/op | 1.2250 us/op | 1.01 | | deserialize SignedContributionAndProof - tree | 1.9910 us/op | 1.9430 us/op | 1.02 | | deserialize SignedContributionAndProof - struct | 2.6960 us/op | 2.4660 us/op | 1.09 | | deserialize SignedBeaconBlock - tree | 230.46 us/op | 210.10 us/op | 1.10 | | deserialize SignedBeaconBlock - struct | 137.70 us/op | 122.17 us/op | 1.13 | | BeaconState vc 300000 - deserialize tree | 622.35 ms/op | 603.89 ms/op | 1.03 | | BeaconState vc 300000 - serialize tree | 144.03 ms/op | 144.99 ms/op | 0.99 | | BeaconState.historicalRoots vc 300000 - deserialize tree | 829.00 ns/op | 829.00 ns/op | 1.00 | | BeaconState.historicalRoots vc 300000 - serialize tree | 709.00 ns/op | 799.00 ns/op | 0.89 | | BeaconState.validators vc 300000 - deserialize tree | 581.96 ms/op | 554.55 ms/op | 1.05 | | BeaconState.validators vc 300000 - serialize tree | 117.92 ms/op | 147.16 ms/op | 0.80 | | BeaconState.balances vc 300000 - deserialize tree | 21.480 ms/op | 20.539 ms/op | 1.05 | | BeaconState.balances vc 300000 - serialize tree | 3.9866 ms/op | 4.0953 ms/op | 0.97 | | BeaconState.previousEpochParticipation vc 300000 - deserialize tree | 600.97 us/op | 599.09 us/op | 1.00 | | BeaconState.previousEpochParticipation vc 300000 - serialize tree | 289.74 us/op | 275.36 us/op | 1.05 | | BeaconState.currentEpochParticipation vc 300000 - deserialize tree | 543.25 us/op | 569.83 us/op | 0.95 | | BeaconState.currentEpochParticipation vc 300000 - serialize tree | 284.04 us/op | 274.37 us/op | 1.04 | | BeaconState.inactivityScores vc 300000 - deserialize tree | 21.904 ms/op | 20.824 ms/op | 1.05 | | BeaconState.inactivityScores vc 300000 - serialize tree | 3.0050 ms/op | 3.0102 ms/op | 1.00 | | hashTreeRoot Attestation - struct | 27.115 us/op | 27.035 us/op | 1.00 | | hashTreeRoot Attestation - tree | 18.171 us/op | 19.708 us/op | 0.92 | | hashTreeRoot SignedAggregateAndProof - struct | 38.222 us/op | 38.885 us/op | 0.98 | | hashTreeRoot SignedAggregateAndProof - tree | 27.689 us/op | 27.724 us/op | 1.00 | | hashTreeRoot SyncCommitteeMessage - struct | 9.0990 us/op | 9.1540 us/op | 0.99 | | hashTreeRoot SyncCommitteeMessage - tree | 6.2060 us/op | 6.2130 us/op | 1.00 | | hashTreeRoot SignedContributionAndProof - struct | 26.126 us/op | 26.128 us/op | 1.00 | | hashTreeRoot SignedContributionAndProof - tree | 19.815 us/op | 19.460 us/op | 1.02 | | hashTreeRoot SignedBeaconBlock - struct | 2.3385 ms/op | 2.3208 ms/op | 1.01 | | hashTreeRoot SignedBeaconBlock - tree | 1.6884 ms/op | 1.6666 ms/op | 1.01 | | hashTreeRoot Validator - struct | 12.801 us/op | 12.914 us/op | 0.99 | | hashTreeRoot Validator - tree | 11.069 us/op | 11.019 us/op | 1.00 | | BeaconState vc 300000 - hashTreeRoot tree | 3.7061 s/op | 3.6900 s/op | 1.00 | | BeaconState.historicalRoots vc 300000 - hashTreeRoot tree | 1.5050 us/op | 1.5260 us/op | 0.99 | | BeaconState.validators vc 300000 - hashTreeRoot tree | 3.4366 s/op | 3.5851 s/op | 0.96 | | BeaconState.balances vc 300000 - hashTreeRoot tree | 85.230 ms/op | 84.735 ms/op | 1.01 | | BeaconState.previousEpochParticipation vc 300000 - hashTreeRoot tree | 8.9992 ms/op | 9.0065 ms/op | 1.00 | | BeaconState.currentEpochParticipation vc 300000 - hashTreeRoot tree | 9.0064 ms/op | 9.0226 ms/op | 1.00 | | BeaconState.inactivityScores vc 300000 - hashTreeRoot tree | 82.849 ms/op | 88.197 ms/op | 0.94 | | hash64 x18 | 18.978 us/op | 19.458 us/op | 0.98 | | hashTwoObjects x18 | 17.884 us/op | 18.181 us/op | 0.98 | | hash64 x1740 | 1.7991 ms/op | 1.8439 ms/op | 0.98 | | hashTwoObjects x1740 | 1.7230 ms/op | 1.6973 ms/op | 1.02 | | hash64 x2700000 | 2.7944 s/op | 2.8515 s/op | 0.98 | | hashTwoObjects x2700000 | 2.6584 s/op | 2.6420 s/op | 1.01 | | get_exitEpoch - ContainerType | 209.00 ns/op | 214.00 ns/op | 0.98 | | get_exitEpoch - ContainerNodeStructType | 196.00 ns/op | 216.00 ns/op | 0.91 | | set_exitEpoch - ContainerType | 237.00 ns/op | 256.00 ns/op | 0.93 | | set_exitEpoch - ContainerNodeStructType | 207.00 ns/op | 242.00 ns/op | 0.86 | | get_pubkey - ContainerType | 1.0130 us/op | 1.2390 us/op | 0.82 | | get_pubkey - ContainerNodeStructType | 213.00 ns/op | 233.00 ns/op | 0.91 | | hashTreeRoot - ContainerType | 373.00 ns/op | 451.00 ns/op | 0.83 | | hashTreeRoot - ContainerNodeStructType | 416.00 ns/op | 492.00 ns/op | 0.85 | | createProof - ContainerType | 3.8100 us/op | 4.0570 us/op | 0.94 | | createProof - ContainerNodeStructType | 20.805 us/op | 23.408 us/op | 0.89 | | serialize - ContainerType | 1.7100 us/op | 2.1380 us/op | 0.80 | | serialize - ContainerNodeStructType | 1.4570 us/op | 1.6530 us/op | 0.88 | | set_exitEpoch_and_hashTreeRoot - ContainerType | 4.1480 us/op | 4.2750 us/op | 0.97 | | set_exitEpoch_and_hashTreeRoot - ContainerNodeStructType | 11.208 us/op | 11.593 us/op | 0.97 | | Array - for of | 5.9980 us/op | 6.1060 us/op | 0.98 | | Array - for(;;) | 5.4750 us/op | 5.4370 us/op | 1.01 | | basicListValue.readonlyValuesArray() | 3.6533 ms/op | 3.8111 ms/op | 0.96 | | basicListValue.readonlyValuesArray() + loop all | 3.7165 ms/op | 3.7721 ms/op | 0.99 | | compositeListValue.readonlyValuesArray() | 25.704 ms/op | 27.051 ms/op | 0.95 | | compositeListValue.readonlyValuesArray() + loop all | 24.938 ms/op | 22.815 ms/op | 1.09 | | Number64UintType - get balances list | 4.0597 ms/op | 4.5024 ms/op | 0.90 | | Number64UintType - set balances list | 8.9038 ms/op | 9.2937 ms/op | 0.96 | | Number64UintType - get and increase 10 then set | 38.481 ms/op | 37.507 ms/op | 1.03 | | Number64UintType - increase 10 using applyDelta | 14.626 ms/op | 15.427 ms/op | 0.95 | | Number64UintType - increase 10 using applyDeltaInBatch | 14.722 ms/op | 16.109 ms/op | 0.91 | | tree_newTreeFromUint64Deltas | 15.771 ms/op | 16.340 ms/op | 0.97 | | unsafeUint8ArrayToTree | 27.900 ms/op | 33.060 ms/op | 0.84 | | bitLength(50) | 229.00 ns/op | 231.00 ns/op | 0.99 | | bitLengthStr(50) | 241.00 ns/op | 233.00 ns/op | 1.03 | | bitLength(8000) | 223.00 ns/op | 218.00 ns/op | 1.02 | | bitLengthStr(8000) | 287.00 ns/op | 279.00 ns/op | 1.03 | | bitLength(250000) | 221.00 ns/op | 219.00 ns/op | 1.01 | | bitLengthStr(250000) | 319.00 ns/op | 317.00 ns/op | 1.01 | | floor - Math.floor (53) | 0.46959 ns/op | 0.46511 ns/op | 1.01 | | floor - << 0 (53) | 0.46413 ns/op | 0.46675 ns/op | 0.99 | | floor - Math.floor (512) | 0.46450 ns/op | 0.46467 ns/op | 1.00 | | floor - << 0 (512) | 0.46399 ns/op | 0.46652 ns/op | 0.99 | | fnIf(0) | 1.5470 ns/op | 1.5460 ns/op | 1.00 | | fnSwitch(0) | 2.4718 ns/op | 2.4739 ns/op | 1.00 | | fnObj(0) | 0.46494 ns/op | 0.46596 ns/op | 1.00 | | fnArr(0) | 0.46456 ns/op | 0.46672 ns/op | 1.00 | | fnIf(4) | 2.1639 ns/op | 2.1672 ns/op | 1.00 | | fnSwitch(4) | 2.4741 ns/op | 2.4744 ns/op | 1.00 | | fnObj(4) | 0.46421 ns/op | 0.46520 ns/op | 1.00 | | fnArr(4) | 0.46459 ns/op | 0.46441 ns/op | 1.00 | | fnIf(9) | 3.0945 ns/op | 3.0955 ns/op | 1.00 | | fnSwitch(9) | 2.4744 ns/op | 2.4747 ns/op | 1.00 | | fnObj(9) | 0.46430 ns/op | 0.46414 ns/op | 1.00 | | fnArr(9) | 0.46598 ns/op | 0.46632 ns/op | 1.00 | | Container {a,b,vec} - as struct x100000 | 47.548 us/op | 46.807 us/op | 1.02 | | Container {a,b,vec} - as tree x100000 | 372.99 us/op | 371.61 us/op | 1.00 | | Container {a,vec,b} - as struct x100000 | 78.135 us/op | 77.491 us/op | 1.01 | | Container {a,vec,b} - as tree x100000 | 402.16 us/op | 402.62 us/op | 1.00 | | get 2 props x1000000 - rawObject | 309.97 us/op | 310.51 us/op | 1.00 | | get 2 props x1000000 - proxy | 72.763 ms/op | 71.340 ms/op | 1.02 | | get 2 props x1000000 - customObj | 309.39 us/op | 310.57 us/op | 1.00 | | Simple object binary -> struct | 619.00 ns/op | 677.00 ns/op | 0.91 | | Simple object binary -> tree_backed | 1.7420 us/op | 1.8790 us/op | 0.93 | | Simple object struct -> tree_backed | 2.2270 us/op | 2.3550 us/op | 0.95 | | Simple object tree_backed -> struct | 1.7580 us/op | 2.0850 us/op | 0.84 | | Simple object struct -> binary | 926.00 ns/op | 1.0400 us/op | 0.89 | | Simple object tree_backed -> binary | 1.5180 us/op | 1.7320 us/op | 0.88 | | aggregationBits binary -> struct | 543.00 ns/op | 612.00 ns/op | 0.89 | | aggregationBits binary -> tree_backed | 2.0860 us/op | 2.3470 us/op | 0.89 | | aggregationBits struct -> tree_backed | 2.4900 us/op | 3.0840 us/op | 0.81 | | aggregationBits tree_backed -> struct | 1.0600 us/op | 1.3370 us/op | 0.79 | | aggregationBits struct -> binary | 734.00 ns/op | 943.00 ns/op | 0.78 | | aggregationBits tree_backed -> binary | 922.00 ns/op | 1.1710 us/op | 0.79 | | List(uint8) 100000 binary -> struct | 1.3532 ms/op | 1.5123 ms/op | 0.89 | | List(uint8) 100000 binary -> tree_backed | 88.756 us/op | 120.82 us/op | 0.73 | | List(uint8) 100000 struct -> tree_backed | 1.3118 ms/op | 1.4987 ms/op | 0.88 | | List(uint8) 100000 tree_backed -> struct | 937.54 us/op | 967.99 us/op | 0.97 | | List(uint8) 100000 struct -> binary | 1.2250 ms/op | 1.3951 ms/op | 0.88 | | List(uint8) 100000 tree_backed -> binary | 85.422 us/op | 86.130 us/op | 0.99 | | List(uint64Number) 100000 binary -> struct | 1.1624 ms/op | 1.3366 ms/op | 0.87 | | List(uint64Number) 100000 binary -> tree_backed | 3.0751 ms/op | 3.2667 ms/op | 0.94 | | List(uint64Number) 100000 struct -> tree_backed | 4.6558 ms/op | 4.4198 ms/op | 1.05 | | List(uint64Number) 100000 tree_backed -> struct | 2.0765 ms/op | 2.4672 ms/op | 0.84 | | List(uint64Number) 100000 struct -> binary | 1.4092 ms/op | 1.6557 ms/op | 0.85 | | List(uint64Number) 100000 tree_backed -> binary | 828.33 us/op | 857.90 us/op | 0.97 | | List(Uint64Bigint) 100000 binary -> struct | 3.3633 ms/op | 3.6727 ms/op | 0.92 | | List(Uint64Bigint) 100000 binary -> tree_backed | 3.2382 ms/op | 3.1711 ms/op | 1.02 | | List(Uint64Bigint) 100000 struct -> tree_backed | 4.5156 ms/op | 5.3821 ms/op | 0.84 | | List(Uint64Bigint) 100000 tree_backed -> struct | 4.1237 ms/op | 4.4546 ms/op | 0.93 | | List(Uint64Bigint) 100000 struct -> binary | 2.0503 ms/op | 2.0691 ms/op | 0.99 | | List(Uint64Bigint) 100000 tree_backed -> binary | 806.61 us/op | 851.98 us/op | 0.95 | | Vector(Root) 100000 binary -> struct | 28.951 ms/op | 30.048 ms/op | 0.96 | | Vector(Root) 100000 binary -> tree_backed | 23.981 ms/op | 24.979 ms/op | 0.96 | | Vector(Root) 100000 struct -> tree_backed | 34.132 ms/op | 33.116 ms/op | 1.03 | | Vector(Root) 100000 tree_backed -> struct | 42.959 ms/op | 39.824 ms/op | 1.08 | | Vector(Root) 100000 struct -> binary | 1.8385 ms/op | 1.8913 ms/op | 0.97 | | Vector(Root) 100000 tree_backed -> binary | 8.3135 ms/op | 9.3856 ms/op | 0.89 | | List(Validator) 100000 binary -> struct | 102.84 ms/op | 104.74 ms/op | 0.98 | | List(Validator) 100000 binary -> tree_backed | 272.15 ms/op | 272.71 ms/op | 1.00 | | List(Validator) 100000 struct -> tree_backed | 287.67 ms/op | 282.33 ms/op | 1.02 | | List(Validator) 100000 tree_backed -> struct | 194.86 ms/op | 185.88 ms/op | 1.05 | | List(Validator) 100000 struct -> binary | 30.525 ms/op | 30.363 ms/op | 1.01 | | List(Validator) 100000 tree_backed -> binary | 97.776 ms/op | 96.615 ms/op | 1.01 | | List(Validator-NS) 100000 binary -> struct | 99.377 ms/op | 95.863 ms/op | 1.04 | | List(Validator-NS) 100000 binary -> tree_backed | 145.22 ms/op | 151.81 ms/op | 0.96 | | List(Validator-NS) 100000 struct -> tree_backed | 175.77 ms/op | 185.82 ms/op | 0.95 | | List(Validator-NS) 100000 tree_backed -> struct | 147.50 ms/op | 151.36 ms/op | 0.97 | | List(Validator-NS) 100000 struct -> binary | 30.594 ms/op | 30.539 ms/op | 1.00 | | List(Validator-NS) 100000 tree_backed -> binary | 35.431 ms/op | 36.278 ms/op | 0.98 | | get epochStatuses - MutableVector | 99.228 us/op | 94.288 us/op | 1.05 | | get epochStatuses - ViewDU | 196.60 us/op | 195.34 us/op | 1.01 | | set epochStatuses - ListTreeView | 1.3866 ms/op | 1.4369 ms/op | 0.96 | | set epochStatuses - ListTreeView - set() | 428.06 us/op | 447.12 us/op | 0.96 | | set epochStatuses - ListTreeView - commit() | 398.21 us/op | 410.78 us/op | 0.97 | | bitstring | 650.59 ns/op | 642.17 ns/op | 1.01 | | bit mask | 13.649 ns/op | 13.940 ns/op | 0.98 | | struct - increase slot to 1000000 | 929.24 us/op | 927.58 us/op | 1.00 | | UintNumberType - increase slot to 1000000 | 28.824 ms/op | 28.505 ms/op | 1.01 | | UintBigintType - increase slot to 1000000 | 410.63 ms/op | 404.10 ms/op | 1.02 | | UintBigint8 x 100000 tree_deserialize | 4.6654 ms/op | 3.7593 ms/op | 1.24 | | UintBigint8 x 100000 tree_serialize | 1.1862 ms/op | 1.1866 ms/op | 1.00 | | UintBigint16 x 100000 tree_deserialize | 4.4539 ms/op | 3.5223 ms/op | 1.26 | | UintBigint16 x 100000 tree_serialize | 1.1286 ms/op | 1.1479 ms/op | 0.98 | | UintBigint32 x 100000 tree_deserialize | 4.6619 ms/op | 5.2458 ms/op | 0.89 | | UintBigint32 x 100000 tree_serialize | 1.1922 ms/op | 1.2169 ms/op | 0.98 | | UintBigint64 x 100000 tree_deserialize | 4.9179 ms/op | 5.5721 ms/op | 0.88 | | UintBigint64 x 100000 tree_serialize | 1.5599 ms/op | 1.5799 ms/op | 0.99 | | UintBigint8 x 100000 value_deserialize | 433.15 us/op | 433.35 us/op | 1.00 | | UintBigint8 x 100000 value_serialize | 565.02 us/op | 595.01 us/op | 0.95 | | UintBigint16 x 100000 value_deserialize | 464.54 us/op | 464.74 us/op | 1.00 | | UintBigint16 x 100000 value_serialize | 608.21 us/op | 630.99 us/op | 0.96 | | UintBigint32 x 100000 value_deserialize | 433.90 us/op | 433.71 us/op | 1.00 | | UintBigint32 x 100000 value_serialize | 607.69 us/op | 626.07 us/op | 0.97 | | UintBigint64 x 100000 value_deserialize | 464.71 us/op | 470.35 us/op | 0.99 | | UintBigint64 x 100000 value_serialize | 780.95 us/op | 805.80 us/op | 0.97 | | UintBigint8 x 100000 deserialize | 4.4913 ms/op | 4.7229 ms/op | 0.95 | | UintBigint8 x 100000 serialize | 1.3963 ms/op | 1.4524 ms/op | 0.96 | | UintBigint16 x 100000 deserialize | 4.5437 ms/op | 4.6000 ms/op | 0.99 | | UintBigint16 x 100000 serialize | 1.4394 ms/op | 1.4943 ms/op | 0.96 | | UintBigint32 x 100000 deserialize | 5.2760 ms/op | 5.6218 ms/op | 0.94 | | UintBigint32 x 100000 serialize | 2.7414 ms/op | 2.8077 ms/op | 0.98 | | UintBigint64 x 100000 deserialize | 3.7203 ms/op | 3.6731 ms/op | 1.01 | | UintBigint64 x 100000 serialize | 1.4906 ms/op | 1.4961 ms/op | 1.00 | | UintBigint128 x 100000 deserialize | 6.0204 ms/op | 5.9133 ms/op | 1.02 | | UintBigint128 x 100000 serialize | 16.436 ms/op | 16.867 ms/op | 0.97 | | UintBigint256 x 100000 deserialize | 10.690 ms/op | 11.045 ms/op | 0.97 | | UintBigint256 x 100000 serialize | 49.365 ms/op | 49.953 ms/op | 0.99 | | Slice from Uint8Array x25000 | 977.37 us/op | 1.0132 ms/op | 0.96 | | Slice from ArrayBuffer x25000 | 16.801 ms/op | 17.379 ms/op | 0.97 | | Slice from ArrayBuffer x25000 + new Uint8Array | 17.521 ms/op | 19.184 ms/op | 0.91 | | Copy Uint8Array 100000 iterate | 790.42 us/op | 818.94 us/op | 0.97 | | Copy Uint8Array 100000 slice | 88.013 us/op | 89.874 us/op | 0.98 | | Copy Uint8Array 100000 Uint8Array.prototype.slice.call | 88.140 us/op | 89.785 us/op | 0.98 | | Copy Buffer 100000 Uint8Array.prototype.slice.call | 88.519 us/op | 89.811 us/op | 0.99 | | Copy Uint8Array 100000 slice + set | 146.80 us/op | 154.17 us/op | 0.95 | | Copy Uint8Array 100000 subarray + set | 88.327 us/op | 89.165 us/op | 0.99 | | Copy Uint8Array 100000 slice arrayBuffer | 88.990 us/op | 89.492 us/op | 0.99 | | Uint64 deserialize 100000 - iterate Uint8Array | 1.7193 ms/op | 1.7551 ms/op | 0.98 | | Uint64 deserialize 100000 - by Uint32A | 1.7124 ms/op | 1.7508 ms/op | 0.98 | | Uint64 deserialize 100000 - by DataView.getUint32 x2 | 1.7126 ms/op | 1.7232 ms/op | 0.99 | | Uint64 deserialize 100000 - by DataView.getBigUint64 | 4.7809 ms/op | 4.8253 ms/op | 0.99 | | Uint64 deserialize 100000 - by byte | 64.967 ms/op | 65.306 ms/op | 0.99 |

by benchmarkbot/action

twoeths commented 4 months ago

Implementation note for lodestar: use BeaconStateViewDU.serialize(), or the ViewDU.serializeToBytes() if there is a preallocated buffer