This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 162158 - [67cat] ClassLoader.getResource from Ant tasks slower than in 6.5
Summary: [67cat] ClassLoader.getResource from Ant tasks slower than in 6.5
Status: VERIFIED FIXED
Alias: None
Product: projects
Classification: Unclassified
Component: Ant (show other bugs)
Version: 6.x
Hardware: PC Linux
: P2 blocker (vote)
Assignee: issues@performance
URL:
Keywords: PERFORMANCE, REGRESSION
Depends on:
Blocks:
 
Reported: 2009-04-07 17:55 UTC by Michel Graciano
Modified: 2009-04-22 14:48 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Output text from build (1.09 MB, text/plain)
2009-04-07 19:44 UTC, Michel Graciano
Details
Execution log using ant degub mode (573.97 KB, application/x-compressed)
2009-04-07 21:09 UTC, Michel Graciano
Details
Execution log using ant quit mode (3.05 KB, text/plain)
2009-04-07 21:10 UTC, Michel Graciano
Details
Ant slowness demo (18.16 KB, application/x-compressed)
2009-04-17 17:59 UTC, misterm
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Michel Graciano 2009-04-07 17:55:48 UTC
[ BUILD # : 200904011705 ]
[ JDK VERSION : 1.6.* ]

Now, execution of ant tasks are slower than 6.5, almost 5 times
slower.
Comment 1 Jesse Glick 2009-04-07 18:16:45 UTC
Test case? Measurements?
Comment 2 Michel Graciano 2009-04-07 18:22:43 UTC
I am using 6.7 M3 JavaSE download option. For example, the same build I can run at 6.5, console and 6.7.

6.5: BUILD SUCCESSFUL (total time: 2 minutes 47 seconds)
console: Total time: 2 minutes 58 seconds
6.7: BUILD SUCCESSFUL (total time: 9 minutes 36 seconds)
Comment 3 Michel Graciano 2009-04-07 18:25:48 UTC
Any ant script I run, I can see it is really slower. All this times I sent, I just closed and reopened the IDE and run
the most large task I have. Thew console in 6.7 is slower, the things are printed slowly, in 6.5 it is hard to read what
is printed. What kind of info you need?

Regards
Comment 4 Jesse Glick 2009-04-07 19:28:12 UTC
Running on JDK 6 / Ubuntu I can reproduce a modest slowdown (roughly 42 -> 49 seconds) between 6.5 and 090406-dev
running nbbuild/build.xml#build-platform second and subsequent times (i.e. everything compiled and up to date). Possibly
due to output window colorizing.
Comment 5 Michel Graciano 2009-04-07 19:44:12 UTC
Created attachment 79679 [details]
Output text from build
Comment 6 Jesse Glick 2009-04-07 20:23:32 UTC
Looks like an unusually verbose build. Might be able to see contrast more clearly (e.g. for use by a profiler) when
changing Ant logging level to Verbose or Debug.
Comment 7 Michel Graciano 2009-04-07 21:09:06 UTC
Created attachment 79683 [details]
Execution log using ant degub mode
Comment 8 Michel Graciano 2009-04-07 21:10:24 UTC
Created attachment 79684 [details]
Execution log using ant quit mode
Comment 9 Michel Graciano 2009-04-07 21:22:03 UTC
There is no relevant difference between ant tasks execution times in any mode, even in Normal, Debug or Quiet
Comment 10 Jesse Glick 2009-04-07 21:25:23 UTC
If it's still slow in "Quiet" mode then your problem is likely different from what I reproduced, and we would certainly
need a complete, self-contained test case to reproduce - or a profiler snapshot (ideally with 6.5 times subtracted).
Comment 11 Antonin Nebuzelsky 2009-04-08 13:55:36 UTC
> There is no relevant difference between ant tasks execution times in any mode, even in Normal, Debug or Quiet.

All of these take same amount of time? Reassigning to performance for some measurements. Output would be innocent in
this case.
Comment 12 Michel Graciano 2009-04-08 14:02:09 UTC
> All of these take same amount of time? Reassigning to performance for some measurements. Output would be innocent in
> this case.

Yes, all builds take something close to 10 minutes in 6.7, and less than 3 minutes for 6.5 and console ant execution.
Comment 13 t_h 2009-04-08 14:31:28 UTC
I compared performance of OW in 6.5.1 and trunk version and I do not see any significant difference. Also I checked
perf. difference when colorized output is used and it was OK too (100k color lines written to OW took 2.8s instead of 2.6s).
Comment 14 Michel Graciano 2009-04-13 15:28:35 UTC
Just to be clear, I am sure the problem is not about OW coloring. I have the same times even when running ant with
different debug levels. I will send an test case as soon as I can create one, since my project is really huge.
Comment 15 Jesse Glick 2009-04-13 16:27:52 UTC
Obviously we would prefer not to get a 50Mb ZIP of your whole project (even assuming there is nothing proprietary in it
and you could do so). It is possible that there is some particular task that your build script runs which is much slower
in 6.7 for some reason, and identifying it could lead to a small and easily analyzed test case. A profiler may help
identify this task.

Also be sure to check running heap usage - if different _default_ max heap settings cause 6.7 to run close to max heap,
and your build involves some steps which reference a lot of heap at once, NB will spend a lot of time in GC. A healthy
JVM process will evenly consume its available heap, collect at least half of it, then start over; this characteristic
"saw" pattern can be seen in Visual VM or similar tools.
Comment 16 misterm 2009-04-14 21:03:22 UTC
XDoclet tasks run slowly and any task except javac that generates .class files is also slow.
Comment 17 misterm 2009-04-14 21:20:32 UTC
BTW, on my machine, builds also run 5 times slower (from 8 min to 40 min).
Comment 18 Jesse Glick 2009-04-14 22:03:22 UTC
@misterm: could you attach a small example project that we can look at to clearly see the difference between 6.5 and 6.7?
Comment 19 Michel Graciano 2009-04-14 22:11:25 UTC
I have an "small" sample where we can see this difference, but this sample have 20 mb... Do you have any idea where can
I attach it since here is not possible?
Comment 20 Michel Graciano 2009-04-15 14:25:43 UTC
I attached test case [1]. To test it, you will need the JBoss too, both 3.2.X or 4.2.X should work.
To test it, go to genesis-all-3.1/samples/useradmin and build using clean-webstart target for build.xml build file. The
build should be different for 6.5 and 6.7, here I have difference larger than one minute.
The basic difference about this sample and our project is that we have a lot of files to be weaved, as you can see at
attached log files. As misterm says, xdoclet targets seen to be the problem.

Regards
[1] http://performance.netbeans.org/files/documents/66/2464/genesis-all-3.1.zip
Comment 21 misterm 2009-04-17 17:59:55 UTC
Created attachment 80380 [details]
Ant slowness demo
Comment 22 misterm 2009-04-17 18:06:45 UTC
Steps to reproduce:

- Extract ant_slowness.zip;
- Use Resolve References to point to ant.jar in your NB checkout;
- Run ant-slowness in NB 6.5 and 6.7.

Our results:
Windows XP - 43 sec vs 1:47min
Ubuntu 8.04 - 3 sec vs 21 sec

It seems using ClassLoader.getResourceAsStream(String) from an Ant task is as slow as a turtle :-)
Comment 23 Jesse Glick 2009-04-17 18:08:00 UTC
BTW project.properties in demo should have:

javac.classpath=${ant.core.lib}
Comment 24 Jesse Glick 2009-04-17 19:49:54 UTC
I can reproduce a slowdown with this project. It seems a somewhat pathological case but valid. No idea yet what the
difference between 6.5 and 6.7 would be here.


BTW the task is also wrong:

      final FileSet fileSet = new FileSet();
      fileSet.setDir(parent);
      path.addFileset(fileSet);

should be

      path.createPathElement().setLocation(parent);
Comment 25 misterm 2009-04-17 19:58:53 UTC
Notice running it from the command line with the Ant release bundled with NetBeans main produces no slowdown.

Also, don't take the test case so literally; several tasks that generate files have more or less the same pattern: read 
several resources from the classpath and spits a couple of thousands of files. These include XDoclet tasks, weaving 
tasks from AOP frameworks, retroweaving tools etc.
Comment 26 Jesse Glick 2009-04-17 20:06:44 UTC
I have to take the test case literally - it's the only one I have. I can see that, for example, cl.getResource(name) is
slower in 6.7 than in 6.5. If something else is slower as well, then I need a separate test case.
Comment 27 misterm 2009-04-17 20:09:53 UTC
Sorry for the confusion. What I mean is all the tasks types I mentioned read thousands of resources and spits thousands 
of files. So that's how I got to this task.

I have a project with all these kinds of tasks, so I am just telling all of them are affected because they follow this 
pattern.

The only difference is they don't read files they have just generated; instead, they read files generated from previous 
tasks.
Comment 28 Jesse Glick 2009-04-17 20:54:25 UTC
Have not managed to get any useful information from the Profiler; reports self times, but for a quick method called
>2000x this is pretty skewed. Taking random thread dumps seems to work much better; most of them look like this:

        at java.io.UnixFileSystem.canonicalize0(Native Method)
        at java.io.UnixFileSystem.canonicalize(UnixFileSystem.java:157)
        at java.io.File.getCanonicalPath(File.java:531)
        at java.io.FilePermission$1.run(FilePermission.java:218)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.io.FilePermission.init(FilePermission.java:212)
        at java.io.FilePermission.<init>(FilePermission.java:264)
        at sun.net.www.protocol.file.FileURLConnection.getPermission(FileURLConnection.java:198)
        at sun.net.www.protocol.jar.JarURLConnection.getPermission(JarURLConnection.java:79)
        at sun.misc.URLClassPath.check(URLClassPath.java:398)
        at sun.misc.URLClassPath$Loader.findResource(URLClassPath.java:456)
        at sun.misc.URLClassPath.findResource(URLClassPath.java:142)
        at java.net.URLClassLoader$2.run(URLClassLoader.java:362)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findResource(URLClassLoader.java:359)
        at java.lang.ClassLoader.getResource(ClassLoader.java:977)
        at org.apache.tools.ant.module.bridge.AntBridge$AllPermissionURLClassLoader.getResource(AntBridge.java:582)
        at org.apache.tools.ant.AntClassLoader.getResource(AntClassLoader.java:920)
        at br.com.summa.netbeans.ant.test.FileGenerator.execute(FileGenerator.java:52)
Comment 29 misterm 2009-04-17 21:03:31 UTC
The only logical answer for that is that, somehow, in NB 6.7, there is a lot more visible to AntClassLoader than in the 
other environments (NB 6.5 and command line). That's why it takes so much longers.
Comment 30 misterm 2009-04-17 21:03:45 UTC
The only logical answer for that is that, somehow, in NB 6.7, there is a lot more visible to AntClassLoader than in the 
other environments (NB 6.5 and command line). That's why it takes so much longer.
Comment 31 Jesse Glick 2009-04-17 21:10:02 UTC
In fact there is a little bit _less_ in 6.7, since platform*/lib/*.jar are no longer visible.

My current guess is that some changes in JAR handling in 6.5 were partially reverted to the "natural" state in 6.7, and
the JRE's jar: protocol handler is just slow when a security manager is present.
Comment 32 Jesse Glick 2009-04-17 23:16:36 UTC
Obscure bug in URLClassLoader, as it turns out. core-main #48a20db39cca
Comment 33 Quality Engineering 2009-04-20 20:23:22 UTC
Integrated into 'main-golden', will be available in build *200904201507* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/48a20db39cca
User: Jesse Glick <jglick@netbeans.org>
Log: #162158: performance problem in URLClassLoader when passing jar:...!/ URLs.
Comment 34 Michel Graciano 2009-04-22 14:48:54 UTC
Now... 'BUILD SUCCESSFUL (total time: 2 minutes 27 seconds)'
:-D

v. 200904220201