You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@logging.apache.org by GitBox <gi...@apache.org> on 2021/07/07 13:35:23 UTC

[GitHub] [logging-log4j2] carterkozak commented on a change in pull request #544: LOG4J2-3115: Remember previously computed strings in NamePatternConverter for performance ~3x

carterkozak commented on a change in pull request #544:
URL: https://github.com/apache/logging-log4j2/pull/544#discussion_r665376798



##########
File path: log4j-core/src/main/java/org/apache/logging/log4j/core/pattern/NamePatternConverter.java
##########
@@ -29,6 +32,11 @@
      */
     private final NameAbbreviator abbreviator;
 
+    /**
+     * Cache of previously encountered inputs (keys) and conversion results (values).
+     */
+    private final Map<String, String> conversionCache = new ConcurrentHashMap<>();

Review comment:
       I'm aware of applications which create an unbounded number of loggers using `LogManager.getLogger("resource." + resourceId)` to log a small amount of data. Such usage is expensive, and not good practice, but it shouldn't result in a memory leak.
   
   I imagine if performance of abbreviation is a problem, we can improve that instead of adding caches. I'm generally a bit biased against using caches unless it's the only option, they're hard to monitor, maintain, debug, and reason about imo.




-- 
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.

To unsubscribe, e-mail: notifications-unsubscribe@logging.apache.org

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