AnonHxy commented on code in PR #17854:
URL: https://github.com/apache/pulsar/pull/17854#discussion_r981918432


##########
pulsar-client/src/main/java/org/apache/pulsar/client/impl/AbstractBatchMessageContainer.java:
##########
@@ -46,6 +47,8 @@ public abstract class AbstractBatchMessageContainer 
implements BatchMessageConta
     protected long currentTxnidLeastBits = -1L;
 
     protected static final int INITIAL_BATCH_BUFFER_SIZE = 1024;
+    protected static final int SHRINK_COOLING_OFF_PERIOD = 10;
+    protected int consecutiveShrinkTime = 0;

Review Comment:
   OK, private fields looks better for `allocator` is private 



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

Review Comment:
   This changing is just revert the pr 
https://github.com/apache/pulsar/pull/15033.  PR#15033 is also try to solve the 
memory waste problem but bring a significant performance regression @tisonkun 



-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to