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

        Transition Time In Source Status Execution Times Last Executer Last Execution Date
        Open Open Resolved Resolved
        284d 4h 4m 1 Niall Pemberton 04/Aug/10 01:37
        Resolved Resolved Closed Closed
        463d 17h 32m 1 Henri Yandell 10/Nov/11 18:09
        Henri Yandell made changes -
        Status Resolved [ 5 ] Closed [ 6 ]
        Mark Thomas made changes -
        Workflow jira [ 12480312 ] Default workflow, editable Closed status [ 12601847 ]
        Niall Pemberton made changes -
        Field Original Value New Value
        Status Open [ 1 ] Resolved [ 5 ]
        Assignee Niall Pemberton [ niallp ]
        Fix Version/s 2.0 [ 12312961 ]
        Resolution Fixed [ 1 ]
        Show
        Niall Pemberton added a comment - Fixed thanks http://svn.apache.org/viewvc?view=revision&revision=982093
        Michael Haverkamp created issue -

          People

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

            Dates

            • Created:
              Updated:
              Resolved:

              Development