-
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
Parallel hashing #20488
Parallel hashing #20488
Conversation
This is now up for a benchmark full sync: https://geth-bench.ethdevops.io/d/Jpk-Be5Wk/dual-geth?orgId=1&var-exp=mon08&var-master=mon09&var-percentile=50&from=1577792859000&to=now |
Some preliminary charts. So, this PR only does paralell hashing if the number of updates is 100 or more, so as you can see, it has basically no effect pre-byzantium (when we hash in between every tx). However, the effect post-byz is very visible: Here's a bit more zoom = this PR is pretty stable at about |
After 4 days (
|
After ~5 days, |
The other one (#20493) , running on |
trie/pure_hasher.go
Outdated
if h.parallel { | ||
var wg sync.WaitGroup | ||
wg.Add(16) | ||
for i := 0; i < 16; i++ { |
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.
You probably want to do runtime.NumCPU
or runtime.GOMAXPROCS
here instead of hard coding 16. Or maybe tke the minimum of the two. If I have only 4 cores available, I don't think running on 16 threads helps.
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.
Ah, you're hashing each child on a separate goroutine. Hmm, what if the first full node is not that dense. Though to be honest, it probably is the densest apart from attacker tries.
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.
Yeah, so this branches off at the topmost fullnode, which in all likelihood will be pretty well balanced and dense
trie/trie.go
Outdated
@@ -47,6 +48,10 @@ type LeafCallback func(leaf []byte, parent common.Hash) error | |||
type Trie struct { | |||
db *Database | |||
root node | |||
// Keep a rough track of the number of leafs to commit | |||
dirtyCount int |
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.
Might also add to the docs that the statedb deduplicates writes and only does a trie update when the data is actually pushed to the database, so this counter will actually be pretty precise.
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 will be pretty precise, but I'm increasing it for deletions aswell, so that will cause some skew
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 probably drop this field if it's not used (yet)
Let's do #20481 first, and once that one is 'done', I'll rebase this and fix the hasher-specific things |
When this was executed without the paralell hashing, this was the result:
With the addition of parallel hashing, the new results are, it hit |
On |
aa281e7
to
97c622c
Compare
97c622c
to
75d4f20
Compare
Rebased on top of master -- PTAL @karalabe |
75d4f20
to
0b66424
Compare
0b66424
to
5f0d62c
Compare
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.
SGTM
…#20488) * trie: make hasher parallel when number of changes are large * trie: remove unused field dirtyCount * trie: rename unhashedCount/unhashed
This is a follow-up to #20481 , which implements
The benchmarks below are against #20481
Here are the benchmarks against master:
Once the current benchmark run is done, I'll put this one up