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 129931 - Cannot profile NB module "java.j2seproject"
Summary: Cannot profile NB module "java.j2seproject"
Status: RESOLVED FIXED
Alias: None
Product: profiler
Classification: Unclassified
Component: Base (show other bugs)
Version: 6.x
Hardware: All Linux
: P2 blocker (vote)
Assignee: Tomas Hurka
URL:
Keywords:
: 133482 138317 138334 (view as bug list)
Depends on:
Blocks:
 
Reported: 2008-03-12 16:29 UTC by Jaroslav Tulach
Modified: 2008-08-25 11:30 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
Logfile with tons of exceptions (35.58 KB, application/x-gzip)
2008-03-12 16:30 UTC, Jaroslav Tulach
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jaroslav Tulach 2008-03-12 16:29:43 UTC
NetBeans IDE Dev (Build 200803111205), javase version. Clean userdir, open java.j2seproject module. Set it as main. 
Try to profile it. No luck.
Comment 1 Jaroslav Tulach 2008-03-12 16:30:37 UTC
Created attachment 58249 [details]
Logfile with tons of exceptions
Comment 2 J Bachorik 2008-03-19 21:37:34 UTC
The call causing problem is "com.sun.tools.javac.model.JavacElements.getTypeElement()" which in the end results in ZIP
exception in "org.netbeans.modules.java.source.parsing.CachingArchive.createMap()" method.
From the first look it doesn't seem like a profiler problem but I will investigate further
Comment 3 J Bachorik 2008-03-25 23:08:10 UTC
The root cause is definitely depleting the pool of file descriptors. It seems it only happen on some linux distributions
where the number of opened files is limited to 1000 - in my case Ubuntu.
The excessive usage is caused by the fact that we in profiler use SourceForBinaryQuery to get the list of library only
classes from the classpath. AFAIK, it's not possible to get that list by any other means.
For now, the workaround is to increase the limit on open files.
Comment 4 J Bachorik 2008-03-26 19:44:45 UTC
fixing this issue will require substantial changes in the profiler code related to how a project classpath is
constructed and used. this is definitely not achievable for 6.1
requesting waiver
Comment 5 J Bachorik 2008-04-22 08:20:24 UTC
*** Issue 133482 has been marked as a duplicate of this issue. ***
Comment 6 pzajac 2008-04-22 08:48:27 UTC
too big IDE :(.  
Comment 7 Jiri Sedlacek 2008-06-26 21:41:54 UTC
*** Issue 138334 has been marked as a duplicate of this issue. ***
Comment 8 Jan Lahoda 2008-06-27 09:51:08 UTC
Not sure how this is related to the SourceForBinaryQuery. I tried this:
1. started profiling of java.j2seproject, took look on which files become open (through /proc/<id>/fd). One of them was:
"netbeans/enterprise5/modules/org-netbeans-modules-websvc-utilities.jar" which I used in further experiments.
2. I have augmented the "checkRead" method in the NB's security manager (o.n.bootstrap, TopSecurityManager) to show a
stacktrace each time someone wants to read the above file. Tried to profile java.j2seproject again. The interesting
stacktrace touching the given file was:
java.lang.Exception:
/usr/local/home/lahvac/src/nb/cos/nbbuild/netbeans/enterprise5/modules/org-netbeans-modules-websvc-utilities.jar
	at org.netbeans.TopSecurityManager.checkRead(TopSecurityManager.java:299)
	at java.util.zip.ZipFile.<init>(ZipFile.java:109)
	at java.util.zip.ZipFile.<init>(ZipFile.java:131)
	at org.netbeans.lib.profiler.classfile.ClassPath.<init>(ClassPath.java:181)
	at org.netbeans.lib.profiler.classfile.ClassRepository.initClassPaths(ClassRepository.java:453)
	at org.netbeans.modules.profiler.NetBeansProfiler.cleanupBeforeProfiling(NetBeansProfiler.java:1863)
	at org.netbeans.modules.profiler.NetBeansProfiler.access$2700(NetBeansProfiler.java:161)
	at org.netbeans.modules.profiler.NetBeansProfiler$3.doInBackground(NetBeansProfiler.java:1091)
	at org.netbeans.lib.profiler.ui.SwingWorker$2.run(SwingWorker.java:113)
	at org.openide.util.RequestProcessor$Task.run(RequestProcessor.java:561)
	at org.openide.util.RequestProcessor$Processor.run(RequestProcessor.java:986)
3. I took a look at org.netbeans.lib.profiler.classfile.ClassPath and it is seems to be opening ZipFiles, but it is not
clear to me when it is closing them (maybe at the end of the profiling session?). I added debugging messages into
org.netbeans.lib.profiler.classfile.ClassPath.<init> to check when a ZipFile is opened and to
org.netbeans.lib.profiler.classfile.ClassPath.close to check when a ZipFile is closed. After running the profiler again,
I got ~978 messages about opening a ZipFile, but none about closing them. There are ~978 jar files in NetBeans, so it
seems to me that the profiler is trying to open all the .jar files, but does not close them soon enough (978 opened
files seems too much to me).

Would it be possible to verify my observations, investigate when are the files being closed and how to prevent opening
so much files concurrently? Thanks.
Comment 9 Tomas Hurka 2008-06-27 11:06:43 UTC
org.netbeans.lib.profiler.classfile.ClassPath caches ZipFile-s to avoid their repetitive creation in the code that reads classfiles from JARs. The ZipFile-s are 
closed when profiling finishes. 
Comment 10 Tomas Hurka 2008-06-27 13:16:25 UTC
It looks like the initial evaluation is incorrect and the problem can be fixed in profiler code.
I will see what can be done to decrease number of simultaneously opened jars.
Comment 11 Tomas Hurka 2008-06-30 13:41:21 UTC
Fixed.
changeset:   86802:a1dd11c30d9d
user:        Tomas Hurka <thurka@netbeans.org>
date:        Mon Jun 30 14:40:19 2008 +0200
summary:     bugfix #129931, do not open all jars from classpath in the ClassPath constructor, open jars only when needed by profiler and use LRU cache for 
already opened jars

Comment 12 Quality Engineering 2008-07-02 04:30:49 UTC
Integrated into 'main-golden', available in NB_Trunk_Production #294 build
Changeset: http://hg.netbeans.org/main/rev/a1dd11c30d9d
User: Tomas Hurka <thurka@netbeans.org>
Log: bugfix #129931, do not open all jars from classpath in the ClassPath constructor, open jars only when needed by profiler and use LRU cache for already opened jars
Comment 13 Jiri Sedlacek 2008-08-25 11:30:15 UTC
*** Issue 138317 has been marked as a duplicate of this issue. ***