Skip to content

Commit

Permalink
pulsar-perf: Dump JVM information (#9769)
Browse files Browse the repository at this point in the history
* Print JVM info while running pulsar-perf commands

* Address Matteo's comments

Co-authored-by: Enrico Olivelli <eolivelli@apache.org>
(cherry picked from commit 7643897)
  • Loading branch information
eolivelli authored and zymap committed Mar 3, 2021
1 parent ca94db5 commit 41a7e78
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
import org.apache.pulsar.client.api.AuthenticationDataProvider;
import org.apache.pulsar.client.api.AuthenticationFactory;
import org.apache.pulsar.common.naming.TopicName;
import org.apache.pulsar.testclient.PerfClientUtils;
import org.apache.pulsar.testclient.utils.PaddingDecimalFormat;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -300,6 +301,7 @@ public void runPerformanceTest(long messages, long limit, int numOfTopic, int si
public static void main(String[] args) throws Exception {
PerformanceClient test = new PerformanceClient();
Arguments arguments = test.loadArguments(args);
PerfClientUtils.printJVMInformation(log);
test.runPerformanceTest(arguments.numMessages, arguments.msgRate, arguments.numTopics, arguments.msgSize,
arguments.proxyURL, arguments.topics.get(0), arguments.authPluginClassName, arguments.authParams);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -344,6 +344,7 @@ public static void main(String[] args) throws Exception {
jc.usage();
System.exit(-1);
}
PerfClientUtils.printJVMInformation(log);
(new LoadSimulationClient(mainArguments)).run();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ public static void main(String[] args) throws Exception {
arguments.testTime = TimeUnit.SECONDS.toMillis(arguments.testTime);

// Dump config variables
PerfClientUtils.printJVMInformation(log);
ObjectMapper m = new ObjectMapper();
ObjectWriter w = m.writerWithDefaultPrettyPrinter();
log.info("Starting Pulsar managed-ledger perf writer with config: {}", w.writeValueAsString(arguments));
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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.pulsar.testclient;

import io.netty.util.internal.PlatformDependent;
import lombok.experimental.UtilityClass;
import org.apache.commons.io.FileUtils;
import org.slf4j.Logger;
import java.lang.management.ManagementFactory;

/**
* Utility for test clients
*/
@UtilityClass
public class PerfClientUtils {

/**
* Print useful JVM information, you need this information in order to be able
* to compare the results of executions in different environments.
* @param log
*/
public static void printJVMInformation(Logger log) {
log.info("JVM args {}", ManagementFactory.getRuntimeMXBean().getInputArguments());
log.info("Netty max memory (PlatformDependent.maxDirectMemory()) {}", FileUtils.byteCountToDisplaySize(PlatformDependent.maxDirectMemory()));
log.info("JVM max heap memory (Runtime.getRuntime().maxMemory()) {}", FileUtils.byteCountToDisplaySize(Runtime.getRuntime().maxMemory()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ public static void main(String[] args) throws Exception {
}

// Dump config variables
PerfClientUtils.printJVMInformation(log);
ObjectMapper m = new ObjectMapper();
ObjectWriter w = m.writerWithDefaultPrettyPrinter();
log.info("Starting Pulsar performance consumer with config: {}", w.writeValueAsString(arguments));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ public static void main(String[] args) throws Exception {
}

// Dump config variables
PerfClientUtils.printJVMInformation(log);
ObjectMapper m = new ObjectMapper();
ObjectWriter w = m.writerWithDefaultPrettyPrinter();
log.info("Starting Pulsar perf producer with config: {}", w.writeValueAsString(arguments));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ public static void main(String[] args) throws Exception {
}

// Dump config variables
PerfClientUtils.printJVMInformation(log);
ObjectMapper m = new ObjectMapper();
ObjectWriter w = m.writerWithDefaultPrettyPrinter();
log.info("Starting Pulsar performance reader with config: {}", w.writeValueAsString(arguments));
Expand Down

0 comments on commit 41a7e78

Please sign in to comment.