onflow / atree

Atree provides scalable arrays and scalable ordered maps.
https://onflow.org
Apache License 2.0
40 stars 16 forks source link

Optimize atree to reduce Flow's mtrie size and reduce number of reads #292

Closed fxamacker closed 1 month ago

fxamacker commented 1 year ago

Issue To Be Solved

We should make Execution Nodes use less memory without sacrificing performance. Also, given the same user data growth rate, we should reduce the rate of Execution Node system requirements growth.

Suggested Solution and Implementation

Solution requires changes to onflow/atree, onflow/cadence, onflow/flow-go, and data migration.

See also:

Atree Inlining & Deduplication

Before/After Comparison Using Aug 14, 2024 Devnet State

Mtrie Nodes and Atree Payloads Atree Payload Sizes (bytes)
#### Total Counts | | Before | After | Change | | :---: | ---: | ---: | ---: | | mtrie nodes | 1,182,195,945 | 343,949,052 | -838,246,893 | | atree payloads | 455,399,623 | 102,283,931 | -353,115,692 | #### Total Sizes | | Before | After | Change | | :---: | ---: | ---: | ---: | | mtrie nodes | 113.49 GB | 33.02 GB | -80.47 GB | | atree payloads | 87.74 GB | 69.28 GB | -18.46 GB | | combined | 201.23 GB | 102.30 GB | -98.93 GB | | | Before | After | | :---: | ---: | ---: | | count | 455,399,623 | 102,283,931 | | mean | 192.7 | 677.4 | | std | 996.4 | 2,065.7 | | min | 13 | 22 | | 25% | 88 | 199 | | 50% | 139 | 665 | | 75% | 206 | 1,043 | | 99% | 876 | 1,267 | | 99.5% | 1,078 | 1,453 | | max | 5,853,892 | 5,853,892 |

Atree inlining and data deduplication on testnet indicates:

NOTE: Impact on testnet and mainnet will differ, depending on actual usage, data, etc.

Impact on memory and storage size

image

image

These charts should probably be updated when time allows.

Impact on payload count and node count

image

image

These charts should probably be updated when time allows.

j1010001 commented 4 months ago

Complete TPS throughput test before closing:

Test 1 - non-inlined state

Test 2 - atree-inlined state

Doc that contains necessary steps: https://www.notion.so/flowfoundation/Execution-Fork-Handbook-a8b70533978c44c5963bc68af99a536d

fxamacker commented 1 month ago

@j1010001 thanks again for providing testnet memory reduction screenshot we can share on GitHub!

Closing this as completed. Please re-open if needed! :pray: