Skip to content

Conversation

bhartnett
Copy link
Contributor

@bhartnett bhartnett commented Oct 10, 2025

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

@bhartnett bhartnett changed the title Implement snapshots queue in aristo database Implement snapshots cache in aristo database Oct 10, 2025
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
Copy link
Contributor Author

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.

@bhartnett bhartnett requested a review from arnetheduck October 10, 2025 07:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant