GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — pulsar/bin/pulsar-perf at master · apache/pulsar Expand file tree/ Copy pathpulsar-perfMore file actions executable file ·215 lines (191 loc) · 9.53 KB / Copy pathpulsar-perfFile metadata and controlsexecutable file ·215 lines (191 loc) · 9.53 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 #!/usr/bin/env bash # # 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. # BINDIR=$(dirname "$0") PULSAR_HOME=`cd -P $BINDIR/..;pwd` # log directory PULSAR_LOG_DIR=${PULSAR_LOG_DIR:-"$PULSAR_HOME/logs"} DEFAULT_CLIENT_CONF=${PULSAR_CLIENT_CONF:-"$PULSAR_HOME/conf/client.conf"} DEFAULT_LOG_CONF=$PULSAR_HOME/conf/log4j2.yaml # Remember whether the caller set these, since conf/pulsar_env.sh below fills them in with the # broker's defaults. pulsar-perf has never applied those defaults, and a load generator that # suddenly reserved the broker's 2g heap could fail to start where it used to run, so only a value # the caller passed in is applied. See where OPTS is assembled below. PULSAR_MEM_FROM_CALLER=${PULSAR_MEM:+true} PULSAR_GC_FROM_CALLER=${PULSAR_GC:+true} # Check bookkeeper env and load bkenv.sh if [ -f "$PULSAR_HOME/conf/bkenv.sh" ] then . "$PULSAR_HOME/conf/bkenv.sh" fi if [ -f "$PULSAR_HOME/conf/pulsar_env.sh" ] then . "$PULSAR_HOME/conf/pulsar_env.sh" fi # Check for the java to use if [[ -z $JAVA_HOME ]]; then JAVA=$(which java) if [ $? != 0 ]; then echo "Error: JAVA_HOME not set, and no java executable found in $PATH." 1>&2 exit 1 fi else JAVA=$JAVA_HOME/bin/java fi # exclude tests jar RELEASE_JAR=`ls $PULSAR_HOME/pulsar-*.jar 2> /dev/null | grep -v tests | tail -1` if [ $? == 0 ]; then PULSAR_JAR=$RELEASE_JAR fi # exclude tests jar BUILT_JAR=`ls $PULSAR_HOME/pulsar-testclient/build/libs/pulsar-testclient-*.jar 2> /dev/null | grep -v tests | tail -1` if [ $? != 0 ] && [ ! -e "$PULSAR_JAR" ]; then echo "\nCouldn't find pulsar jar."; echo "Make sure you've run './gradlew assemble'\n"; exit 1; elif [ -e "$BUILT_JAR" ]; then PULSAR_JAR=$BUILT_JAR fi add_gradle_deps_to_classpath() { f="${PULSAR_HOME}/distribution/server/build/classpath.txt" if [ ! -f "${f}" ] then ( cd "${PULSAR_HOME}" ./gradlew :distribution:pulsar-server-distribution:exportClasspath --no-configuration-cache -q 2> /dev/null ) fi PULSAR_CLASSPATH=${CLASSPATH}:`cat "${f}"` } if [ -d "$PULSAR_HOME/lib" ]; then PULSAR_CLASSPATH="$PULSAR_CLASSPATH:$PULSAR_HOME/lib/*" else add_gradle_deps_to_classpath fi if [ -z "$PULSAR_PERFTEST_CONF" ]; then PULSAR_PERFTEST_CONF=$DEFAULT_CLIENT_CONF fi if [ -z "$PULSAR_LOG_CONF" ]; then PULSAR_LOG_CONF=$DEFAULT_LOG_CONF fi PULSAR_CLASSPATH="$PULSAR_JAR:$PULSAR_CLASSPATH:$PULSAR_EXTRA_CLASSPATH" PULSAR_CLASSPATH="`dirname $PULSAR_LOG_CONF`:$PULSAR_CLASSPATH" OPTS="-Djava.net.preferIPv4Stack=true $OPTS -Dlog4j.configurationFile=`basename $PULSAR_LOG_CONF`" # Bridge java.util.logging (JUL) to Log4j2 so that JUL logs from third-party libraries # (Jersey, gRPC, Guava, etc.) are bridged into the Log4j2 configuration (conf/log4j2.yaml) OPTS="-Djava.util.logging.manager=org.apache.logging.log4j.jul.LogManager $OPTS" # Required to allow sun.misc.Unsafe on JDK 24 without warnings # Also required for enabling unsafe memory access for Netty since 4.1.121.Final if [[ $JAVA_MAJOR_VERSION -ge 23 ]]; then OPTS="--sun-misc-unsafe-memory-access=allow $OPTS" fi # Use compact object headers (JEP 519, https://openjdk.org/jeps/519), which shrink object headers from 12 to 8 bytes # and so reduce heap usage and improve cache locality. They are a product feature since JDK 25 and the default from # JDK 27 on (JEP 534, https://openjdk.org/jeps/534). The option is prepended so that the configured options can # override it with -XX:-UseCompactObjectHeaders. if [[ $JAVA_MAJOR_VERSION -eq 25 || $JAVA_MAJOR_VERSION -eq 26 ]]; then OPTS="-XX:+UseCompactObjectHeaders $OPTS" fi # Allow Netty to use reflection access OPTS="$OPTS -Dio.netty.tryReflectionSetAccessible=true" OPTS="$OPTS -Dorg.apache.pulsar.shade.io.netty.tryReflectionSetAccessible=true" if [[ $JAVA_MAJOR_VERSION -gt 8 ]]; then OPTS="$OPTS --add-opens java.base/sun.net=ALL-UNNAMED --add-opens java.base/java.lang=ALL-UNNAMED" # Required by Pulsar client optimized checksum calculation on other than Linux x86_64 platforms # reflection access to java.util.zip.CRC32C OPTS="$OPTS --add-opens java.base/java.util.zip=ALL-UNNAMED" fi if [[ $JAVA_MAJOR_VERSION -ge 11 ]]; then # Required by Netty for optimized direct byte buffer access OPTS="$OPTS --add-opens java.base/java.nio=ALL-UNNAMED --add-opens java.base/jdk.internal.misc=ALL-UNNAMED" fi if [[ $JAVA_MAJOR_VERSION -ge 24 ]]; then # Netty loads native libraries (epoll, io_uring, tcnative) via java.lang.System::loadLibrary, # which is a restricted method from Java 24 onwards. Without this the JVM prints a warning to # stderr on every invocation, and restricted methods will be blocked outright in a future # release. bin/pulsar already sets this for the server side. OPTS="$OPTS --enable-native-access=ALL-UNNAMED" fi # These two settings work together to ensure the Pulsar process exits immediately and predictably # if it runs out of either Java heap memory or its internal off-heap memory, # as these are unrecoverable errors that require a process restart to clear the faulty state and restore operation OPTS="-XX:+ExitOnOutOfMemoryError -Dpulsar.allocator.exit_on_oom=true $OPTS" # Netty tuning # These settings are primarily used to modify the Netty allocator configuration, # improving memory utilization and reducing the frequency of requesting off-heap memory from the OS # # Based on the netty source code, the allocator's default chunk size is calculated as: # io.netty.allocator.pageSize (default: 8192) shifted left by # io.netty.allocator.maxOrder (default: 9 after Netty 4.1.76.Final version). # This equals 8192 * 2^9 = 4 MB: # https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/PooledByteBufAllocator.java#L105 # # Allocations that are larger than chunk size are considered huge allocations and don't use the pool: # https://github.com/netty/netty/blob/4.1/buffer/src/main/java/io/netty/buffer/PoolArena.java#L141-L142 # # Currently, Pulsar defaults to a maximum single message size of 5 MB. # Therefore, when frequently producing messages whose size exceeds the chunk size, # Netty cannot utilize resources from the memory pool and must frequently allocate native memory. # This can lead to increased physical memory fragmentation and higher reclamation costs. # Thus, increasing io.netty.allocator.maxOrder to 10 to ensure that a single message is larger # than chunk size (8MB) and can reuse Netty's memory pool. OPTS="-Dio.netty.recycler.maxCapacityPerThread=4096 -Dio.netty.allocator.maxOrder=10 $OPTS" # Disable Netty's leak detection by default, as bin/pulsar does, since it costs CPU on the hot paths; # -Dio.netty.leakDetection.level in PULSAR_EXTRA_OPTS, which comes later on the command line, overrides it. OPTS="-Dio.netty.leakDetection.level=disabled $OPTS" OPTS="-cp $PULSAR_CLASSPATH $OPTS" # Apply PULSAR_MEM and PULSAR_GC when the caller set them. Unlike conf/pulsar_tools_env.sh, which # folds them into PULSAR_EXTRA_OPTS itself, conf/pulsar_env.sh only defines them, so a script that # sources it has to add them here or they are silently dropped — which is what used to happen. # Only caller-supplied values are used, so that the broker defaults conf/pulsar_env.sh fills in are # not imposed on a tool that has never had them; setting them by editing that file therefore does # not affect pulsar-perf, export them instead. PULSAR_GC_LOG is left out for the same reason: # pulsar_env.sh always gives it a value, so including it would make every run write GC logs. if [ -n "$PULSAR_MEM_FROM_CALLER" ]; then OPTS="$OPTS $PULSAR_MEM" fi if [ -n "$PULSAR_GC_FROM_CALLER" ]; then OPTS="$OPTS $PULSAR_GC" fi OPTS="$OPTS $PULSAR_EXTRA_OPTS" # log directory & file PULSAR_LOG_APPENDER=${PULSAR_LOG_APPENDER:-"Console"} # PULSAR_LOG_CONSOLE_JSON_TEMPLATE is deprecated — use PULSAR_LOG_JSON_TEMPLATE PULSAR_LOG_JSON_TEMPLATE=${PULSAR_LOG_JSON_TEMPLATE:-${PULSAR_LOG_CONSOLE_JSON_TEMPLATE:-"file:$PULSAR_HOME/conf/OtelLogLayout.json"}} PULSAR_LOG_FORMAT=${PULSAR_LOG_FORMAT:-"text"} PULSAR_LOG_FILE=${PULSAR_LOG_FILE:-"pulsar-perftest.log"} PULSAR_LOG_IMMEDIATE_FLUSH="${PULSAR_LOG_IMMEDIATE_FLUSH:-"false"}" #Configure log configuration system properties OPTS="$OPTS -Dpulsar.log.appender=$PULSAR_LOG_APPENDER" OPTS="$OPTS -Dpulsar.log.json.template=$PULSAR_LOG_JSON_TEMPLATE" OPTS="$OPTS -Dpulsar.log.format=$PULSAR_LOG_FORMAT" if [ -n "$PULSAR_LOG_LEVEL" ]; then OPTS="$OPTS -Dpulsar.log.level=$PULSAR_LOG_LEVEL" fi if [ -n "$PULSAR_LOG_ROOT_LEVEL" ]; then OPTS="$OPTS -Dpulsar.log.root.level=$PULSAR_LOG_ROOT_LEVEL" elif [ -n "$PULSAR_LOG_LEVEL" ]; then OPTS="$OPTS -Dpulsar.log.root.level=$PULSAR_LOG_LEVEL" fi OPTS="$OPTS -Dpulsar.log.immediateFlush=$PULSAR_LOG_IMMEDIATE_FLUSH" OPTS="$OPTS -Dpulsar.log.dir=$PULSAR_LOG_DIR" OPTS="$OPTS -Dpulsar.log.file=$PULSAR_LOG_FILE" #Change to PULSAR_HOME to support relative paths cd "$PULSAR_HOME" exec $JAVA $OPTS org.apache.pulsar.testclient.PulsarPerfTestTool $PULSAR_PERFTEST_CONF "$@" |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |