Skip to content

Conversation

bhartnett
Copy link
Contributor

@bhartnett bhartnett commented Oct 2, 2025

This PR removes the snapshots cache from the forked chain. My reasoning for removing it is mainly due to the fact that when we create a snapshot on a txFrame if there is an existing snapshot on any parent frame then it will be moved to the new frame. This means that parent snapshots will be removed once processing the next block and so I believe the logic in the updateSnapshot function was flawed because it cleans up old snapshots which usually would have already been moved.

When processing multiple branches/heads at once it is more likely that the clearSnapshot function will actually remove a snapshot but in that case we might be clearing a needed snapshot. When processing blocks on a longer chain the snapshots from the shorter chains are more likely to get cleaned up.

If we just snapshot each block without using the snapshot cache then each of the branch heads will hold one snapshot and so if we are processing 3 branches in parallel then we will only have 3 snapshots in memory. This is simpler and doesn't risk clearing snapshots that are actually needed.

The downside of doing this change is the potential for increased memory usage if and only if we somehow need to process a large amount of branches in parallel (more than 10 for example)

@bhartnett bhartnett requested a review from arnetheduck October 2, 2025 05:50
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