Skip to content

Conversation

@BewareMyPower
Copy link
Owner

No description provided.

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`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants