MINOR: Reduce sends created by SendBuilder#9619
Merged
hachikuji merged 4 commits intoapache:trunkfrom Nov 19, 2020
Merged
Conversation
Contributor
Author
chia7712
approved these changes
Nov 19, 2020
Member
chia7712
left a comment
There was a problem hiding this comment.
@hachikuji +1 to this improvement.
just curious. Why the "big" latency can be made without this improvement. I run the perf on my machine and can't get such big different latency. Is MultiRecordsSend a bad pattern to our code?
Contributor
Author
|
@chia7712 To be honest, I'm not sure. I think it makes sense in general to try and batch the writes together to reduce number of calls to the kernel in any case, but I am not sure why it has such a big impact locally. I also didn't see anything like this when I was testing in on linux, but I didn't feel great about the difference anyway. |
Member
|
+1 to last commit |
dajac
approved these changes
Nov 19, 2020
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.
In #9401, I observed some strange latency behavior when testing locally (on macos). The behavior seemed to be caused by slightly different write behavior as a result of the new
SendBuilderclass. After the change, we were making several calls down to bothGatheringByteChannel.write(ByteBuffer[])as well asWritableByteChannel.write(ByteBuffer)whereas previously there would be just one path through the former. The difference is clearly seen in the flame graphs posted here: #9401 (comment).This patch changes the grouping of
Sendobjects created bySendBuilderto try and restore the previous write behavior. Rather than creating a singleByteBufferSendfor eachByteBuffer, we attempt to group consecutive buffers into a singleByteBufferSend. I confirmed that did indeed address the latency issue I observed using the same test setup with a single broker that was discussed in #9401.Here are the results:
Committer Checklist (excluded from commit message)