Log4j 2
  1. Log4j 2
  2. LOG4J2-153

Async Logger/Appender performance improvement: provide mechanism to discover if location StackTraceElement is actually required downstream.

    Details

    • Type: Improvement Improvement
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: 2.0-beta5
    • Component/s: None
    • Labels:
      None

      Description

      (update 2013 Feb 4: changed summary.
      Previous title: Add a method to the Layout interface to allow Loggers to discover if any of their Appenders need the location StackTraceElement.)


      Use Case: any asynchronous Logger or Appender has this problem:
      should it take a snapshot of the call stack (as implemented in Log4jLogEvent.getSource) or not?
      This is an expensive method (1600+ nanoseconds on a machine with 2.9GHz cores) so you only want to call it if you need it. Currently there is no way to discover if the location information is used by any of the configured layouts.

      If the Layout interface has a method that indicates whether the layout calls the LogEvent.getSource method, then the Logger can query its LoggerConfig if any of the configured Appenders has a Layout which needs location info. (Maybe boolean needsLocationInfo() would be a good name?)

      With this information, a Logger can construct Log4jLogEvents with a non-null dummy StackTraceElement location if none of the layouts downstream need location info. The non-null dummy location would prevent LogEvent.getSource from taking a call stack snapshot.

      The current AsynchAppender class would get an immediate performance boost from this, and custom asynchronous Loggers or Appenders would reap the same benefits.

        Issue Links

          Activity

          Gavin made changes -
          Link This issue is depended upon by LOG4J2-163 [ LOG4J2-163 ]
          Gavin made changes -
          Link This issue blocks LOG4J2-163 [ LOG4J2-163 ]
          Remko Popma made changes -
          Status Resolved [ 5 ] Closed [ 6 ]
          Ralph Goers made changes -
          Status Open [ 1 ] Resolved [ 5 ]
          Assignee Ralph Goers [ ralph.goers@dslextreme.com ]
          Fix Version/s 2.0-beta5 [ 12323970 ]
          Resolution Fixed [ 1 ]
          Remko Popma made changes -
          Link This issue blocks LOG4J2-163 [ LOG4J2-163 ]
          Remko Popma made changes -
          Summary Add a method to the Layout interface to allow Loggers to discover if any of their Appenders need the location StackTraceElement. Async Logger/Appender performance improvement: provide mechanism to discover if location StackTraceElement is actually required downstream.
          Description Use Case: any asynchronous Logger or Appender has this problem:
          should it take a snapshot of the call stack (as implemented in Log4jLogEvent.getSource) or not?
          This is an expensive method (1600+ nanoseconds on a machine with 2.9GHz cores) so you only want to call it if you need it. Currently there is no way to discover if the location information is used by any of the configured layouts.

          If the Layout interface has a method that indicates whether the layout calls the LogEvent.getSource method, then the Logger can query its LoggerConfig if any of the configured Appenders has a Layout which needs location info. (Maybe boolean needsLocationInfo() would be a good name?)

          With this information, a Logger can construct Log4jLogEvents with a non-null dummy StackTraceElement location if none of the layouts downstream need location info. The non-null dummy location would prevent LogEvent.getSource from taking a call stack snapshot.

          The current AsynchAppender class would get an immediate performance boost from this, and custom asynchronous Loggers or Appenders would reap the same benefits.
          (update 2013 Feb 4: changed summary.
          Previous title: Add a method to the Layout interface to allow Loggers to discover if any of their Appenders need the location StackTraceElement.)

          ----
          Use Case: any asynchronous Logger or Appender has this problem:
          should it take a snapshot of the call stack (as implemented in Log4jLogEvent.getSource) or not?
          This is an expensive method (1600+ nanoseconds on a machine with 2.9GHz cores) so you only want to call it if you need it. Currently there is no way to discover if the location information is used by any of the configured layouts.

          If the Layout interface has a method that indicates whether the layout calls the LogEvent.getSource method, then the Logger can query its LoggerConfig if any of the configured Appenders has a Layout which needs location info. (Maybe boolean needsLocationInfo() would be a good name?)

          With this information, a Logger can construct Log4jLogEvents with a non-null dummy StackTraceElement location if none of the layouts downstream need location info. The non-null dummy location would prevent LogEvent.getSource from taking a call stack snapshot.

          The current AsynchAppender class would get an immediate performance boost from this, and custom asynchronous Loggers or Appenders would reap the same benefits.
          Remko Popma made changes -
          Field Original Value New Value
          Link This issue is related to LOG4J2-151 [ LOG4J2-151 ]
          Remko Popma created issue -

            People

            • Assignee:
              Ralph Goers
              Reporter:
              Remko Popma
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development