-
Notifications
You must be signed in to change notification settings - Fork 521
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
EVM-660 Use batch write inside blockchain.go (LevelDB/memory) #1569
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
It would be probably interesting to implement some benchmark tests and see how much gain we get by using batch updates. |
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.
Except from the small comments, looks good.
…s are updated only after successful batch writeBatch
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.
LGTM this should bring great improvement.
Description
WriteFullBlock
and other methods ofBlockchain
structure wrote each part of the block separately. However, with the changes introduced in this PR, everything is written together as a single batch. This can improve performance and efficiency when writing dataKeyValueStorage
is focused on read operations only + it provides a method [func (s *KeyValueStorage) NewBatch() Batch
] to create a concrete implementation of a Batch (memory or LevelDB)BatchWriter,
which holds the concreteBatch
interface implementation. It contains methods such asPutHeadHash
orPutHeadNumber
etc that are putting desired changes into a batch queue. However, these methods do not immediately change the storage. The changes are only saved to the actual database or memory when theWriteBatch
method is called.LevelDB options that are changed:
LevelDB options are set to the same values that go-ethereum uses.
Changes include
Breaking changes
Please complete this section if any breaking changes have been made, otherwise delete it
Checklist
Testing
Manual tests
Please complete this section if you ran manual tests for this functionality, otherwise delete it
Documentation update
Please link the documentation update PR in this section if it's present, otherwise delete it
Additional comments
Please post additional comments in this section if you have them, otherwise delete it