Skip to content

Conversation

rjl493456442
Copy link
Member

@rjl493456442 rjl493456442 commented Oct 11, 2025

The state history indexer configuration is introduced in this PR, primarily to allow
setting different index block capacities for different types of history data.

Notably, the index block capacity for existing state history has been reduced from
4K to 2K. This change aims to prevent the worst case where all mutated state entries
must update an almost full index block, causing significant write amplification and
potentially triggering a panic due to Pebble 4 GB batch size limitation.

This parameter adjustment remains backward compatible with the existing index data.


What's more, the database batch for writing the index data is now pre-allocated.
It's observed that database batch repeatedly grows the size of the mega-batch,
causing significant memory allocation pressure. This approach can effectively
mitigate the overhead.

if !last.full() {
delete(r.readers, last.id)
}
delete(r.readers, last.id)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In theory, if the last resolved reader is full, it's unnecessary to reload it for refreshing.

In practice, it's very rare that the last reader is full. In order to avoid passing the block capacity from the top down to the indexReader only for this purpose, this condition is removed.

The correctness shouldn't be affected.

indexBlockRestartLen = 256 // The restart interval length of index block
historyIndexBatch = 1_000_000 // The number of state history indexes for constructing or deleting as batch
indexBlockDescSize = 14 // The size of index block descriptor
indexBlockRestartLen = 256 // The restart interval length of index block
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

While in theory, the restart size can also be configured, it's not moved into the config in this pull request yet

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants