Rewrite delta to use only a single goroutine - #373
Merged
Merged
Conversation
julianbrost
force-pushed
the
feature/single-threaded-delta
branch
from
September 23, 2021 13:28
71fca86 to
6556197
Compare
lippserd
requested changes
Sep 23, 2021
| return <-delta.done | ||
| } | ||
|
|
||
| func checksumsMatch(a, b contracts.Entity) bool { |
Member
There was a problem hiding this comment.
I would move this function after Delta.run() so that private functions come after public ones and Delta methods stay together.
julianbrost
force-pushed
the
feature/single-threaded-delta
branch
from
September 24, 2021 09:35
6556197 to
2198cdb
Compare
lippserd
approved these changes
Sep 24, 2021
julianbrost
force-pushed
the
feature/single-threaded-delta
branch
from
September 24, 2021 09:52
2198cdb to
66d9b0e
Compare
Member
Author
|
Rebased due to merge conflict in |
lippserd
approved these changes
Sep 24, 2021
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
The current delta implementation uses two goroutines that read from their own channels but update shared maps all the time. Rewriting it to just use a single goroutine make almost no difference in wall clock time (seems to even be a little faster) but removes quite a lot of lock contention so that the total CPU time needed decreases quite a bit.
For the following test, I increased the limit in the benchmark (didn't want to commit this as that test needs about 12GB RAM).
Before
After
Comparison
(Don't give too much on the exact numbers, that was just a single run but it matches my general impression from multiple runs: there's no huge change but it tends to even be slightly faster.)
Also the CPU time (user+sys) went from 87.25s to 69.86s (-20 %), that's the main benefit of this PR.
refs #361 (Making delta single-threaded was originally part of that PR but now got moved here. There's a bit of history/context over there.)