| From | Sent On | Attachments |
|---|---|---|
| Brett Borchardt | Sep 13, 2011 9:11 am | |
| Brett Borchardt | Sep 13, 2011 3:14 pm | |
| strayph | Sep 13, 2011 3:18 pm | |
| Paul King | Sep 13, 2011 7:11 pm | |
| Paul King | Sep 13, 2011 7:20 pm |
| Subject: | [groovy-user] Groovyc ant task is very slow | |
|---|---|---|
| From: | Brett Borchardt (bbor...@gmail.com) | |
| Date: | Sep 13, 2011 9:11:03 am | |
| List: | org.codehaus.groovy.user | |
I am trying to introduce groovy into a fairly sizable java project (~300k SLOC) and one of the hurdles I have run into is that the groovyc ant task is very slow compared to its javac counterpart. I understand it has to do some extra work for cross compilation but it is slow even when all my source files are java. As a comparison, javac was taking ~1 minute, while groovyc was taking ~5 minutes to compile the same set of files. This was not acceptable to us, but I didn't want to give up so easily so I did a little digging.
What I found is the groovyc task relies on another class called JavaAwareCompilationUnit, which was ultimately calling the following method when collecting the source files:
private void addJavaSource(File file) { String path = file.getAbsolutePath(); for (Iterator iter = javaSources.iterator(); iter.hasNext();) { String su = (String) iter.next(); if (path.equals(su)) return; } javaSources.add(path); }
As you can see this is extremely inefficient as the number of source files gets large. I made a change to this class to change the javaSources variable from a LinkedList to a LinkedHashSet and modified this method to do the following:
private void addJavaSource(File file) { String path = file.getAbsolutePath(); javaSources.add(path); }
Presto! My build time went back down to ~1 minute, almost exactly as long as the javac task was taking. Note that this was all done in non-forked mode (due to issues getting forked mode to work with a long classpath). I may do some investigation into forked mode as well since it looks like there may be a fix in the works for that, but just thought I'd share this so it could be put back into the groovy project and others could benefit.
One other thing I noticed is that the exact same issue appears to be present when adding groovy sources (in the method org.codehaus.groovy.control.CompilationUnit#addSource(SourceUnit source)).
--
View this message in context:
http://groovy.329449.n5.nabble.com/Groovyc-ant-task-is-very-slow-tp4799092p4799092.html
Sent from the groovy - user mailing list archive at Nabble.com.
--------------------------------------------------------------------- To unsubscribe from this list, please visit:





