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/09/16 06:42:17 UTC

[GitHub] [pulsar] Jason918 commented on a diff in pull request #17663: [fix][client]Fix Producer exceeds PulsarClient memory limit when sending fail timeout using CompressionType.NONE

Jason918 commented on code in PR #17663:
URL: https://github.com/apache/pulsar/pull/17663#discussion_r972663811


##########
pulsar-common/src/main/java/org/apache/pulsar/common/compression/CompressionCodecNone.java:
##########
@@ -28,8 +29,15 @@ public class CompressionCodecNone implements CompressionCodec {
 
     @Override
     public ByteBuf encode(ByteBuf raw) {
-        // Provides an encoder that simply returns the same uncompressed buffer
-        return raw.retain();
+        int readableBytes = raw.readableBytes();
+        if (readableBytes == raw.capacity()) {
+            return raw.retain();
+        }
+        raw.markReaderIndex();
+        ByteBuf target = PulsarByteBufAllocator.DEFAULT.buffer(readableBytes, readableBytes);
+        target.writeBytes(raw);
+        raw.resetReaderIndex();
+        return target;

Review Comment:
   +1. 
   1. We should take the whole buffer size into account in `MemoryLimitController`. Because it's allocated by our producer.
   2. There is a memory waste problem in producer batch container, as the max buffer size only grows.



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