-
Notifications
You must be signed in to change notification settings - Fork 15
Cleanup and refactor accountsdb index #419
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
9 files reviewed, no comments
Edit PR Review Bot Settings | Greptile
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Please link the migration script in the PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Can the migration script be run automatically on restart?
8fc7900
to
2bd3c68
Compare
* dev: Cleanup and refactor accountsdb index (#419) chore: create dev branch
Modify account layout in accounts database: 1. reuse slack space which is available in block allocation if possible, this avoids reallocation of accounts if the data field grows insignificantly. 2. track account owner change to avoid index checks in happy path depends on #419 closes #443 closes #441 <!-- greptile_comment --> ## Greptile Summary Major refactoring of AccountsDB storage and indexing system to optimize account data storage and improve performance through block space reuse and owner tracking. - Consolidated multiple LMDB environments into a single environment and introduced new `Table` abstraction in `magicblock-accounts-db/src/index/table.rs` for better database operation encapsulation - Modified account serialization in `magicblock-accounts-db/src/lib.rs` to reuse slack space in block allocations, reducing unnecessary reallocations for small data growth - Added owner change tracking to optimize index checks by skipping them in the happy path when owner hasn't changed - Improved LMDB iteration safety and efficiency in `magicblock-accounts-db/src/index/iterator.rs` by removing manual cursor management - Changed program account iteration behavior to return empty iterators instead of NotFound errors for better API consistency <!-- /greptile_comment -->
Main changes:
Due to the use of a single environment instead of previously used 3, this is a breaking change, which requires running a migration script to fix up the index directory.
Greptile Summary
Major refactoring of the AccountsDB index system to improve performance and code organization by consolidating database environments and optimizing LMDB operations.
magicblock-accounts-db/src/index.rs
Table
abstraction inmagicblock-accounts-db/src/index/table.rs
to encapsulate database operations cleanly