-
Notifications
You must be signed in to change notification settings - Fork 21.6k
trie: db insertions + leaf callback parallelism #20465
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
Conversation
|
I added a benchmark on fixed-size tries, to measure what the impact is on smaller tries. Before: The channel-based |
|
I've put this up on a full sync benchmark against master: https://geth-bench.ethdevops.io/d/Jpk-Be5Wk/dual-geth?orgId=1&var-exp=mon08&var-master=mon09&var-percentile=50&from=1576664098483&to=now |
|
After about 5 days of sync, the experimental is ahead with about |
|
Closing in favour of #20481 |




When we do
Commiton the trie when parents-of-leafs are encountered, we do two things:db.insert, which can be a fairly heavy operation, andonleaffunction for the leafs. This can also be somewhat heavy.This PR splits this up, so that we can have one dedicated goroutine which handles the insertion and callbacks, and the main trie-walker can concentrate on iterating the trie.
Since the order of events (inserts and callback invocation) is unchanged by this PR, I don't think this has any buggy side-effects.
Here are the benchmark results:
As can be expected, if there's an
onleaffunction provided, the gains are higher20%, compared to16%if there is noonleaf.The benchmarks are pretty synthetic, though, and I imagine that there is a lot more work done in the
insertsection on a live node.This PR should work pretty nicely even pre-byzantium, I'd guess.
The actual implementation can surely be cleaned up a bit, particularly the hack in
trie.gocould be made a bit more elegant.