Uploaded image for project: 'logback'
  1. logback
  2. LOGBACK-282

SizeBasedTriggeringPolicy is not effecient enough because of using File.length() to check the active file size

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: logback-core
    • Labels:
      None
    • Environment:

      windows, linux

      Description

      Hi,

      It looks like SizeBasedTriggeringPolicy is not effecient enough because it will check active file size by calling File.length(), which will add a fixed overhead every 16 messages. (The performance definitely has been improved from 0.9.15 to 0.9.17 a lot by checking the file size every 16 message instead of every messages, we saw 20% overhead cut down on linux local file system.)

      We think SizeBasedTriggeringPolicy could work the FileAppender which keep track of how many bytes has been written through, and it's more efficient to check the file size based on how many bytes has been written. We also quickly made a mock up which keeps track of how many bytes written for comparison.

      Test Enviornment: Windows XP SP2, Linux 2.4
      Test #1: Writing 10 bytes message 1, 000, 000 times. (No rotation happens)
      Platform File.length() Tracking bytes written overhead (%)
      Windows ~ 12, 200 ms ~ 10, 000 ms 22%
      Linux (local) ~ 10, 200 ms ~ 9, 800 ms 4%
      Linux (NFS) ~ 37, 700 ms ~ 27, 300 ms 38%

      Test #2: Writing 100 bytes messages 1, 000, 000 times. (No rotation happens)
      Platform File.length() Tracking bytes written overhead (%)
      Windows ~ 14, 000 ms ~ 11, 300 ms 23%
      Linux (local) ~ 11, 100 ms ~ 10, 300 ms 7%
      Linux (NFS) ~ 414, 600 ms ~366, 300 ms 13%

      Could you please consider improve the performance of SizeBasedTriggeringPolicy so that there is minimal overhead.

      Great Thanks,
      Tom

        Attachments

          Activity

            People

            • Assignee:
              logback-dev Logback dev list
              Reporter:
              tomliliu tomliliu
            • Votes:
              2 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated: