pre_validate_blocks_multiprocessing
Warm up the cache once per batch
#18484
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.
Purpose:
This is a small improvement towards a more efficient long sync.
The section this patch moves makes sure the block record cache contains sufficient blocks going back from the current block.
Currently we do this inside the loop over the blocks in the batch, which is unnecessary. The batch is expected to be contiguous anyway, so warming up the cache once outside the loop is sufficient.
This offers a small speed-up and slight simplification to
pre_validate_blocks_multiprocessing()
. Although, this code should ideally be moved to where we start a long sync (or maybe even a deep reorg). The code was only added to address issues in deep reorgs, where the cache may be cold.The sync rate goes from ~24 blocks/second to ~28 blocks/second. A speedup of ~ 1.16
This commit is probably best reviewed with whitespaces ignored, as it changes the indentation level for the code in question.
Current Behavior:
Warm up the cache for every block.
New Behavior:
Warm up the cache once, for the first block.
Testing Notes:
Sync test here.