Open
Conversation
Fixes apache#306 ### Motivation `OpSendMsg` is a struct whose size is 400 bytes. We should avoid the copy operation on it. ### Modifications Pass the `unique_ptr<OpSendMsg>` everywhere instead of `OpSendMsg`. - Use `unique_ptr<OpSendMsg>` as the element of the pending message queue in `ProducerImpl` and disable the copy constructor and assignment for `OpSendMsg`. - Add `SendArgument`, which includes the necessary fields to construct a `CommandSend` request. Use `shared_ptr` rather than `unique_ptr` to store `SendArgument` in `OpSendMsg` because the producer might need to resend the message so the `SendArgument` object could be shared by `ProducerImpl` and `ClientConnection`. This patch is more like a refactor because the compiler optimization might reduce unnecessary copying.
…ssage is added ### Motivation Currently, each time a message is added to the batch message container, `serializeSingleMessageInBatchWithPayload` will be called. In this method, if the payload buffer's size is not enough, it will grow twice. After batch is cleared, the payload buffer will be reset. For example, here is a typical buffer size increament during a period of a batch: ``` increase buffer size from 0 to 1033 increase buffer size from 1033 to 2066 increase buffer size from 2066 to 4132 increase buffer size from 3099 to 6198 increase buffer size from 5165 to 10330 increase buffer size from 9297 to 18594 increase buffer size from 17561 to 35122 increase buffer size from 34089 to 68178 increase buffer size from 67145 to 134290 ``` ### Modifications Refactor the `MessageAndCallbackBatch` design, in `add` method, only store the message and callback. Provide a `createOpSendMsg` method to serialize the messages and callbacks into a `OpSendMsg`.
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.
No description provided.