| 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: | Re: [groovy-user] Re: Groovyc ant task is very slow | |
|---|---|---|
| From: | Paul King (pau...@asert.com.au) | |
| Date: | Sep 13, 2011 7:20:33 pm | |
| List: | org.codehaus.groovy.user | |
Created a jira issue: http://jira.codehaus.org/browse/GROOVY-5018
On 14/09/2011 12:11 PM, Paul King wrote:
Well spotted. Definitely a bug.
Thanks, Paul.
On 14/09/2011 8:15 AM, Brett Borchardt wrote:
In looking at this a little more, it appears the code I listed above while inefficient is not really that slow unless the number of files is huge. That left me wondering why it was a problem for us since we only have ~2500 classes. I popped it into the debugger and saw that it was iterating over 7 million files due to the following method in FileSystemCompiler, which is the real root cause of most our slowness. I bolded the offending line of code
public static String[] generateFileNamesFromOptions(CommandLine cli) { String[] filenames = cli.getArgs(); List<String> fileList = new ArrayList<String>(filenames.length); boolean errors = false; for (String filename : filenames) { if (filename.startsWith("@")) { try { BufferedReader br = new BufferedReader(new FileReader(filename.substring(1))); String file; while ((file = br.readLine()) != null) { fileList.add(file); } } catch (IOException ioe) { System.err.println("error: file not readable: " + filename.substring(1)); errors = true; } } else { *fileList.addAll(Arrays.asList(filenames));* } } if (errors) { return null; } else { return fileList.toArray(new String[fileList.size()]); } }
As you can see it's adding the entire array inside the loop, so you end up with n^2 files. Then combine that with the inefficient iterator when later adding the files to the compilation unit and that's how it ends up being so slow.
--
View this message in context:
http://groovy.329449.n5.nabble.com/Groovyc-ant-task-is-very-slow-tp4799092p4800466.html
Sent from the groovy - user mailing list archive at Nabble.com.
--------------------------------------------------------------------- To unsubscribe from this list, please visit:
--------------------------------------------------------------------- To unsubscribe from this list, please visit:
--------------------------------------------------------------------- To unsubscribe from this list, please visit:





