ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 42219] New: - Inefficient code in Union, DirectoryScanner makes large copy tasks very slow
Date Tue, 24 Apr 2007 14:09:24 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG·
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=42219>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND·
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=42219

           Summary: Inefficient code in Union, DirectoryScanner makes large
                    copy tasks very slow
           Product: Ant
           Version: 1.7.0
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Core tasks
        AssignedTo: dev@ant.apache.org
        ReportedBy: m101@io.com


In the (apparently) new org.apache.tools.ant.types.resources.Union class, and in
the venerable org.apache.tools.ant.DirectoryScanner class, Vectors or ArrayList
objects are used to accumulate unique file names.  The resultant use of the
"contains" or "indexOf" methods on those objects consumes a tremendous amount of
CPU time when the lists get long. The primary offender is the code in the new
Union class, specifically in the "getCollection" implementation.  The code in
DirectoryScanner is similar but (in my experience) causes less dramatic problems.

I'll attach a test build.xml file.

The solution is simple: since Java 1.4, java.util.LinkedHashSet has been
available to combine the lookup ("contains") performance of a HashSet coupled
with the predictable ordering of ArrayList or Vector.  In the Union class, the
code change necessary is to replace the ArrayList with a LinkedHashSet. In
DirectoryScanner, all the Vector sets can be similarly replaced, though a few
cleanup code changes are necessary (invisible outside the class).

In my real-life build, I have an "install" phase that involves at one point
copying over 12,000 .class files into an application directory. That was taking
about 45 seconds of solid 100% CPU-burning time (without actually doing any
copying; it was a "null build" situation where a build had just been completed),
but after hacking in my own fix to Union.java the build runs in about 15 seconds
(directly comparable to 1.6.5).  By applying the fixes to DirectoryScanner as
well, the "null build" time drops to 10 or 11 seconds.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@ant.apache.org
For additional commands, e-mail: dev-help@ant.apache.org


Mime
View raw message