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 2022/05/25 19:46:42 UTC

[GitHub] [pulsar] tjiuming commented on a diff in pull request #15033: [client-producer] avoid too large memory preallocation for batch message.

tjiuming commented on code in PR #15033:
URL: https://github.com/apache/pulsar/pull/15033#discussion_r882051495


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/BatchMessageContainerImpl.java:
##########
@@ -69,8 +69,7 @@ public boolean add(MessageImpl<?> msg, SendCallback callback) {
                 messageMetadata.setSequenceId(msg.getSequenceId());
                 lowestSequenceId = Commands.initBatchMessageMetadata(messageMetadata, msg.getMessageBuilder());
                 this.firstCallback = callback;
-                batchedMessageMetadataAndPayload = PulsarByteBufAllocator.DEFAULT
-                        .buffer(Math.min(maxBatchSize, ClientCnx.getMaxMessageSize()));
+                batchedMessageMetadataAndPayload = PulsarByteBufAllocator.DEFAULT.compositeBuffer();

Review Comment:
   Buffer expansions will happens in some situations, but for `CompositeByteBuf`, it wouldn't takes too much costs.
   `mem_copy` operations triggered when `CompositeByteBuf#consolidate0`, which means after write more than 1000000 bytes into buffer, `mem_copy` will be triggered first time by default. I believe it's acceptable in the `client side`



-- 
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