I wonder if @CriticalPath or @HandOptimized would convey better what we are
trying to express?

Gary


---------- Forwarded message ----------
From: <[email protected]>
Date: Sun, Feb 21, 2016 at 7:02 PM
Subject: logging-log4j2 git commit: Add PerformanceSensitive annotation.
To: [email protected]


Repository: logging-log4j2
Updated Branches:
  refs/heads/master f884234a8 -> 4aa7df826


Add PerformanceSensitive annotation.


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

Branch: refs/heads/master
Commit: 4aa7df826de7e359ac3bde98597fe5ca6e4b5901
Parents: f884234
Author: Matt Sicker <[email protected]>
Authored: Sun Feb 21 21:02:51 2016 -0600
Committer: Matt Sicker <[email protected]>
Committed: Sun Feb 21 21:02:51 2016 -0600

----------------------------------------------------------------------
 .../log4j/util/PerformanceSensitive.java        | 29 ++++++++++++++++++++
 .../logging/log4j/util/ReflectionUtil.java      |  5 ++++
 .../log4j/core/config/AppenderControl.java      |  4 +++
 .../core/config/AppenderControlArraySet.java    |  8 ++++--
 4 files changed, 43 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4aa7df82/log4j-api/src/main/java/org/apache/logging/log4j/util/PerformanceSensitive.java
----------------------------------------------------------------------
diff --git
a/log4j-api/src/main/java/org/apache/logging/log4j/util/PerformanceSensitive.java
b/log4j-api/src/main/java/org/apache/logging/log4j/util/PerformanceSensitive.java
new file mode 100644
index 0000000..3fbb058
--- /dev/null
+++
b/log4j-api/src/main/java/org/apache/logging/log4j/util/PerformanceSensitive.java
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache license, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the license for the specific language governing permissions and
+ * limitations under the license.
+ */
+
+package org.apache.logging.log4j.util;
+
+/**
+ * Indicates that a particular annotated construct was written with
certain performance constraints in mind that
+ * should be considered when modifying or testing.
+ *
+ * @since 2.6
+ */
+public @interface PerformanceSensitive {
+    /** Description of why this is written the way it is. */
+    String value() default "";
+}

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4aa7df82/log4j-api/src/main/java/org/apache/logging/log4j/util/ReflectionUtil.java
----------------------------------------------------------------------
diff --git
a/log4j-api/src/main/java/org/apache/logging/log4j/util/ReflectionUtil.java
b/log4j-api/src/main/java/org/apache/logging/log4j/util/ReflectionUtil.java
index 6e7ce4a..dec2350 100644
---
a/log4j-api/src/main/java/org/apache/logging/log4j/util/ReflectionUtil.java
+++
b/log4j-api/src/main/java/org/apache/logging/log4j/util/ReflectionUtil.java
@@ -117,6 +117,7 @@ public final class ReflectionUtil {
     // (MS) I believe this would work without any modifications elsewhere,
but I could be wrong

     // migrated from ReflectiveCallerClassUtility
+    @PerformanceSensitive
     public static Class<?> getCallerClass(final int depth) {
         if (depth < 0) {
             throw new IndexOutOfBoundsException(Integer.toString(depth));
@@ -193,11 +194,13 @@ public final class ReflectionUtil {
     }

     // migrated from ClassLoaderContextSelector
+    @PerformanceSensitive
     public static Class<?> getCallerClass(final String fqcn) {
         return getCallerClass(fqcn, Strings.EMPTY);
     }

     // migrated from Log4jLoggerFactory
+    @PerformanceSensitive
     public static Class<?> getCallerClass(final String fqcn, final String
pkg) {
         if (supportsFastReflection()) {
             boolean next = false;
@@ -227,6 +230,7 @@ public final class ReflectionUtil {
     }

     // added for use in LoggerAdapter implementations mainly
+    @PerformanceSensitive
     public static Class<?> getCallerClass(final Class<?> anchor) {
         if (supportsFastReflection()) {
             boolean next = false;
@@ -270,6 +274,7 @@ public final class ReflectionUtil {
     }

     // migrated from ThrowableProxy
+    @PerformanceSensitive
     public static Stack<Class<?>> getCurrentStackTrace() {
         // benchmarks show that using the SecurityManager is much faster
than looping through getCallerClass(int)
         if (SECURITY_MANAGER != null) {

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4aa7df82/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
----------------------------------------------------------------------
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
index f65011d..175c9e1 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControl.java
@@ -25,6 +25,7 @@ import org.apache.logging.log4j.core.LogEvent;
 import org.apache.logging.log4j.core.appender.AppenderLoggingException;
 import org.apache.logging.log4j.core.filter.AbstractFilterable;
 import org.apache.logging.log4j.core.filter.Filterable;
+import org.apache.logging.log4j.util.PerformanceSensitive;

 /**
  * Wraps an {@link Appender} with details an appender implementation
shouldn't need to know about.
@@ -88,14 +89,17 @@ public class AppenderControl extends AbstractFilterable
{
         return isFilteredByAppenderControl(event) ||
isFilteredByLevel(event) || isRecursiveCall();
     }

+    @PerformanceSensitive
     private boolean isFilteredByAppenderControl(final LogEvent event) {
         return getFilter() != null && Filter.Result.DENY ==
getFilter().filter(event);
     }

+    @PerformanceSensitive
     private boolean isFilteredByLevel(final LogEvent event) {
         return level != null && intLevel < event.getLevel().intLevel();
     }

+    @PerformanceSensitive
     private boolean isRecursiveCall() {
         if (recursive.get() != null) {
             appenderErrorHandlerMessage("Recursive call to appender ");

http://git-wip-us.apache.org/repos/asf/logging-log4j2/blob/4aa7df82/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControlArraySet.java
----------------------------------------------------------------------
diff --git
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControlArraySet.java
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControlArraySet.java
index 78a42b3..d30ce32 100644
---
a/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControlArraySet.java
+++
b/log4j-core/src/main/java/org/apache/logging/log4j/core/config/AppenderControlArraySet.java
@@ -16,17 +16,19 @@
  */
 package org.apache.logging.log4j.core.config;

-import org.apache.logging.log4j.core.Appender;
-
 import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
 import java.util.concurrent.atomic.AtomicReference;

+import org.apache.logging.log4j.core.Appender;
+import org.apache.logging.log4j.util.PerformanceSensitive;
+
 /**
  * Data structure with similar semantics to CopyOnWriteArraySet, but
giving direct access to the underlying array.
  */
+@PerformanceSensitive
 public class AppenderControlArraySet {
     private final AtomicReference<AppenderControl[]> appenderArray = new
AtomicReference<>(new AppenderControl[0]);

@@ -117,4 +119,4 @@ public class AppenderControlArraySet {
     public AppenderControl[] get() {
         return appenderArray.get();
     }
-}
\ No newline at end of file
+}




-- 
E-Mail: [email protected] | [email protected]
Java Persistence with Hibernate, Second Edition
<http://www.manning.com/bauer3/>
JUnit in Action, Second Edition <http://www.manning.com/tahchiev/>
Spring Batch in Action <http://www.manning.com/templier/>
Blog: http://garygregory.wordpress.com
Home: http://garygregory.com/
Tweet! http://twitter.com/GaryGregory

Reply via email to