This is an automated email from the ASF dual-hosted git repository. yong pushed a commit to branch branch-2.7 in repository https://gitbox.apache.org/repos/asf/pulsar.git
commit 41a7e78b2e472e5e42d95cc7d54b44015b763acd Author: Enrico Olivelli <[email protected]> AuthorDate: Tue Mar 2 18:31:20 2021 +0100 pulsar-perf: Dump JVM information (#9769) * Print JVM info while running pulsar-perf commands * Address Matteo's comments Co-authored-by: Enrico Olivelli <[email protected]> (cherry picked from commit 7643897cc3257ae640d4cad79455f3e4ab369470) --- .../proxy/socket/client/PerformanceClient.java | 2 + .../pulsar/testclient/LoadSimulationClient.java | 1 + .../pulsar/testclient/ManagedLedgerWriter.java | 1 + .../apache/pulsar/testclient/PerfClientUtils.java | 43 ++++++++++++++++++++++ .../pulsar/testclient/PerformanceConsumer.java | 1 + .../pulsar/testclient/PerformanceProducer.java | 1 + .../pulsar/testclient/PerformanceReader.java | 1 + 7 files changed, 50 insertions(+) diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/proxy/socket/client/PerformanceClient.java b/pulsar-testclient/src/main/java/org/apache/pulsar/proxy/socket/client/PerformanceClient.java index 107791b..aa0651a 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/proxy/socket/client/PerformanceClient.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/proxy/socket/client/PerformanceClient.java @@ -41,6 +41,7 @@ import org.apache.pulsar.client.api.Authentication; 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; @@ -300,6 +301,7 @@ public class PerformanceClient { 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); } diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/LoadSimulationClient.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/LoadSimulationClient.java index 9346da7..a71c323 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/LoadSimulationClient.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/LoadSimulationClient.java @@ -344,6 +344,7 @@ public class LoadSimulationClient { jc.usage(); System.exit(-1); } + PerfClientUtils.printJVMInformation(log); (new LoadSimulationClient(mainArguments)).run(); } diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/ManagedLedgerWriter.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/ManagedLedgerWriter.java index 034f7f8..93dde85 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/ManagedLedgerWriter.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/ManagedLedgerWriter.java @@ -143,6 +143,7 @@ public class ManagedLedgerWriter { 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)); diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerfClientUtils.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerfClientUtils.java new file mode 100644 index 0000000..3befd82 --- /dev/null +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerfClientUtils.java @@ -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())); + } +} diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceConsumer.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceConsumer.java index 27bc102..1f915c1 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceConsumer.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceConsumer.java @@ -244,6 +244,7 @@ public class PerformanceConsumer { } // 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)); diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java index 0c91fce..13ce5a0 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceProducer.java @@ -277,6 +277,7 @@ public class PerformanceProducer { } // 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)); diff --git a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceReader.java b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceReader.java index 97a00fc..dc7041e 100644 --- a/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceReader.java +++ b/pulsar-testclient/src/main/java/org/apache/pulsar/testclient/PerformanceReader.java @@ -187,6 +187,7 @@ public class PerformanceReader { } // 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));
