-
Notifications
You must be signed in to change notification settings - Fork 816
In Distribtor, pre-allocate buffer for reading protobufs #1719
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
Conversation
ReadAll() will start at 512 bytes then successively double the buffer, copying the contents each time. If the caller supplies a size we can be much more efficient. Signed-off-by: Bryan Boreham <[email protected]>
+1 Do we have a benchmark that shows an improvement? |
Nope, no benchmark. In my prod distributors this |
This is the compressed data - if we could use a pool of buffers for the uncompressed bytes, that would be much bigger impact, but I'm not sure whether |
also +1 on this. |
Signed-off-by: Bryan Boreham <[email protected]>
And extend the test to check it fires. Signed-off-by: Bryan Boreham <[email protected]>
3703686
to
99fd4d3
Compare
I added a size limit. |
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.
LGTM
@@ -125,6 +125,7 @@ type Config struct { | |||
|
|||
HATrackerConfig HATrackerConfig `yaml:"ha_tracker,omitempty"` | |||
|
|||
MaxRecvMsgSize int `yaml:"max_send_msg_size"` |
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.
The yaml here is max_send_msg_size
, while the CLI flag is max-recv-msg-size
. Isn't contradictory?
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.
Good catch, could you open a PR/issue so that we don't lose track of this?
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.
Sure: #1755
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.
oops, sorry!
ReadAll() will start at 512 bytes then successively double the buffer, copying the contents each time. If the caller supplies a size we can be much more efficient. It's not a massive win, but every little helps.
(However, doing this creates a new DoS vector - supplying an fake size that is way too big. I'm thinking we should have a max input size, similar to gRPC)