Uploaded image for project: 'Log4j 2'
  1. Log4j 2
  2. LOG4J2-1120

LoggerConfig performance improvements

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 2.3
    • 2.4
    • Core
    • None

    Description

      As discussed on the mailing list, I can see several ways to improve the performance of the hot path in LoggerConfig.

      1. Pulling up the shutdown.get() check into afterLogEvent() will avoid acquiring the shutdownLock unnecessarily - only acquiring the lock if a shutdown is actually in progress.
      2. Another performance improvement can be made by changing the data structure that holds the AppenderControl objects from ConcurrentHashMap to CopyOnWriteArraySet. Modifications on this data structure are extremely rare, and the array-based collection has much better iteration performance.
      3. Finally, since clearAppenders() is only called after all appenders have been stopped, waitForCompletion() may no longer be necessary (unless I am missing something here). If so, the shutdownLock, shutdown and counter fields can be removed. Not incrementing the atomic counters with every event in the hot path should give better performance.

      Attachments

        Issue Links

          Activity

            People

              rpopma Remko Popma
              rpopma Remko Popma
              Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: