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] state verification pipeline #795

Merged

Conversation

forcodedancing
Copy link
Contributor

@forcodedancing forcodedancing commented Mar 14, 2022

Description

Improve the performance of block importing by pipelining state verification, which consumes a big portion of time of block importing.

Rationale

In the previous release, the pipecommit feature is well implemented. Following the pipecommit feature, the pr tries to further pipeline state verification, by moving AccountsIntermediateRoot from ValidateState function to Commit function.

Workflow

svp_workflow

  1. Commit Snapshot will not wait for AccountsIntermediateRoot (thereby the new snapshot data is not correct)
  2. Before Commit Snapshot, needed accounts will be populated
  3. After AccountsIntermediateRoot, the snapshot generated will be corrected

Performance

Instances with 8 cores, 64G memory, 2.5T SSD (S1 vs S3)

Importing Time (0.75 quantile)

Before SVP
image
After SVP (S1 is using SVP)
image

State Verification Percentage

S3
image
S1 (S1 is using SVP)
image

Instances with 16 cores, 64G memory, 7.5T NVME (155 vs 118)

Importing Time (0.75 quantile)

Before SVP
image
After SVP (155 is using SVP)
image

State Verification Percentage

118
image
115 (155 is using SVP)
image

In general, the performance improvement effect is different on different instance types and different transaction volumes; if there is more time spent on state verification, then the improvement will be more obvious.

Changes

Notable changes:

  • ValidateState, Commit function are changed to support state verification pipeline

core/state/statedb.go Outdated Show resolved Hide resolved
core/blockchain.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
@bnb-chain bnb-chain deleted a comment from realuncle Mar 16, 2022
core/state/statedb.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
core/state/statedb.go Outdated Show resolved Hide resolved
@unclezoro unclezoro changed the title [WIP] state verification pipeline [R4R] state verification pipeline Mar 24, 2022
core/block_validator.go Outdated Show resolved Hide resolved
Copy link
Contributor

@setunapo setunapo left a comment

Choose a reason for hiding this comment

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

LGTM

core/state/statedb.go Outdated Show resolved Hide resolved
@unclezoro
Copy link
Collaborator

Let us use a special hash instead of emptyRoot.

@unclezoro unclezoro merged commit 90dc3d2 into bnb-chain:develop Mar 28, 2022
unclezoro pushed a commit that referenced this pull request Mar 29, 2022
* pipeline state verification

* update codes and add logs for debug

* refactor

* update and add logs

* refactor

* refactor

* remove unneeded logs

* fix a blocking issue

* fix sync issue when force kill

* remove logs

* refactor based on comments

* refactor based on comments

* refactor based on comments

* refactor based on comments

* refactor based on comments

* fix a deadlock issue

* fix merkle root mismatch issue during sync

* refactor based on review comments

* remove unnecessary code

* remove unnecessary code

* refactor based on review comments

* change based on comments

* refactor

* uew dummyRoot to replace emptyRoot

* add nil check

* add comments

* remove unneeded codes

* format comments

Co-authored-by: forcodedancing <[email protected]>
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.

6 participants