[GitHub] [kafka] chia7712 commented on a change in pull request #9223: KAFKA-10438 Lazy initialization of record header to reduce memory usa…
chia7712 commented on a change in pull request #9223: URL: https://github.com/apache/kafka/pull/9223#discussion_r491040089 ## File path: jmh-benchmarks/src/main/java/org/apache/kafka/jmh/record/RecordBatchBenchmarkSuite.java ## @@ -0,0 +1,149 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + *http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.kafka.jmh.record; + +import kafka.server.BrokerTopicStats; +import org.apache.kafka.common.header.Header; +import org.apache.kafka.common.record.AbstractRecords; +import org.apache.kafka.common.record.BufferSupplier; +import org.apache.kafka.common.record.CompressionType; +import org.apache.kafka.common.record.MemoryRecords; +import org.apache.kafka.common.record.MemoryRecordsBuilder; +import org.apache.kafka.common.record.Record; +import org.apache.kafka.common.record.RecordBatch; +import org.apache.kafka.common.record.TimestampType; +import org.openjdk.jmh.annotations.Param; +import org.openjdk.jmh.annotations.Scope; +import org.openjdk.jmh.annotations.Setup; +import org.openjdk.jmh.annotations.State; + +import java.nio.ByteBuffer; +import java.util.Arrays; +import java.util.Random; +import java.util.stream.IntStream; + +import static org.apache.kafka.common.record.RecordBatch.CURRENT_MAGIC_VALUE; + +@State(Scope.Benchmark) +public abstract class RecordBatchBenchmarkSuite { Review comment: done 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
[GitHub] [kafka] chia7712 commented on a change in pull request #9223: KAFKA-10438 Lazy initialization of record header to reduce memory usa…
chia7712 commented on a change in pull request #9223: URL: https://github.com/apache/kafka/pull/9223#discussion_r485761001 ## File path: jmh-benchmarks/src/main/java/org/apache/kafka/jmh/record/RecordBatchIterationBenchmark.java ## @@ -142,15 +169,15 @@ private ByteBuffer createBatch(int batchSize) { break; } -builder.append(0, null, value); +builder.append(0, null, value, headers); } return builder.build().buffer(); } @Benchmark public void measureValidation(Blackhole bh) throws IOException { MemoryRecords records = MemoryRecords.readableRecords(singleBatchBuffer.duplicate()); -LogValidator.validateMessagesAndAssignOffsetsCompressed(records, new TopicPartition("a", 0), +LogValidator.validateMessagesAndAssignOffsets(records, new TopicPartition("a", 0), Review comment: > it would be better to have another benchmark for the uncompressed case. I creates two new classes - ```CompressedRecordBatchValidationBenchmark``` and ```UncompressedRecordBatchValidationBenchmark```. They use different compression type and measure different validation function. 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
[GitHub] [kafka] chia7712 commented on a change in pull request #9223: KAFKA-10438 Lazy initialization of record header to reduce memory usa…
chia7712 commented on a change in pull request #9223: URL: https://github.com/apache/kafka/pull/9223#discussion_r48574 ## File path: jmh-benchmarks/src/main/java/org/apache/kafka/jmh/record/RecordBatchIterationBenchmark.java ## @@ -142,15 +169,15 @@ private ByteBuffer createBatch(int batchSize) { break; } -builder.append(0, null, value); +builder.append(0, null, value, headers); } return builder.build().buffer(); } @Benchmark public void measureValidation(Blackhole bh) throws IOException { MemoryRecords records = MemoryRecords.readableRecords(singleBatchBuffer.duplicate()); -LogValidator.validateMessagesAndAssignOffsetsCompressed(records, new TopicPartition("a", 0), +LogValidator.validateMessagesAndAssignOffsets(records, new TopicPartition("a", 0), Review comment: > Why did we change this? run JMH with uncompressed data. The alternative way is that we can add an new benchmark for ```assignOffsetsNonCompressed```. However, the test data of this class includes both uncompressed and compressed so it is weird to input compressed data to test ```assignOffsetsNonCompressed```. 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
[GitHub] [kafka] chia7712 commented on a change in pull request #9223: KAFKA-10438 Lazy initialization of record header to reduce memory usa…
chia7712 commented on a change in pull request #9223: URL: https://github.com/apache/kafka/pull/9223#discussion_r479750019 ## File path: clients/src/test/java/org/apache/kafka/common/record/DefaultRecordTest.java ## @@ -270,7 +270,7 @@ public void testInvalidNumHeadersPartial() throws IOException { DefaultRecord.readPartiallyFrom(inputStream, skipArray, 0L, 0L, RecordBatch.NO_SEQUENCE, null); } -@Test(expected = StringIndexOutOfBoundsException.class) +@Test(expected = InvalidRecordException.class) Review comment: The exception is caused by ```headerKeyBuffer.limit(headerKeySize);```. The new limit is larger than capacity 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