You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/12/14 12:42:22 UTC
[GitHub] [pulsar] tongsucn opened a new pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
tongsucn opened a new pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293
Fixes #13285
### Motivation
See more in #13285
### Modifications
1. Replaced `std::vector<char>` with `std::string` as the internal storage of `SharedBuffer`.
2. Added new interface `MessageBuilder::setContent(std::string&&)`.
3. Added new move-constructors in `SharedBuffer`.
### Does this pull request potentially affect one of the following parts:
- Dependencies (does it add or upgrade a dependency): no
- The public API: no
- The schema: no
- The default values of configurations: no
- The wire protocol: no
- The rest endpoints: no
- The admin cli options: no
- Anything that affects deployment: no
### Documentation
Need to update docs?
Nope
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] tongsucn commented on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
tongsucn commented on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-995465472
> @tongsucn You should either rebase or merge with master as there were some merge conflicts that make the checkstyle to fail. It's already fixed in latest master.
@merlimat done
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] tongsucn commented on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
tongsucn commented on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-994737273
@codelipenghui Just added a test case on `MessageBuilder::setContent`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] github-actions[bot] commented on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-993532599
@tongsucn:Thanks for your contribution. For this PR, do we need to update docs?
(The [PR template contains info about doc](https://github.com/apache/pulsar/blob/master/.github/PULL_REQUEST_TEMPLATE.md#documentation), which helps others know more about the changes. Can you provide doc-related info in this and future PR descriptions? Thanks)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] github-actions[bot] commented on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-993647540
@tongsucn:Thanks for providing doc info!
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] BewareMyPower commented on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
BewareMyPower commented on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-994245553
I have a suggestion for testing the memory copy doesn't occur after this change, but it might depend on the implementation of `std::string`.
```c++
TEST(MessageBuilderTest, testSetContent) {
std::string value;
value.resize(1024, 'x');
const void* originalAddress = &value[0];
{
auto msg = MessageBuilder().setContent(value).build();
ASSERT_NE(msg.getData(), originalAddress);
}
{
auto msg = MessageBuilder().setContent(std::move(value)).build();
ASSERT_EQ(msg.getData(), originalAddress);
}
}
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] codelipenghui commented on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
codelipenghui commented on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-994456220
@tongsucn Any update on this PR?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] tongsucn edited a comment on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
tongsucn edited a comment on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-994254501
> `auto msg = MessageBuilder().setContent(value).build();`
@BewareMyPower I think the first `setContent` assertion should be fine. Because it internally allocates a same-sized `std::string` and calls `std::copy` explicitly, rather than using `std::string`'s copy constructor. Thanks bro
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] merlimat edited a comment on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
merlimat edited a comment on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-995371966
@tongsucn You should either rebase or merge with master as there were some merge conflicts that make the checkstyle to fail. It's already fixed in latest master.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] merlimat commented on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
merlimat commented on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-995371966
@tongsucn You either rebase or merge with master as there were some merge conflicts that make the checkstyle to fail. It's already fixed in latest master.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] tongsucn commented on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
tongsucn commented on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-994254501
> `auto msg = MessageBuilder().setContent(value).build();`
@BewareMyPower I think the first `setContent` assertion should be fine. Because it internally allocates a same-sized `std::string` and calls `std::copy` explicitly, rather than using `std::string`'s copy constructor.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] tongsucn commented on pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
tongsucn commented on pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293#issuecomment-994254870
> @tongsucn Can you also add a unit tests for the new `setContent()` method?
@merlimat OK, I'll add some tests today.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
[GitHub] [pulsar] merlimat merged pull request #13293: [Issue 13285][pulsar-client] Optimize MessageBuilder and SharedBuffer to avoid unnecessary memory copy.
Posted by GitBox <gi...@apache.org>.
merlimat merged pull request #13293:
URL: https://github.com/apache/pulsar/pull/13293
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org