Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pre_validate_blocks_multiprocessing Warm up the cache once per batch #18484

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

arvidn
Copy link
Contributor

@arvidn arvidn commented Aug 18, 2024

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.

@arvidn arvidn added the Changed Required label for PR that categorizes merge commit message as "Changed" for changelog label Aug 18, 2024
@arvidn arvidn marked this pull request as ready for review August 18, 2024 10:41
@arvidn arvidn requested a review from a team as a code owner August 18, 2024 10:41
@arvidn arvidn requested a review from almogdepaz August 18, 2024 10:41
Copy link

Pull Request Test Coverage Report for Build 10439213317

Details

  • 13 of 13 (100.0%) changed or added relevant lines in 1 file are covered.
  • 34 unchanged lines in 11 files lost coverage.
  • Overall coverage increased (+0.01%) to 90.866%

Files with Coverage Reduction New Missed Lines %
chia/daemon/keychain_proxy.py 1 73.03%
chia/rpc/rpc_server.py 1 88.82%
chia/farmer/farmer.py 1 73.79%
chia/_tests/core/full_node/test_transactions.py 1 99.14%
chia/wallet/util/wallet_sync_utils.py 1 86.54%
chia/server/node_discovery.py 1 79.43%
chia/full_node/full_node.py 2 85.85%
chia/daemon/client.py 2 73.33%
chia/full_node/full_node_api.py 5 82.49%
chia/wallet/wallet_node.py 7 88.51%
Totals Coverage Status
Change from base Build 10423078207: 0.01%
Covered Lines: 101335
Relevant Lines: 111501

💛 - Coveralls

@arvidn arvidn requested a review from wjblanke August 20, 2024 09:00
Copy link
Contributor

@wjblanke wjblanke left a comment

Choose a reason for hiding this comment

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

aok

@arvidn arvidn added the ready_to_merge Submitter and reviewers think this is ready label Aug 21, 2024
@pmaslana pmaslana merged commit 387c70a into main Aug 21, 2024
375 of 376 checks passed
@pmaslana pmaslana deleted the minor-optimization-to-pre-validate branch August 21, 2024 18:05
@altendky altendky mentioned this pull request Sep 3, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Changed Required label for PR that categorizes merge commit message as "Changed" for changelog ready_to_merge Submitter and reviewers think this is ready
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants