anjy7 commented on code in PR #22669: URL: https://github.com/apache/kafka/pull/22669#discussion_r3572233909
########## raft/src/testFixtures/java/org/apache/kafka/raft/RaftClientBenchmarkContext.java: ########## @@ -0,0 +1,277 @@ +/* + * 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.raft; + +import org.apache.kafka.common.Uuid; +import org.apache.kafka.common.protocol.ApiKeys; +import org.apache.kafka.raft.RaftClientTestContext.RaftProtocol; +import org.apache.kafka.server.common.KRaftVersion; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Optional; +import java.util.concurrent.ThreadLocalRandom; +import java.util.stream.Collectors; +import java.util.stream.IntStream; + +public final class RaftClientBenchmarkContext { + // Standardized JMH iteration counts, shared by all raft benchmarks so every benchmark of a given + // mode is configured identically. + + // SingleShotTime measures a single operation per iteration, so it needs many iterations to build + // a stable distribution. + public static final int SINGLE_SHOT_WARMUP_ITERATIONS = 50; + public static final int SINGLE_SHOT_MEASUREMENT_ITERATIONS = 30; + public static final int SINGLE_SHOT_FORKS = 5; + + // AverageTime averages many operations within each timed iteration, so it needs fewer. + public static final int AVERAGE_TIME_WARMUP_ITERATIONS = 5; + public static final int AVERAGE_TIME_MEASUREMENT_ITERATIONS = 10; + public static final int AVERAGE_TIME_FORKS = 3; + + // Default to the newest version of each (the highest-ordinal enum constant). Enum natural order + // is ordinal order, so this picks the last-declared constant; relies on the constants being + // declared oldest-to-newest, which avoids updating these when a new version is added. + public static final KRaftVersion DEFAULT_KRAFT_VERSION = + Arrays.stream(KRaftVersion.values()).max(Comparator.naturalOrder()).orElseThrow(); Review Comment: Good call. I agree on using `KRaftVersion.LATEST_PRODUCTION` for this. -- 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: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
