-
Notifications
You must be signed in to change notification settings - Fork 138
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. |
Progress Update (Nov 4-15)On Nov 4 and Nov 13, we ran full migrations with mainnet data and test results were better than estimated. They also satisfy the "How do we measure success" criteria. All full migration test runs detected no problems 🎉 and Nov 13 results show:
On Nov 5, PR reviews started for this OKR. On Nov 12, we merged all PRs 🎉 (to feature branch) for the approved work for using HCU to migrate accounts having write ops.
The remaining work of refactoring to make code easier to understand was combined with new requirements, since replacing HCU with feature flag would also require refactoring work that was done. New Requirements (HCU vs Feature Flag)On Nov 5, we started discussing and exploring possibility of using feature flag to replace HCU requirement. On Nov 12, Bastian opened a draft PR 3678 to explore replacing HCU requirement with feature flag, as well as other worthwhile changes discussed since Nov 5. By Nov 15, most of the feedback for the new PR 3678 were already incorporated:
Many thanks to Cadence team for reviews and amazing work by Bastian 🙌 on these new PRs. Extra work and findings in this project should benefit other projects in the future that involve feature flags or on-the-fly migrations. |
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.
UPDATED Estimates (Nov. 2024)
Results based on full migration test run using Nov 1, 2024 mainnet state:
We can reduce payload count by ~28% (instead of being limited to ~24%) due to onflow/atree#429.
Full migration test run passed storage health check, diff-states, and used these:
feature/combine-domain-payloads
branch with master #3676DRAFT Estimates (Sept. 2024)
🔍 Initial 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: