-
Notifications
You must be signed in to change notification settings - Fork 140
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
Combine non-atree domain payloads into atree payloads #3584
Comments
I was asked about impact of this, so I used mainnet state (Sept. 17 checkpoint) to create DRAFT estimates:
We can reduce payload count by 28% (instead of being limited to 24%) due to atree inlining. Reduction in payload count and mtrie nodes isn't as big as atree v.0.8.0 (Sept. 4, 2024) but goals are similar. In general, benefits from reducing payload counts and eliminating mtrie nodes include:
Each coding change can't always eliminate 1 billion mtrie nodes, but smaller reductions can eventually become greater. |
it seems like there is also 140M registers ( ~ 4 per account ) used by flow-go, ( account status, keys etc ) maybe it can be good to consider them also. Would be nice to migrate everything to atree. ( as flow-go now uses atree anyway for EVM stuff ) |
Yes, definitely worth considering! 👍 |
I replaced text promising 25% reduction of EN memory (that estimate isn't from me). Payload count can be reduced by 20-30% by combining their content, so their content is not lost. However, we can safely eliminate 20-30% of mtrie nodes (96 bytes each). Note If we use on-the-fly migration, then the full impact won't be realized until all accounts are eventually migrated. Unless we do a full migration, we won't immediately see the full benefits. After all the non-atree domain registers are migrated, we should get:
While at it, I listed other benefits (memory reduction is only 1 benefit). Also, more than EN can benefit when we reduce state size by reducing payload counts, etc. |
On mainnet, average number of domains per account is just over 4. For each new account having 4 domains, I think we would save around 1152 bytes. |
To test the impact of PR #3664, I created a full migration program and ran it on mainnet data (Nov 1, 2024 state). The full migration program on a test vm produced expected results for reducing number of payloads and mtrie nodes by 28.7% each. 🎉 However, the plan is to deploy PR #3664 as HCU and use its on-the-fly migration feature (no downtime), so the full impact won't be seen until all accounts (including read-only and idle accounts) are eventually migrated. |
Why
We can reduce memory, storage use, etc. by combining non-atree domain registers into 1 atree payload per account. We can further reduce execution state size by using atree register inlining feature added in Atree v0.8.0.
This improvement can be deployed via HCU and implements first on-the-fly migration to avoid causing further downtime.
The full impact on memory reduction (TBD) will be realized after all the accounts eventually migrate all their non-atree domain registers to a single combined atree payload per account.
NOTE: Memory reduction is only 1 benefit from reducing payload count.
How will we measure success ?
After all the non-atree domain registers are migrated to 1 atree map per account we expect:
Requires HCU.
If we use on-the-fly migration, then the full impact won't be realized until all accounts are migrated.
Requires "cleanup" migration for accounts that were not migrated on-the-fly.
Estimate
~3dev/weeks to get ready for deployment.
DACI
Details
New domains were added in Cadence 1.0 and domain register count increased to 150 million (was 80 million on Sept. 4 pre-spork). Each 8-byte domain register also requires ~2 mtrie nodes (~2x96 byte overhead).
Nearly 25% of total payloads are 8-byte domain registers.
These 8-byte "domain registers" refers to 8-byte account domain payloads. They are not atree payloads.
As of Sept 10, 2024, mainnet state had:
Suggestion
Currently, all 150+ million account domain registers are not using atree.
I think we should replace non-atree domain registers with 1 atree register (atree map) per account. Currently, there are 35 million accounts.
Also, we can use atree inlining to inline small domain data. So instead of reducing payload count from 150 million to 35 million, we can reduce payload count by 174 million.
DRAFT Estimates
Based on preliminary estimates using Sept. 17, 2024 mainnet state, I think we can:
We can reduce payload count by 28% (instead of being limited to 24%) due to atree inlining.
Misc
This issue replaces my older issue #2867.
EDIT: add DRAFT estimates and mention why we can reduce 174 million payload count if there are only 150 million domain registers.
Effort Estimation
2dev/weeks to wrap-up testing and open PR for review. Will need @turbolent to review.
The text was updated successfully, but these errors were encountered: