-
Notifications
You must be signed in to change notification settings - Fork 65
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
execution: fix OOM crash due to db::Buffer::accounts realloc (#2064) #2081
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
battlmonstr
force-pushed
the
pr/crashdbg
branch
6 times, most recently
from
June 12, 2024 14:40
72e14b7
to
0078f27
Compare
canepat
reviewed
Jun 14, 2024
[[nodiscard]] ValidationResult execute_block(std::vector<Receipt>& receipts) noexcept; | ||
|
||
//! \brief Flush IntraBlockState into cumulative State. | ||
void flush_state(); |
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.
We should change this to something like:
[[nodiscard]] FlushingResult flush_state() noexcept;
in order to:
- make
ExecutionProcessor
exception-free again - do not rely on
db::Buffer::MemoryLimitError
exception to handle an expected condition i.e. batch full
canepat
approved these changes
Jun 14, 2024
canepat
added
the
maintenance
Some maintenance work (fix, refactor, rename, test...)
label
Jun 14, 2024
Closes #2064 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The flat_hash_map has a policy (in
rehash_and_grow_if_necessary()
) to grow 2x when its size reaches 25/32 (78%) of capacity.Previously the batch execution logic was adding things to db::Buffer, and then testing if its size becomes bigger than batch_size. This lead to significant overshooting, because at the growth threshold it will double the memory size and make it batch_size * 2 (even more, because there's also unused 22% of capacity).
In standalone silkworm execution stage the batch_size estimation was based on a gas-based heuristic formula, which lead to significant underestimation and an OOM crash when trying to allocate 4 Gb of RAM at once.
This changes the logic from checking batch_size aposteriori to apriori. If there's a possibility to grow the buffer significantly and overshoot the limit, we shouldn't take the risk, and commit the batch.
Additional changes: