-
Notifications
You must be signed in to change notification settings - Fork 86
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
ChainDB: pass new block to ledger validation #1398
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
mrBliss
added
consensus
issues related to ouroboros-consensus
optimisation
Performance optimisation
chain db
labels
Jan 6, 2020
mrBliss
force-pushed
the
mrBliss/pass-new-block-to-ledger-validation
branch
from
January 6, 2020 10:08
3739d62
to
3bed5e0
Compare
edsko
reviewed
Jan 23, 2020
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Discussed over meet. Let's introduce a BlockCache and take another look.
mrBliss
commented
Jan 23, 2020
ouroboros-consensus/src/Ouroboros/Storage/ChainDB/Impl/LgrDB.hs
Outdated
Show resolved
Hide resolved
ouroboros-consensus/src/Ouroboros/Storage/ChainDB/Impl/LgrDB.hs
Outdated
Show resolved
Hide resolved
mrBliss
force-pushed
the
mrBliss/pass-new-block-to-ledger-validation
branch
from
January 23, 2020 11:49
3bed5e0
to
a3d2ec4
Compare
mrBliss
force-pushed
the
mrBliss/pass-new-block-to-ledger-validation
branch
2 times, most recently
from
January 29, 2020 13:23
ae956ec
to
79018a0
Compare
edsko
approved these changes
Jan 29, 2020
mrBliss
force-pushed
the
mrBliss/pass-new-block-to-ledger-validation
branch
from
January 30, 2020 11:03
79018a0
to
1def1ad
Compare
In `ChainDB.addBlock`, we receive a new block and use it to try switch to a longer chain. This will require applying the block to the ledger, which requires reading the block from disk and parsing it again. This is right in the critical path of (bulk) chain sync. Since we have the block in memory, we can avoid the redundant read and pass it to the validation code directly in the form of a `BlockCache`. We can later use this cache for caching more/other blocks. Note that when switching to a fork or when we can extend the new chain with more blocks after the new block, we'll still have to read blocks from disk in order to validate them, but not the new block.
mrBliss
force-pushed
the
mrBliss/pass-new-block-to-ledger-validation
branch
from
January 30, 2020 11:15
1def1ad
to
ab17e61
Compare
bors r+ |
iohk-bors bot
added a commit
that referenced
this pull request
Jan 30, 2020
1398: ChainDB: pass new block to ledger validation r=mrBliss a=mrBliss In `ChainDB.addBlock`, we receive a new block and use it to try switch to a longer chain. This will require applying the block to the ledger, which requires reading the block from disk and parsing it again. This is right in the critical path of (bulk) chain sync. Since we have the block in memory, we can avoid the redundant read and pass it to the validation code directly. Note that when switching to a fork or when we can extend the new chain with more blocks after the new block, we'll still have to read blocks from disk in order to validate them, but not the new block. Co-authored-by: Thomas Winant <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
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.
In
ChainDB.addBlock
, we receive a new block and use it to try switch to a longer chain. This will require applying the block to the ledger, which requires reading the block from disk and parsing it again. This is right in the critical path of (bulk) chain sync.Since we have the block in memory, we can avoid the redundant read and pass it to the validation code directly.
Note that when switching to a fork or when we can extend the new chain with more blocks after the new block, we'll still have to read blocks from disk in order to validate them, but not the new block.