-
Notifications
You must be signed in to change notification settings - Fork 20.2k
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
core/state/snapshot: replace diffToDisk ideal batch size with 64MB #27977
core/state/snapshot: replace diffToDisk ideal batch size with 64MB #27977
Conversation
Unfortunately, this will be problematic. In Ethereum, it's possible some contracts will be deleted, and the associated storage should be deleted from the snapshot. However, these contracts can be unbound and might result in out-of-memory(theoretically possible to build such contract, but have the cost to fulfill the slots though). Therefore, we split the big write into several small ones. |
These checks were added because they were needed, see #22582 for more details, and also #22497 (comment) for some history:
|
Thanks for the context! I was under the mistaken impression that this change was made as a performance optimization as opposed to avoid an OOM. |
As an alternative to avoid snapshot corruption. Applying the diff from the same block should be an idempotent operation. Would you be open to a PR that:
I understand that this may break some abstractions, so curious whether you'd be open to this idea, think it would be too gross to add, or even if snapshot corruption is not much of a concern in your view. |
Can't we have a middle ground? The IdealBatchSize is something like 100KB. That will trigger on a lot of contracts. But if we cap it at some significantly higher number (something reasonable in comparison with the max allowed deletion), then it should be fine almost always, except if you nuke your node exactly when it's deleting something larger? |
I guess there's no max allowed deletion in the snapshots. Still, could we special case this and cap it at a significantly higher number instead of 100KB? Say 64MB-256MB? |
Should be fine; IMO rather 64 than 256 |
// Ensure we don't delete too much data blindly (contract can be | ||
// huge). It's ok to flush, the root will go missing in case of a | ||
// crash and we'll detect and regenerate the snapshot. | ||
if batch.ValueSize() > ethdb.IdealBatchSize { |
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.
Can we keep the code for now and replace ethdb.IdealBatchSize
with 64 * 1024 * 1024
in both invocations? When removing SELFDESTRUCT lands in Cancun, we can nuke it out according to the original PR. In between we'd at least have a more robust code.
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.
Just updated during only those two invocations.
9b3dd18
to
dacb3fa
Compare
dacb3fa
to
87ffce8
Compare
… 64MB (ethereum#27977)" This reverts commit 1f2bb01.
… 64MB (ethereum#27977)" This reverts commit 1f2bb01.
This PR updates
diffToDisk(...)
within snapshot flattening to write the entire diff to disk in a single batch.Writing the diff to disk across multiple batches leads to the possibility that the snapshot will be corrupted during an ungraceful shutdown and can cause degraded performance during snapshot re-generation on startup.