You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by GitBox <gi...@apache.org> on 2021/04/09 10:49:33 UTC
[GitHub] [kafka] tombentley commented on a change in pull request #10469: KAFKA-12611: Fix using random payload in ProducerPerformance incorrectly
tombentley commented on a change in pull request #10469:
URL: https://github.com/apache/kafka/pull/10469#discussion_r610531203
##########
File path: tools/src/main/java/org/apache/kafka/tools/ProducerPerformance.java
##########
@@ -127,15 +122,22 @@ public static void main(String[] args) throws Exception {
int currentTransactionSize = 0;
long transactionStartTime = 0;
for (long i = 0; i < numRecords; i++) {
+
+ if (payloadFilePath != null) {
+ payload = payloadByteList.get(random.nextInt(payloadByteList.size()));
+ } else if (recordSize != null) {
+ payload = new byte[recordSize];
Review comment:
I guess by allocating a new `byte[]` for each record and with big enough `recordSize` we'd generate quite a lot of garbage, so it might be better to allocate `payload` once outside the loop and just fill the buffer here.
--
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:
users@infra.apache.org