-
Notifications
You must be signed in to change notification settings - Fork 148
Implement snapshots cache in aristo database #3760
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
| db.txRef = AristoTxRef(db: db, vTop: vTop, snapshot: Snapshot(level: Opt.some(0))) | ||
| db.accLeaves = LruCache[Hash32, AccLeafRef].init(ACC_LRU_SIZE) | ||
| db.stoLeaves = LruCache[Hash32, StoLeafRef].init(ACC_LRU_SIZE) | ||
| db.maxSnapshots = 10 |
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.
This can be made configurable if/when needed.
| # Checkpoint creates a snapshot of ancestor changes in txFrame - it is an | ||
| # expensive operation, specially when creating a new branch (ie when blk | ||
| # is being applied to a block that is currently not a head). | ||
| parentFrame.checkpoint(blk.header.number, skipSnapshot = false) |
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.
txFrame.checkpoint.. no?
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.
Yes should be txFrame.checkpoint. Will fix in my next PR.
| # Checkpoint creates a snapshot of ancestor changes in txFrame - it is an | ||
| # expensive operation, specially when creating a new branch (ie when blk | ||
| # is being applied to a block that is currently not a head). | ||
| parentFrame.checkpoint(blk.header.number, skipSnapshot = false) |
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.
..and here..
This PR adds a snapshots cache/queue to the aristo database instance.
The main purpose of this change is to support limiting the number of snapshots that can be created in total and also to support clearing out old data from snapshots just after persisting.
When we persist a txFrame to the database the base level increases but any snapshots that were not persisted may still have vertexes with a level lower than the base level. This stale data should be removed to further save memory and also prevent issues caused by reading stale data.
If we decided to go ahead with this idea then ideally it should be merged just after this PR: #3737