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.
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
Improve withdrawals processing performance #5026
Improve withdrawals processing performance #5026
Changes from 3 commits
6ab849c
f05d666
ea3c23a
4c53b43
d81efc6
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
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.
nitpick: if we flip the condition and return early, we might avoid the indentions. i.e.
if (updatedAccount.getUpdatedStorage.isEmpty() {return;}
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.
It's not clear to me why this improves withdrawals performance, can you please explain?
Also, it seems to be a change that will affect things other than withdrawals, so wondering what has been done to ensure we haven't regressed anything else? Would this be covered by existing automated tests or have you performed some relevant manual tests?
Finally, it's bonsai specific - what if we process withdrawals with FOREST?
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.
This looks like different optimisation from the one mentioned initially. I thought the optimization was to avoid the cost of the parallel streams overhead. This looks like it avoids doing unnecessary work if there is no storage to update. Which is a good thing though.
Are you planning to add an optimization to avoid the parallel stream for withdrawal balance 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.
@siladu You're right, the PR description is not detailed enough. During block processing, we have 3 big consumers in terms of time processing : Transactions execution, commit the changes of each transaction to the worldstate updater and persist all the changes (in memory or on disk). During withdrawals processing, we also commit the changes of all the withdrawals to a worldstate updater but we use the same method (commit) that is used to manage all the cases (accounts deletion, storage update, storage deletion, ..etc). In the case of withdrawals, we only modify the balances, so we should just focus on accounts updates.
@jframe good point, you're totally right. I wanted to start with this first optimisation to see if it is sufficient, and avoid creating another specific method for withdrawals to keep the code simple.
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.
I added the flamegraphs at the block processing level in the description to better see that withdrawals processing doesn't appear as it takes less time than before
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.
Regarding FOREST, I couldn't get more insights from the profiling as it couldn't capture anything (after my last modification). It could be interesting to do the same work with lots of transactions to see the real impact. Currently, block processing with withdrawals takes less than 2 ms, that's why it is hard to get samples on Block processing. Async Profiler, the tool I'm using, has a default frequency of 100 Hz (1 sample every 10 ms).