Commons IO
  1. Commons IO
  2. IO-220

FileCleaningTracker Vector performs badly under load

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Major Major
    • Resolution: Fixed
    • Affects Version/s: 1.0, 1.1, 1.2, 1.3, 1.3.1, 1.3.2, 1.4, 2.0, 3.x
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      Using commons-io-1.4 via commons-fileupload-1.1.1 in Apache Tomcat/5.5.0 on Java 1.6.

      Description

      When subjected to heavy load, the performance of org.apache.commons.io.FileCleaningTracker degrades and becomes a bottleneck to the system. In our case, we had over 2 millions entries on the "trackers" Vector. Under these conditions, the call to trackers.remove(tracker) on line 214 becomes very inefficient as it causes the Vector to shift and reindex the remaining data. In addition, calls to trackers.add are forced to wait on the inefficient remove operation. With the application idle, it took several hours for the File Reaper thread to finish processing the entries on the trackers Vector.

      The solution for use was to implement trackers as a HashSet instead of a Vector. Thus line 52 was changed from:
      final Collection /* Tracker */ trackers = new Vector(); // synchronized
      to
      final Collection /* Tracker */ trackers = Collections.synchronizedSet(new HashSet()); // synchronized
      Imports were also change appropriately.

        Activity

        Show
        Niall Pemberton added a comment - Fixed thanks http://svn.apache.org/viewvc?view=revision&revision=982093

          People

          • Assignee:
            Niall Pemberton
            Reporter:
            Michael Haverkamp
          • Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development