This is an automated email from the ASF dual-hosted git repository.
mmerli 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 13e57bd [logging] Enable Log4j2 Garbage Free Logging to reduce GC
pressure (#8944)
13e57bd is described below
commit 13e57bd00214ab6f0282e08ee3aa5a97b8fecc9f
Author: Lari Hotari <[email protected]>
AuthorDate: Mon Dec 14 19:01:10 2020 +0200
[logging] Enable Log4j2 Garbage Free Logging to reduce GC pressure (#8944)
- Configure log4j2 to disable servlet webapp detection so that Garbage
free logging can be used.
- Log4j2 will disable Garbage free logging if there is
javax.servlet.Servlet class
available at runtime unless "-Dlog4j2.is.webapp=false" is passed
on the command line.
- See source code at
https://github.com/apache/logging-log4j2/blob/master/log4j-api/src/main/java/org/apache/logging/log4j/util/Constants.java#L25-L41
- Documented at
https://logging.apache.org/log4j/2.x/manual/garbagefree.html
"From version 2.6, Log4j runs in "garbage free" mode by default where
objects
and buffers are reused and no temporary objects are allocated as much
as possible.
There is also a "low garbage" mode which is not completely garbage
free but does
not use ThreadLocal fields. This is the default mode when Log4j
detects it is
running in a web application."
...
"ThreadLocal fields holding non-JDK classes can cause memory leaks in
web applications
when the application server's thread pool continues to reference these
fields after
the web application is undeployed. To avoid causing memory leaks,
Log4j will not use
these ThreadLocals when it detects that it is used in a web
application (when the
javax.servlet.Servlet class is in the classpath, or when system
property log4j2.isWebapp
is set to "true")."
---
bin/pulsar | 2 ++
1 file changed, 2 insertions(+)
diff --git a/bin/pulsar b/bin/pulsar
index 28f2f9d..e862cc4 100755
--- a/bin/pulsar
+++ b/bin/pulsar
@@ -289,6 +289,8 @@ OPTS="$OPTS -Dpulsar.log.dir=$PULSAR_LOG_DIR"
OPTS="$OPTS -Dpulsar.log.level=$PULSAR_LOG_LEVEL"
OPTS="$OPTS -Dpulsar.log.root.level=$PULSAR_LOG_ROOT_LEVEL"
OPTS="$OPTS -Dpulsar.routing.appender.default=$PULSAR_ROUTING_APPENDER_DEFAULT"
+# Configure log4j2 to disable servlet webapp detection so that Garbage free
logging can be used
+OPTS="$OPTS -Dlog4j2.is.webapp=false"
# Functions related logging
OPTS="$OPTS -Dpulsar.functions.process.container.log.dir=$PULSAR_LOG_DIR"