Skip to content

Conversation

michaelsproul
Copy link
Member

Proposed Changes

Reduce the time taken to store hot states by introducing an in-memory cache for hot HDiffBuffers. This cache is attached to the state_cache and is simpler than the existing HDiffBuffer cache 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).

@michaelsproul michaelsproul requested a review from dapplion June 17, 2025 07:58
@michaelsproul michaelsproul added optimization Something to make Lighthouse run more efficiently. tree-states Ongoing state and database overhaul labels Jun 17, 2025
@michaelsproul michaelsproul merged commit cb81f07 into sigp:tree-states-hot-rebase Jun 19, 2025
31 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
optimization Something to make Lighthouse run more efficiently. tree-states Ongoing state and database overhaul
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant