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

Fast tree views demo #197

Closed
wants to merge 81 commits into from
Closed

Fast tree views demo #197

wants to merge 81 commits into from

Conversation

dapplion
Copy link
Contributor

Motivation

Partial POC for #196

Description

Research how implementing #196 would look like in our ssz library

@github-actions
Copy link

github-actions bot commented Oct 11, 2021

⚠️ Performance Alert ⚠️

Possible performance regression was detected for some benchmarks.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold.

Benchmark suite Current: 491435d Previous: 041c8dd Ratio
ByteListType - deserialize 13.779 ms/op 3.8651 ms/op 3.57
BasicListType - deserialize 487.09 ms/op 132.41 ms/op 3.68
ByteListType - tree_convertToStruct 576.50 ms/op 147.89 ms/op 3.90
BasicListType - tree_convertToStruct 2.6002 s/op 581.48 ms/op 4.47
Full benchmark results
Benchmark suite Current: 491435d Previous: 041c8dd Ratio
getNodeH() x7812.5 avg hindex 23.863 us/op
getNodeH() x7812.5 index 0 8.2790 us/op
getNodeH() x7812.5 index 7 8.2920 us/op
getNodeH() x7812.5 index 7 with key array 8.2840 us/op
new LeafNode() x7812.5 161.56 us/op
packedRootsBytesToLeafNodes bytes 4000 offset 0 4.9500 us/op
packedRootsBytesToLeafNodes bytes 4000 offset 1 4.8450 us/op
packedRootsBytesToLeafNodes bytes 4000 offset 2 4.7540 us/op
packedRootsBytesToLeafNodes bytes 4000 offset 3 4.6900 us/op
bitlist bytes to struct (120,90) 30.546 us/op 30.979 us/op 0.99
bitlist bytes to tree (120,90) 2.2330 us/op 2.2790 us/op 0.98
bitlist bytes to struct (2048,2048) 521.01 us/op 521.99 us/op 1.00
bitlist bytes to tree (2048,2048) 7.2470 us/op 6.9410 us/op 1.04
ByteListType - deserialize 13.779 ms/op 3.8651 ms/op 3.57
BasicListType - deserialize 487.09 ms/op 132.41 ms/op 3.68
ByteListType - serialize 69.381 ms/op 44.075 ms/op 1.57
BasicListType - serialize 69.012 ms/op 44.055 ms/op 1.57
ByteListType - tree_convertToStruct 576.50 ms/op 147.89 ms/op 3.90
BasicListType - tree_convertToStruct 2.6002 s/op 581.48 ms/op 4.47
cachePermanentRootStruct no cache 15.950 us/op
cachePermanentRootStruct with cache 434.00 ns/op
deserialize Attestation - struct 39.588 us/op 38.361 us/op 1.03
deserialize Attestation - tree 14.030 us/op 12.966 us/op 1.08
deserialize SignedAggregateAndProof - struct 49.282 us/op 48.926 us/op 1.01
deserialize SignedAggregateAndProof - tree 20.071 us/op 18.401 us/op 1.09
deserialize SignedContributionAndProof - struct 38.375 us/op 38.639 us/op 0.99
epochParticipation len 250000 rws 7813 25.533 ms/op 23.926 ms/op 1.07
Array - for of 10.544 us/op 10.542 us/op 1.00
Array - for(;;) 7.1910 us/op 7.1800 us/op 1.00
basicListValue.readonlyValues() 219.92 ms/op 201.30 ms/op 1.09
basicListValue.readonlyValuesArray() 198.16 ms/op 175.17 ms/op 1.13
basicListValue.readonlyValues() + iterate all 212.38 ms/op 187.11 ms/op 1.14
basicListValue.readonlyValuesArray() + loop all 198.13 ms/op 175.00 ms/op 1.13
compositeListValue.readonlyValues() 242.86 ms/op 216.01 ms/op 1.12
compositeListValue.readonlyValuesArray() 253.77 ms/op 226.25 ms/op 1.12
compositeListValue.readonlyValues() + iterate all 165.08 ms/op 138.94 ms/op 1.19
compositeListValue.readonlyValuesArray() + loop all 223.86 ms/op 210.45 ms/op 1.06
NumberUintType - get balances list 757.73 ms/op 696.70 ms/op 1.09
Number64UintType - get balances list 394.49 ms/op 442.20 ms/op 0.89
NumberUintType - set balances list 1.2732 s/op 1.0305 s/op 1.24
Number64UintType - set balances list 1.0743 s/op 805.94 ms/op 1.33
Number64UintType - get and increase 10 then set 1.4462 s/op 1.2304 s/op 1.18
Number64UintType - increase 10 using applyDelta 526.35 ms/op 486.02 ms/op 1.08
Number64UintType - increase 10 using applyDeltaInBatch 549.84 ms/op 506.18 ms/op 1.09
tree_newTreeFromUint64Deltas 52.207 ms/op 53.666 ms/op 0.97
unsafeUint8ArrayToTree 55.085 ms/op 49.303 ms/op 1.12
bitLength(50) 446.00 ns/op
bitLengthStr(50) 613.00 ns/op
bitLength(8000) 440.00 ns/op
bitLengthStr(8000) 768.00 ns/op
bitLength(250000) 442.00 ns/op
bitLengthStr(250000) 849.00 ns/op
floor - Math.floor (53) 0.67025 ns/op
floor - << 0 (53) 0.50292 ns/op
floor - Math.floor (512) 0.67002 ns/op
floor - << 0 (512) 0.50278 ns/op
fnIf(0) 2.6788 ns/op
fnSwitch(0) 3.6850 ns/op
fnObj(0) 0.67006 ns/op
fnArr(0) 0.66990 ns/op
fnIf(4) 4.3532 ns/op
fnSwitch(4) 5.0220 ns/op
fnObj(4) 0.66996 ns/op
fnArr(4) 0.67005 ns/op
fnIf(9) 6.7037 ns/op
fnSwitch(9) 6.6964 ns/op
fnObj(9) 0.66991 ns/op
fnArr(9) 0.66993 ns/op
Container {a,b,vec} - as struct x100000 67.474 us/op 59.763 us/op 1.13
Container {a,b,vec} - as tree x100000 91.674 ms/op 81.071 ms/op 1.13
Container {a,vec,b} - as struct x100000 100.97 us/op 89.009 us/op 1.13
Container {a,vec,b} - as tree x100000 91.418 ms/op 81.683 ms/op 1.12
get 2 props x1000000 - rawObject 335.33 us/op
get 2 props x1000000 - proxy 117.53 ms/op
get 2 props x1000000 - customObj 335.29 us/op
Simple object binary -> struct 2.1000 us/op 1.9020 us/op 1.10
Simple object binary -> tree_backed 2.4670 us/op 2.2210 us/op 1.11
Simple object struct -> tree_backed 1.7480 us/op 1.6140 us/op 1.08
Simple object tree_backed -> struct 1.7810 us/op 1.5560 us/op 1.14
Simple object struct -> binary 2.1910 us/op 2.0540 us/op 1.07
Simple object tree_backed -> binary 3.3090 us/op 3.0600 us/op 1.08
aggregationBits binary -> struct 34.411 us/op 29.496 us/op 1.17
aggregationBits binary -> tree_backed 1.7780 us/op 1.6240 us/op 1.09
aggregationBits struct -> tree_backed 5.0970 us/op 4.4610 us/op 1.14
aggregationBits tree_backed -> struct 35.895 us/op 31.588 us/op 1.14
aggregationBits struct -> binary 4.0020 us/op 3.4350 us/op 1.17
aggregationBits tree_backed -> binary 5.1380 us/op 4.5940 us/op 1.12
List(BigInt) 1000 binary -> struct 374.56 us/op 330.42 us/op 1.13
List(BigInt) 1000 binary -> tree_backed 248.10 us/op 215.28 us/op 1.15
List(BigInt) 1000 struct -> tree_backed 298.31 us/op 256.96 us/op 1.16
List(BigInt) 1000 tree_backed -> struct 898.89 us/op 790.91 us/op 1.14
List(BigInt) 1000 struct -> binary 188.72 us/op 164.00 us/op 1.15
List(BigInt) 1000 tree_backed -> binary 42.376 us/op 38.912 us/op 1.09
List(BigInt) 10000 binary -> struct 3.7625 ms/op 3.3598 ms/op 1.12
List(BigInt) 10000 binary -> tree_backed 3.1917 ms/op 2.7368 ms/op 1.17
List(BigInt) 10000 struct -> tree_backed 3.1025 ms/op 2.6747 ms/op 1.16
List(BigInt) 10000 tree_backed -> struct 10.451 ms/op 9.3951 ms/op 1.11
List(BigInt) 10000 struct -> binary 1.8677 ms/op 1.6132 ms/op 1.16
List(BigInt) 10000 tree_backed -> binary 391.86 us/op 367.59 us/op 1.07
List(BigInt) 100000 binary -> struct 48.178 ms/op 44.425 ms/op 1.08
List(BigInt) 100000 binary -> tree_backed 48.980 ms/op 43.700 ms/op 1.12
List(BigInt) 100000 struct -> tree_backed 41.443 ms/op 35.948 ms/op 1.15
List(BigInt) 100000 tree_backed -> struct 128.83 ms/op 133.00 ms/op 0.97
List(BigInt) 100000 struct -> binary 18.494 ms/op 18.092 ms/op 1.02
List(BigInt) 100000 tree_backed -> binary 4.4555 ms/op 4.1192 ms/op 1.08
get epochStatuses - MutableVector 121.85 us/op
get epochStatuses - ListTreeView 228.56 us/op
get epochStatuses - Tree 17.676 ms/op
set epochStatuses - ListTreeView 2.2174 ms/op
set epochStatuses - Tree 32.517 ms/op
bitstring 816.81 ns/op
bit mask 21.561 ns/op
struct - increase slot to 1000000 2.6967 ms/op 2.6764 ms/op 1.01
NumberUintType - increase slot to 1000000 1.1879 s/op 1.1050 s/op 1.07
Number64UintType - increase slot to 1000000 315.97 ms/op 322.20 ms/op 0.98
get_exitEpoch - ContainerType 692.00 ns/op 705.00 ns/op 0.98
get_exitEpoch - ContainerLeafNodeStructType 543.00 ns/op 523.00 ns/op 1.04
set_exitEpoch - ContainerType 796.00 ns/op 763.00 ns/op 1.04
set_exitEpoch - ContainerLeafNodeStructType 934.00 ns/op 842.00 ns/op 1.11
get_pubkey - ContainerType 2.0570 us/op 1.6660 us/op 1.23
get_pubkey - ContainerLeafNodeStructType 589.00 ns/op 503.00 ns/op 1.17
hashTreeRoot - ContainerType 732.00 ns/op 637.00 ns/op 1.15
hashTreeRoot - ContainerLeafNodeStructType 747.00 ns/op 656.00 ns/op 1.14
createProof - ContainerType 7.1170 us/op 6.0420 us/op 1.18
createProof - ContainerLeafNodeStructType 26.887 us/op 22.398 us/op 1.20
serialize - ContainerType 5.7680 us/op 5.0530 us/op 1.14
serialize - ContainerLeafNodeStructType 3.4220 us/op 2.9650 us/op 1.15
set_exitEpoch_and_hashTreeRoot - ContainerType 7.4270 us/op 6.3700 us/op 1.17
set_exitEpoch_and_hashTreeRoot - ContainerLeafNodeStructType 27.241 us/op 22.640 us/op 1.20

by benchmarkbot/action

@dapplion
Copy link
Contributor Author

To be replaced with proper PR

@dapplion dapplion closed this Jan 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant