You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@logging.apache.org by rp...@apache.org on 2015/09/20 10:34:55 UTC

[1/4] logging-log4j2 git commit: LOG4J2-1125 PatternLayout performance improvement by caching and reusing a ThreadLocal StringBuilder.

Repository: logging-log4j2
Updated Branches:
  refs/heads/LOG4J2-1121B-ReliabilityStrategy beb9e8c3c -> 63323d586


LOG4J2-1125 PatternLayout performance improvement by caching and reusing
a ThreadLocal StringBuilder.


Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/8025bb18
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/8025bb18
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/8025bb18

Branch: refs/heads/LOG4J2-1121B-ReliabilityStrategy
Commit: 8025bb18ce4444b76822a7965776bb075bd52aa9
Parents: 01d11a7
Author: rpopma <rp...@apache.org>
Authored: Sun Sep 20 09:09:07 2015 +0200
Committer: rpopma <rp...@apache.org>
Committed: Sun Sep 20 09:09:07 2015 +0200

----------------------------------------------------------------------
 .../log4j/core/layout/PatternLayout.java        | 20 +++++++++++++++-----
 src/changes/changes.xml                         |  3 +++
 2 files changed, 18 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8025bb18/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
----------------------------------------------------------------------
diff --git a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
index fb4bfcd..a8092ff 100644
--- a/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
+++ b/log4j-core/src/main/java/org/apache/logging/log4j/core/layout/PatternLayout.java
@@ -84,7 +84,14 @@ public final class PatternLayout extends AbstractStringLayout {
     /**
      * Initial converter for pattern.
      */
-    private final List<PatternFormatter> formatters;
+    private final PatternFormatter[] formatters;
+
+    private static ThreadLocal<StringBuilder> strBuilder = new ThreadLocal<StringBuilder>() {
+        @Override
+        protected StringBuilder initialValue() {
+            return new StringBuilder(1024);
+        }        
+    };
 
     /**
      * Conversion pattern.
@@ -127,8 +134,9 @@ public final class PatternLayout extends AbstractStringLayout {
         this.noConsoleNoAnsi = noConsoleNoAnsi;
         final PatternParser parser = createPatternParser(config);
         try {
-            this.formatters = parser.parse(pattern == null ? DEFAULT_CONVERSION_PATTERN : pattern, 
+            List<PatternFormatter> list = parser.parse(pattern == null ? DEFAULT_CONVERSION_PATTERN : pattern, 
                     this.alwaysWriteExceptions, this.noConsoleNoAnsi);
+            this.formatters = list.toArray(new PatternFormatter[0]);
         } catch (RuntimeException ex) {
             throw new IllegalArgumentException("Cannot parse pattern '" + pattern + "'", ex);
         }
@@ -189,9 +197,11 @@ public final class PatternLayout extends AbstractStringLayout {
      */
     @Override
     public String toSerializable(final LogEvent event) {
-        final StringBuilder buf = new StringBuilder(1024);
-        for (final PatternFormatter formatter : formatters) {
-            formatter.format(event, buf);
+        final StringBuilder buf = strBuilder.get();
+        buf.setLength(0);
+        final int len = formatters.length;
+        for (int i = 0; i < len; i++) {
+            formatters[i].format(event, buf);
         }
         String str = buf.toString();
         if (replace != null) {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/8025bb18/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 3779165..2266565 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -63,6 +63,9 @@
       <action issue="LOG4J2-1120" dev="rpopma" type="update">
         LoggerConfig performance improvements: avoid unnecessary lock acquisition, use more efficient data structure.
       </action>
+      <action issue="LOG4J2-1125" dev="rpopma" type="update">
+        PatternLayout performance improvement by caching and reusing a ThreadLocal StringBuilder.
+      </action>
       <action issue="LOG4J2-1114" dev="ggregory" type="update">
         Add thread name to status logger layout.
       </action>


[4/4] logging-log4j2 git commit: Merge branch 'master' into LOG4J2-1121B-ReliabilityStrategy

Posted by rp...@apache.org.
Merge branch 'master' into LOG4J2-1121B-ReliabilityStrategy

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/63323d58
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/63323d58
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/63323d58

Branch: refs/heads/LOG4J2-1121B-ReliabilityStrategy
Commit: 63323d5866bcc62f8d5c4832119f4c2b0638c8d9
Parents: beb9e8c 66b287f
Author: rpopma <rp...@apache.org>
Authored: Sun Sep 20 10:34:32 2015 +0200
Committer: rpopma <rp...@apache.org>
Committed: Sun Sep 20 10:34:32 2015 +0200

----------------------------------------------------------------------
 .../log4j/core/layout/PatternLayout.java        | 20 +++++++++++++++-----
 src/changes/changes.xml                         |  7 +++++++
 2 files changed, 22 insertions(+), 5 deletions(-)
----------------------------------------------------------------------



[3/4] logging-log4j2 git commit: LOG4J2-1121 document ReliabilityStrategy changes in release notes

Posted by rp...@apache.org.
LOG4J2-1121 document ReliabilityStrategy changes in release notes

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/66b287f4
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/66b287f4
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/66b287f4

Branch: refs/heads/LOG4J2-1121B-ReliabilityStrategy
Commit: 66b287f460576beb1b0400385811bf155960046d
Parents: 6f02c44
Author: rpopma <rp...@apache.org>
Authored: Sun Sep 20 10:32:10 2015 +0200
Committer: rpopma <rp...@apache.org>
Committed: Sun Sep 20 10:32:10 2015 +0200

----------------------------------------------------------------------
 src/changes/changes.xml | 4 ++++
 1 file changed, 4 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/66b287f4/src/changes/changes.xml
----------------------------------------------------------------------
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 2266565..d6660dc 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -66,6 +66,10 @@
       <action issue="LOG4J2-1125" dev="rpopma" type="update">
         PatternLayout performance improvement by caching and reusing a ThreadLocal StringBuilder.
       </action>
+      <action issue="LOG4J2-1121" dev="rpopma" type="fix">
+        Fixed potential race condition on reconfiguration. Introduced ReliabilityStrategy to facilitate
+        switching between different mechanisms for preventing log events from being dropped on reconfiguration.
+      </action>
       <action issue="LOG4J2-1114" dev="ggregory" type="update">
         Add thread name to status logger layout.
       </action>


[2/4] logging-log4j2 git commit: Merge branch 'LOG4J2-1121B-ReliabilityStrategy'

Posted by rp...@apache.org.
Merge branch 'LOG4J2-1121B-ReliabilityStrategy'

Project: http://git-wip-us.apache.org/repos/asf/logging-log4j2/repo
Commit: http://git-wip-us.apache.org/repos/asf/logging-log4j2/commit/6f02c448
Tree: http://git-wip-us.apache.org/repos/asf/logging-log4j2/tree/6f02c448
Diff: http://git-wip-us.apache.org/repos/asf/logging-log4j2/diff/6f02c448

Branch: refs/heads/LOG4J2-1121B-ReliabilityStrategy
Commit: 6f02c4487f21e25c7220f61a846cd5889e31a498
Parents: 8025bb1 a536638
Author: rpopma <rp...@apache.org>
Authored: Sun Sep 20 10:24:45 2015 +0200
Committer: rpopma <rp...@apache.org>
Committed: Sun Sep 20 10:24:45 2015 +0200

----------------------------------------------------------------------
 .../org/apache/logging/log4j/core/Logger.java   |  18 ++-
 .../logging/log4j/core/async/AsyncLogger.java   |   8 +-
 .../core/config/AbstractConfiguration.java      |  26 ++-
 .../AwaitCompletionReliabilityStrategy.java     | 157 +++++++++++++++++++
 ...AwaitUnconditionallyReliabilityStrategy.java | 119 ++++++++++++++
 .../log4j/core/config/ConfigurationMonitor.java |   9 ++
 .../config/DefaultConfigurationMonitor.java     |   8 +
 .../core/config/DefaultReliabilityStrategy.java | 103 ++++++++++++
 .../core/config/FileConfigurationMonitor.java   |   8 +
 .../core/config/LockingReliabilityStrategy.java | 128 +++++++++++++++
 .../logging/log4j/core/config/LoggerConfig.java | 155 ++++++------------
 .../log4j/core/config/ReliabilityStrategy.java  |  76 +++++++++
 .../core/config/ReliabilityStrategyFactory.java |  69 ++++++++
 .../log4j/core/async/AsyncLoggerConfigTest.java |   6 +-
 14 files changed, 766 insertions(+), 124 deletions(-)
----------------------------------------------------------------------