divijvaidya commented on code in PR #13312: URL: https://github.com/apache/kafka/pull/13312#discussion_r1157177692
########## clients/src/main/java/org/apache/kafka/common/utils/ByteUtils.java: ########## @@ -227,17 +259,62 @@ public static int readVarint(DataInput in) throws IOException { * @throws IOException if {@link DataInput} throws {@link IOException} */ public static long readVarlong(DataInput in) throws IOException { - long value = 0L; - int i = 0; - long b; - while (((b = in.readByte()) & 0x80) != 0) { - value |= (b & 0x7f) << i; - i += 7; - if (i > 63) - throw illegalVarlongException(value); + long raw = readUnsignedVarlong(in); + return (raw >>> 1) ^ -(raw & 1); + } + + private static long readUnsignedVarlong(DataInput in) throws IOException { + byte tmp = in.readByte(); Review Comment: Good idea. I have added the benchmark for different sizes of varInt and varLong as per your recommendation. -- 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-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org