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

[R4R]prefetch state by applying the transactions within one block #704

Merged
merged 4 commits into from
Jan 11, 2022

Conversation

unclezoro
Copy link
Collaborator

@unclezoro unclezoro commented Jan 7, 2022

Description

By improving the snapshot clean cache hit rate, we can improve the capacity of BSC further.

Rationale

According to the test, the cache hitting rate on BSC is about 94%, while the miss 6% IO will cost 32% of execution time.

We try to preload the state from DB by applying the transactions in advance. It turns out the execution time was reduced by 30%-40%

image

Example

Verified on testnet and mainnet.

Changes

No impact to users

@unclezoro unclezoro changed the title [R4R]prefetch state by apply transactions within one block [R4R]prefetch state by applying transactions within one block Jan 10, 2022
@unclezoro unclezoro changed the title [R4R]prefetch state by applying transactions within one block [R4R]prefetch state by applying the transactions within one block Jan 10, 2022
core/blockchain.go Outdated Show resolved Hide resolved
@@ -35,42 +36,60 @@ type statePrefetcher struct {
engine consensus.Engine // Consensus engine used for block rewards
}

// newStatePrefetcher initialises a new statePrefetcher.
Copy link
Contributor

Choose a reason for hiding this comment

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

Should be NewStatePrefetcher

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

fixed

@unclezoro unclezoro merged commit c78ecfb into bnb-chain:develop Jan 11, 2022
unclezoro added a commit that referenced this pull request Feb 17, 2022
* prefetch state by apply transactions within one block

* resolve comments

* stop prefetch once process is done

* update comments

fix ut
keefel pushed a commit to keefel/bsc that referenced this pull request Jun 6, 2022
…b-chain#704)

* prefetch state by apply transactions within one block

* resolve comments

* stop prefetch once process is done

* update comments

fix ut
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants