You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2020/12/13 17:49:53 UTC

[GitHub] [pulsar] lhotari opened a new pull request #8944: [logging] Enable Log4j2 Garbage Free Logging to reduce GC pressure

lhotari opened a new pull request #8944:
URL: https://github.com/apache/pulsar/pull/8944


   ### Motivation
   
   Log4j2 has a Garbage Free logging mode which reduces GC pressure since the garbage created by logging is very low ("garbage free"). This mode is the default of Log4j2 unless there is javax.servlet.Servlet class available at runtime since the Garbage Free logging mode doesn't support unloading & loading web applications which would be done in traditional J2EE application servers. Since Pulsar doesn't use web applications at all, it's the correct thing to disable Log4j2's web application detection so that the Garbage Free logging mode can be used.
   
   The performance benefits of the Garbage Free logging mode is described in the Log4j2 documentation:
   https://logging.apache.org/log4j/2.x/manual/garbagefree.html
   
   
   ### Modifications
   
   - 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")."
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari edited a comment on pull request #8944: [logging] Enable Log4j2 Garbage Free Logging to reduce GC pressure

Posted by GitBox <gi...@apache.org>.
lhotari edited a comment on pull request #8944:
URL: https://github.com/apache/pulsar/pull/8944#issuecomment-744183206


   > what about log4j2.garbagefreeThreadContextMap ? probably it is not worth, and we should perform benchmarks
   
   @eolivelli Good point. That would also be required for completely [configuring Log4j2 Garbage Free Logging](https://logging.apache.org/log4j/2.x/manual/garbagefree.html#Config). ([LOG4J2-1349 Garbage-free ThreadContext map](https://issues.apache.org/jira/browse/LOG4J2-1349)) Do you think it should be part of this PR? 
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] merlimat merged pull request #8944: [logging] Enable Log4j2 Garbage Free Logging to reduce GC pressure

Posted by GitBox <gi...@apache.org>.
merlimat merged pull request #8944:
URL: https://github.com/apache/pulsar/pull/8944


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on pull request #8944: [logging] Enable Log4j2 Garbage Free Logging to reduce GC pressure

Posted by GitBox <gi...@apache.org>.
eolivelli commented on pull request #8944:
URL: https://github.com/apache/pulsar/pull/8944#issuecomment-744043877


   Pulsar relays heavily on JAX-RS that is a server based technology.
   Can you explain more why are you saying that we do not use Java Web Servet technologies?
   
   I am not against this change but I would like to understand better


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari edited a comment on pull request #8944: [logging] Enable Log4j2 Garbage Free Logging to reduce GC pressure

Posted by GitBox <gi...@apache.org>.
lhotari edited a comment on pull request #8944:
URL: https://github.com/apache/pulsar/pull/8944#issuecomment-744050750


   > Can you explain more why are you saying that we do not use Java Web Servet technologies?
   
   I didn't mean that. I reworded the sentence, it's now "Since Pulsar isn't a J2EE/JEE server and doesn't need to unload & reload J2EE/JEE web applications, it's the correct thing to disable Log4j2's web application detection so that the more performant Log4j2 Garbage Free logging mode can be used."  (I also made other edits.)
   
   Is that better now?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on pull request #8944: [logging] Enable Log4j2 Garbage Free Logging to reduce GC pressure

Posted by GitBox <gi...@apache.org>.
eolivelli commented on pull request #8944:
URL: https://github.com/apache/pulsar/pull/8944#issuecomment-744071511


   what about log4j2.garbagefreeThreadContextMap ? probably it is not worth, and we should perform benchmarks


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on pull request #8944: [logging] Enable Log4j2 Garbage Free Logging to reduce GC pressure

Posted by GitBox <gi...@apache.org>.
lhotari commented on pull request #8944:
URL: https://github.com/apache/pulsar/pull/8944#issuecomment-744183206


   > what about log4j2.garbagefreeThreadContextMap ? probably it is not worth, and we should perform benchmarks
   
   @eolivelli Good point. That would also be required for [configuring Log4j2 Garbage Free Logging](https://logging.apache.org/log4j/2.x/manual/garbagefree.html#Config). ([LOG4J2-1349 Garbage-free ThreadContext map](https://issues.apache.org/jira/browse/LOG4J2-1349)) Do you think it should be part of this PR? 
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on pull request #8944: [logging] Enable Log4j2 Garbage Free Logging to reduce GC pressure

Posted by GitBox <gi...@apache.org>.
lhotari commented on pull request #8944:
URL: https://github.com/apache/pulsar/pull/8944#issuecomment-744063839


   /pulsarbot rerun-failure-checks


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari commented on pull request #8944: [logging] Enable Log4j2 Garbage Free Logging to reduce GC pressure

Posted by GitBox <gi...@apache.org>.
lhotari commented on pull request #8944:
URL: https://github.com/apache/pulsar/pull/8944#issuecomment-744050750


   > Can you explain more why are you saying that we do not use Java Web Servet technologies?
   
   I didn't mean that. I reworded the sentence, it's now "Since Pulsar isn't a J2EE/JEE server, it's the correct thing to disable Log4j2's web application detection so that the Garbage Free logging mode can be used." 
   Is that better now?


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lhotari removed a comment on pull request #8944: [logging] Enable Log4j2 Garbage Free Logging to reduce GC pressure

Posted by GitBox <gi...@apache.org>.
lhotari removed a comment on pull request #8944:
URL: https://github.com/apache/pulsar/pull/8944#issuecomment-744063839


   /pulsarbot rerun-failure-checks


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org