chia7712 commented on code in PR #22326:
URL: https://github.com/apache/kafka/pull/22326#discussion_r3599345781
##########
tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:
##########
@@ -623,6 +678,20 @@ public ConfigPostProcessor(ArgumentParser parser, String[]
args) throws IOExcept
if (reportingInterval <= 0) {
throw new ArgumentParserException("--reporting-interval should
be greater than zero.", parser);
}
+ this.recordKeyRange = namespace.getInt("recordKeyRange");
+ if (recordKeyRange != null && recordKeyRange <= 0) {
Review Comment:
Using `0` let us test a single key for all records, right?
##########
tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:
##########
@@ -167,6 +177,17 @@ KafkaProducer<byte[], byte[]>
createKafkaProducer(Properties props) {
Stats stats;
Stats steadyStateStats;
+ static byte[] generateKey(KeyDistribution keyDistribution, Integer
keyRange, long recordIndex, SplittableRandom random) {
+ switch (keyDistribution) {
Review Comment:
```java
return switch (keyDistribution) {
case RANGE -> Integer.toString((int) (recordIndex %
keyRange)).getBytes(StandardCharsets.UTF_8);
case RANDOM ->
Integer.toString(random.nextInt(keyRange)).getBytes(StandardCharsets.UTF_8);
default -> null;
};
```
##########
tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java:
##########
@@ -97,7 +106,8 @@ void start(String[] args) throws IOException {
transactionStartTime = System.currentTimeMillis();
}
- record = new ProducerRecord<>(config.topicName, payload);
+ byte[] key = generateKey(config.keyDistribution,
config.recordKeyRange, i, random);
Review Comment:
How can we avoid performance regressions in key generation? Pre-allocation?
--
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]