yuzawa-san commented on a change in pull request #9499: URL: https://github.com/apache/kafka/pull/9499#discussion_r512045768
########## File path: clients/src/main/java/org/apache/kafka/common/record/CompressionType.java ########## @@ -119,7 +119,9 @@ public InputStream wrapForInput(ByteBuffer inputBuffer, byte messageVersion, Buf @Override public OutputStream wrapForOutput(ByteBufferOutputStream buffer, byte messageVersion) { try { - return (OutputStream) ZstdConstructors.OUTPUT.invoke(buffer); + // Set input buffer (uncompressed) to 16 KB (none by default) to ensure reasonable performance + // in cases where the caller passes a small number of bytes to write (potentially a single byte) + return new BufferedOutputStream((OutputStream) ZstdConstructors.OUTPUT.invoke(buffer), 16 * 1024); Review comment: This should be safe. It is used already in this file to wrap the GZIPOutputStream which also does not buffer uncompressed data prior to compression. ---------------------------------------------------------------- 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. For queries about this service, please contact Infrastructure at: us...@infra.apache.org