Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Proposed Changes
Reduce the time taken to store hot states by introducing an in-memory cache for hot
HDiffBuffers. This cache is attached to thestate_cacheand is simpler than the existingHDiffBuffercache we have for the cold DB.We are able to take advantage of the fact that the hot DB requires very few hdiff buffers in normal operation: just one per layer required to access the finalized state (total 7).
The memory requirement for this single buffer is 438 MB on Holesky. Presently there is no way to turn off the cache, although we could consider adding this if we want a way to avoid this 438 MB entirely. I suspect the DB cache and associated reads will use a similar amount of memory, if not more.
For users wishing to minimise IO at the cost of more memory, the cache size can be increased to 8 (or higher). In practice the cache seems to hold around 4 entries when allowed to grow, for a total size of 1.68GB on Holesky (around 440 MB per buffer).