You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by mm...@apache.org on 2026/09/30 21:31:37 UTC
(pulsar) branch master updated: [improve][misc] Disable Netty leak detection by default in bin/pulsar, pulsar-perf and the CLI tools (#26783)
This is an automated email from the ASF dual-hosted git repository.
merlimat pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/pulsar.git
The following commit(s) were added to refs/heads/master by this push:
new 9a7dd7d64365 [improve][misc] Disable Netty leak detection by default in bin/pulsar, pulsar-perf and the CLI tools (#26783)
9a7dd7d64365 is described below
commit 9a7dd7d64365fa77ddd99833967611dda7054728
Author: Lari Hotari <lh...@users.noreply.github.com>
AuthorDate: Thu Oct 1 00:31:30 2026 +0300
[improve][misc] Disable Netty leak detection by default in bin/pulsar, pulsar-perf and the CLI tools (#26783)
---
bin/pulsar | 6 +++++-
bin/pulsar-admin-common.sh | 4 ++++
bin/pulsar-perf | 4 ++++
conf/pulsar_env.sh | 3 ++-
4 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/bin/pulsar b/bin/pulsar
index 854bf3995a5e..0ba4599475d7 100755
--- a/bin/pulsar
+++ b/bin/pulsar
@@ -332,8 +332,12 @@ OPTS="-Dio.netty.recycler.maxCapacityPerThread=4096 -Dio.netty.allocator.maxOrde
OPTS="-cp $PULSAR_CLASSPATH $OPTS"
+# Netty's leak detection samples buffer allocations and records access traces for the sampled ones, which costs CPU
+# on every component's hot paths. Disable it by default; the options that come later on the command line, such as
+# -Dio.netty.leakDetection.level=simple in PULSAR_EXTRA_OPTS (BOOKIE_EXTRA_OPTS for bookies), override this.
+OPTS="-Dio.netty.leakDetection.level=disabled $OPTS"
+
if [ $COMMAND == "bookie" ]; then
- OPTS="-Dio.netty.leakDetection.level=disabled $OPTS"
# Pass BOOKIE_EXTRA_OPTS option defined in bkenv.sh
OPTS="$OPTS $BOOKIE_MEM $BOOKIE_GC $BOOKIE_GC_LOG $BOOKIE_EXTRA_OPTS"
else
diff --git a/bin/pulsar-admin-common.sh b/bin/pulsar-admin-common.sh
index d3e46846c904..0ab56ba4a04d 100755
--- a/bin/pulsar-admin-common.sh
+++ b/bin/pulsar-admin-common.sh
@@ -161,6 +161,10 @@ OPTS="-XX:+ExitOnOutOfMemoryError -Dpulsar.allocator.exit_on_oom=true $OPTS"
# 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"
OPTS="$OPTS $PULSAR_EXTRA_OPTS"
diff --git a/bin/pulsar-perf b/bin/pulsar-perf
index 6ab59a36b96a..6470252dc51f 100755
--- a/bin/pulsar-perf
+++ b/bin/pulsar-perf
@@ -165,6 +165,10 @@ OPTS="-XX:+ExitOnOutOfMemoryError -Dpulsar.allocator.exit_on_oom=true $OPTS"
# 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
diff --git a/conf/pulsar_env.sh b/conf/pulsar_env.sh
index c78dd38755c4..baec2954caae 100755
--- a/conf/pulsar_env.sh
+++ b/conf/pulsar_env.sh
@@ -60,7 +60,8 @@
# reuses small size-class slots to limit fragmentation; retained chunks and size rounding still cost memory.
# To retain the previous cache allocator: -Dpulsar.allocator.ml-cache.type=pooled
# Settings are read when an allocator is first created. default overrides do not apply to other IDs.
-# Leak detection is global: use -Dio.netty.leakDetection.level=disabled|simple|advanced|paranoid.
+# Leak detection is global and disabled by default in bin/pulsar: enable it with
+# -Dio.netty.leakDetection.level=simple|advanced|paranoid.
# pulsar.allocator.leak_detection and per-allocator leak_detection settings are not supported.
# -Dpulsar.allocator.pooled=true is deprecated; use -Dpulsar.allocator.type=pooled instead.
# pulsar.allocator.type takes precedence over the legacy pulsar.allocator.pooled property.