You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "ijuma (via GitHub)" <gi...@apache.org> on 2023/02/13 05:42:30 UTC

[GitHub] [kafka] ijuma commented on a diff in pull request #13162: fix: replace an inefficient loop in kafka internals

ijuma commented on code in PR #13162:
URL: https://github.com/apache/kafka/pull/13162#discussion_r1104017807


##########
clients/src/main/java/org/apache/kafka/common/utils/Utils.java:
##########
@@ -1225,13 +1226,11 @@ public static long tryWriteTo(TransferableChannel destChannel,
      * @param length The number of bytes to write
      * @throws IOException For any errors writing to the output
      */
-    public static void writeTo(DataOutput out, ByteBuffer buffer, int length) throws IOException {
+    public static void writeTo(DataOutputStream out, ByteBuffer buffer, int length) throws IOException {
         if (buffer.hasArray()) {
             out.write(buffer.array(), buffer.position() + buffer.arrayOffset(), length);
         } else {
-            int pos = buffer.position();
-            for (int i = pos; i < length + pos; i++)
-                out.writeByte(buffer.get(i));
+            Channels.newChannel(out).write(buffer);

Review Comment:
   Thanks for the PR. Can you please provide a bit more detail regarding the workload? I assume we're talking about the producer here. If so, can you please share whether compression was used, the compression algorithm (if applicable) and the average message size.



-- 
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: jira-unsubscribe@kafka.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org