Skip to content

Commit

Permalink
[Broker/Bookie] Set -Dio.netty.tryReflectionSetAccessible=true for pu…
Browse files Browse the repository at this point in the history
…lsar processes (apache#11138)

- allows Netty to use reflection access on JDK9+
- fixes `jvm_memory_direct_bytes_used` Prometheus metric for Bookkeeper (Bookie). The direct memory usage metrics are disabled in Bookie on JDK11 unless `-Dio.netty.tryReflectionSetAccessible=true` is used.
- enables Netty to use more efficient byte buffer implementation such as UnpooledUnsafeNoCleanerDirectByteBuf in JDK9+ (JDK 11 in this case). This is already used in JDK8. In JDK9+, it is necessary to set `-Dio.netty.tryReflectionSetAccessible=true` to use UnpooledUnsafeNoCleanerDirectByteBuf. This is necessary for preventing performance regressions in this area.

- pass `-Dio.netty.tryReflectionSetAccessible=true` JVM option by default to all pulsar process started with `bin/pulsar` script.

(cherry picked from commit f0cbcb5)
  • Loading branch information
lhotari committed Jul 2, 2021
1 parent 329098e commit 255a96f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions bin/bookkeeper
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,9 @@ BOOKIE_CLASSPATH="$BOOKIE_JAR:$BOOKIE_CLASSPATH:$BOOKIE_EXTRA_CLASSPATH"
BOOKIE_CLASSPATH="`dirname $BOOKIE_LOG_CONF`:$BOOKIE_CLASSPATH"
OPTS="$OPTS -Dlog4j.configurationFile=`basename $BOOKIE_LOG_CONF`"

# Allow Netty to use reflection access
OPTS="$OPTS -Dio.netty.tryReflectionSetAccessible=true"

OPTS="-cp $BOOKIE_CLASSPATH $OPTS"

OPTS="$OPTS $BOOKIE_EXTRA_OPTS"
Expand Down
3 changes: 3 additions & 0 deletions bin/function-localrunner
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
BINDIR=$(dirname "$0")
export PULSAR_HOME=`cd -P $BINDIR/..;pwd`
. "$PULSAR_HOME/bin/pulsar-admin-common.sh"
# Allow Netty to use reflection access
OPTS="$OPTS -Dio.netty.tryReflectionSetAccessible=true"


# functions related variables
FUNCTIONS_HOME=$PULSAR_HOME/pulsar-functions
Expand Down
3 changes: 3 additions & 0 deletions bin/pulsar
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,9 @@ OPTS="$OPTS -Dlog4j.configurationFile=`basename $PULSAR_LOG_CONF`"
# directory)
OPTS="$OPTS -Djute.maxbuffer=10485760 -Djava.net.preferIPv4Stack=true"

# Allow Netty to use reflection access
OPTS="$OPTS -Dio.netty.tryReflectionSetAccessible=true"

OPTS="-cp $PULSAR_CLASSPATH $OPTS"

if [ $COMMAND == "bookie" ]; then
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1132,6 +1132,7 @@ flexible messaging model and an intuitive client API.</description>
-Dpulsar.allocator.leak_detection=Advanced
-Dpulsar.allocator.exit_on_oom=false
-Dlog4j.configurationFile=log4j2.xml
-Dio.netty.tryReflectionSetAccessible=true
${test.additional.args}
</argLine>
<reuseForks>${testReuseFork}</reuseForks>
Expand Down

0 comments on commit 255a96f

Please sign in to comment.