Reduce impact of backendRequests on latency#2530
Merged
joe-elliott merged 7 commits intografana:mainfrom Jun 2, 2023
Merged
Conversation
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
Signed-off-by: Joe Elliott <number101010@gmail.com>
mdisibio
reviewed
Jun 1, 2023
| reqs = append(reqs, subR) | ||
|
|
||
| select { | ||
| case reqCh <- &backendReqMsg{req: subR}: |
Contributor
There was a problem hiding this comment.
SearchSharderRoundTrip50000-8 318ms ± 4% 472ms ± 2% +48.65%
One thought on this is we could reduce the channel overhead by sending batched requests instead of individually. Looking at the code the easiest split is probably all jobs for a block in one channel send here.
Collaborator
Author
There was a problem hiding this comment.
Naive attempt was worse. before = this PR, after = this PR with batching as suggested:
name old time/op new time/op delta
SearchSharderRoundTrip5-8 659µs ± 1% 1108µs ±83% +68.15% (p=0.016 n=4+5)
SearchSharderRoundTrip500-8 12.2ms ± 4% 12.9ms ± 6% ~ (p=0.056 n=5+5)
SearchSharderRoundTrip50000-8 474ms ±11% 540ms ± 8% +13.91% (p=0.032 n=5+5)
name old alloc/op new alloc/op delta
SearchSharderRoundTrip5-8 451kB ± 0% 588kB ±54% +30.19% (p=0.008 n=5+5)
SearchSharderRoundTrip500-8 4.80MB ± 0% 4.96MB ± 0% +3.43% (p=0.008 n=5+5)
SearchSharderRoundTrip50000-8 176MB ± 0% 181MB ± 0% +3.03% (p=0.016 n=5+4)
name old allocs/op new allocs/op delta
SearchSharderRoundTrip5-8 1.33k ± 2% 2.98k ±133% +123.52% (p=0.008 n=5+5)
SearchSharderRoundTrip500-8 57.2k ± 0% 58.0k ± 0% +1.24% (p=0.008 n=5+5)
SearchSharderRoundTrip50000-8 2.26M ± 0% 2.28M ± 0% +0.88% (p=0.008 n=5+5)
I think the additional memory management offsets it. Personally, i'm not concerned about that +40%. Even in that case the overall performance is going to be significantly better b/c we're getting jobs to queriers faster.
That first benchmark SearchSharderRoundTrip5 is the most interesting b/c it roughly represents "time to first job" which is the real improvement here.
mdisibio
approved these changes
Jun 2, 2023
3 tasks
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.
What this PR does:
Uses a channel to return jobs instead of a returning them as a slice from backendRequests. This nicely improves performance for queries that create a huge number of jobs.
Other Changes
searchProgress.internalShouldQuit()where we needed 1 more than the limit to quittotalBlockBytesto be auint64throughoutBenchmarks:
Impact on exhaustive search with 100k jobs:

Which issue(s) this PR fixes:
Fixes #2469
Checklist
CHANGELOG.mdupdated - the order of entries should be[CHANGE],[FEATURE],[ENHANCEMENT],[BUGFIX]