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

FileConfigurationMonitor - High CPU usage

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: 2.3
    • Fix Version/s: 2.4
    • Component/s: Configurators, Core
    • Labels:
      None

      Description

      I am observing some high system CPU usage as a result of high number of calls to System.currentTimeMillis() in FileConfigurationMonitor.checkConfiguration() method.

      The checkConfiguration() method is called as part of Logger's every log/logIfEnabled and isEnabled method, therefore getting called thousands of times in my application when under moderate load. Each one of these calls therefore results in calling System.currentTimeMillis().

      The following code change, where the currentTimeMillis() is called only when required seemed to reduce the cpu load

      final long current = System.currentTimeMillis();
      if(((counter.incrementAndGet() & MASK) == 0) && (current >= nextCheck))

      Fixed as

       final long current;
              if (((counter.incrementAndGet() & MASK) == 0) && ((current = System.currentTimeMillis()) >= nextCheck)) {
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                remkop@yahoo.com Remko Popma
                Reporter:
                iconnj Nikhil
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: