Uploaded image for project: 'Commons IO'
  1. Commons IO
  2. IO-220

FileCleaningTracker Vector performs badly under load

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • 1.0, 1.1, 1.2, 1.3, 1.3.1, 1.3.2, 1.4, 2.0, 3.x
    • 2.0
    • None
    • None
    • 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.

      Attachments

        Activity

          People

            niallp Niall Pemberton
            mhaverkamp Michael Haverkamp
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: