-
Notifications
You must be signed in to change notification settings - Fork 4.5k
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
dont create new reader in recvMsg #940
dont create new reader in recvMsg #940
Conversation
Note: it is possible to do this with a smaller diff using https://godoc.org/bytes#Buffer.Reset |
@tamird as the underlying slice that's passed to bytes.NewReader is changed on every call to it, thanks but I'm actually having trouble seeing how that could work without first copying into the reset buffer, and then reading back out of it, and causing an extra copy. |
The issue here is not the copy of the slice, but the allocation of the |
ah I think I see, it was https://godoc.org/bytes#Reader.Reset rather than https://godoc.org/bytes#Buffer.Reset :), thanks! |
on second thought, IMO I'd actually lean towards keeping the current code. It's a minor detail, but the change ends up being the same size since we need to change initialization of recvBuffer, plus it's another object to allocate per stream, open to it though... |
Ah, yeah, that's the one :) On Fri, Oct 21, 2016 at 9:41 PM, apolcyn notifications@github.com wrote:
|
Why is it another object to allocate? You can make |
9bd2f6b
to
5d292f3
Compare
@tamird for the extra allocation, I was just thinking about the per-stream overhead, where the new latest updates use a |
Ack, thanks for updating.
…On Thu, Dec 22, 2016 at 7:11 PM, apolcyn ***@***.***> wrote:
@tamird <https://github.com/tamird> for the extra allocation, I was just
thinking about the per-stream overhead, where the new recvBufferReader is
created per stream. But as noted this can probably be avoided some other
way if it's necessary, and I don't have any evidence of it being a
potential issue in that case anyways...
latest updates use a Reader.Reset instead of copy functions, small detail
but used an extra null check instead of changing constructors.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#940 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/ABdsPJ7CqDELkO1gDQC99o_Atu-rSg2nks5rKxGmgaJpZM4KdqMy>
.
|
It's looking like the problem on Travis right now is due to |
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.
Looks good. Found and interesting blog reading up for this PR: https://blog.kowalczyk.info/article/d/Improving-speed-of-pure-Go-SMAZ-compressor-by-26.html
Re-running the tests since it's an old change. |
The tests are failing because the latest travis.yml changes aren't pulled in. Can you rebase, please? |
cffd5df
to
df3e202
Compare
Just squashed and rebased, hopefully fixed |
looking at the total memory allocated over the 30-second protobuf streaming benchmark period, we see that 15-16GB is allocated in total.
It seems simple to eliminate the 1GB of that within the
(*recvBufferReader).Read
method:The current functions that allocate significant amount are:
But
appears to be just from the frequent creation of a NewReader. If the stream has small messages, then that Reader should get created per data frame.
After this change, no significant amount is allocated in that function. see:
Benchmarks don't currently show any improvements beyond noise, but I think this should be more significant after #939