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
VKT: Optimizations #147
VKT: Optimizations #147
Changes from 4 commits
0fedef4
45dd248
10d1f47
e889d40
fa84a2e
e5e29aa
d3f3017
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.
Here we have the benchmarks from #146.
I only removed the statelessness one as we discussed, so we avoid test flags.
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.
First optimization is avoiding work if
treeIndex
is zero, which makes sense and is a pretty normal case.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.
Lint.
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.
Looking further at where the wall-clock time was going, I realized that after
Commit()
ing the underlyinggo-verkle
trie, a significant amount of time was spent flushing the result.What I did in ethereum/go-verkle#314, is making
Flush()
for the root node to do the work in parallel. This means thatresolver
will be called by multiple goroutines balancing more CPU work in all available cores.To squeeze things more, the
Serialize()
part of the process was now moved from L258 to theresolver
. This means that theSerialize()
work will also be done in the goroutines that are flushing the result, and not in a single core.In a nutshell, since the resolver execution is exploiting all cores, we want to do as much work as possible there, so the main goroutine ranging L269 is receiving plain results to be stored in the
diskdb
. This main goroutine isn't doing heavy CPU work, just receiving exactly what needs to be stored.This is important, since if the
range
in L269 is slow, it will slow down everything. Note how I also made a buffered channel in L246. We need to avoid as much as possible to be blocking goroutines, so having extra breathing room also improved performance.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.
So if #295 gets merged,
Serialize
will become a tad more expensive - at the cost of a cheaper deserialization (hence not producing a tree that is crash-prone because of potentially invalid commitments, as in your current approach). Your change, I believe, will mitigate this problem and make it cheaper to follow this approach. That's very nice.