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 169160 - Adding J2EE server hangs AWT thread in PhpVisibilityQuery.isVisible
Summary: Adding J2EE server hangs AWT thread in PhpVisibilityQuery.isVisible
Status: RESOLVED DUPLICATE of bug 170308
Alias: None
Product: php
Classification: Unclassified
Component: Project (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: Tomas Mysik
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2009-07-25 04:59 UTC by _ tboudreau
Modified: 2009-08-13 09:51 UTC (History)
1 user (show)

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments
thread dump (39.46 KB, text/plain)
2009-07-25 04:59 UTC, _ tboudreau
Details
thread dump (88.45 KB, text/plain)
2009-07-25 05:16 UTC, _ tboudreau
Details
Patch to quickly test if there is definitely no project (1.19 KB, patch)
2009-07-25 07:19 UTC, _ tboudreau
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description _ tboudreau 2009-07-25 04:59:01 UTC
Start NetBeans with a few Java projects open, but no web projects, and with no servers registered.

In the Services window, add an instance of Tomcat 6.

The UI is frozen for almost a minute (on a very fast machine).  The attached thread dump shows the following

        at org.netbeans.modules.php.project.util.PhpProjectUtils.getPhpProject(PhpProjectUtils.java:
92)
        at org.netbeans.modules.php.project.PhpVisibilityQuery.isVisible(PhpVisibilityQuery.java:67)

        at org.netbeans.api.queries.VisibilityQuery.isVisible(VisibilityQuery.java:99)
        at org.netbeans.modules.parsing.impl.indexing.RepositoryUpdater.fileChanged(RepositoryUpdate
r.java:424)

Not sure whether this is RepositoryUpdater being to aggressive, or if the code that creates the server instance is not
using FileSystem.AtomicAction correctly, or why anything would be trying to find the project that owns an instance of a
servlet container.   Probably something is listening to the entire universe of fileobjects that should not be.

Probably also the wizard should not create the new server instance in the AWT thread at all.

But certainly PhpVisibilityQuery can and should do a less expensive test and fail quickly in such a case, without going
through FileOwnerQuery.
Comment 1 _ tboudreau 2009-07-25 04:59:30 UTC
Created attachment 85204 [details]
thread dump
Comment 2 _ tboudreau 2009-07-25 05:15:41 UTC
Also seems to cause an indefinite hang when creating a web project - this time, not in the AWT thread, but after
creating the Tomcat instance, I tried to create a web project, and the UI has been hung at 25% of project creation
finished for 10 minutes.  Attaching two more thread dumps in a single file.  

Note that there are multiple threads inside PhpVisibilityQuery.isVisible().

Project creation finally completed after 12 minutes.

One item of that may be of interest:  The actual blockage seems to be in 
java.io.WinNTFileSystem.getBooleanAttributes(Native Method)
which is a known bottleneck on Windows (much slower call than on Linux).

I do have one drive mounted on Windows (using MS unix utilities) which is a remote NFS share.  If for some reason it is
trying to scan that (there are no files the IDE *should* know or care about there), that could be part of the problem.

Either way, PhpVisibilityQuery.isVisible() can probably be optimized so that the negative test is much faster.
Comment 3 _ tboudreau 2009-07-25 05:16:39 UTC
Created attachment 85205 [details]
thread dump
Comment 4 _ tboudreau 2009-07-25 05:22:42 UTC
Another note about the NFS share - it is currently mapped to an incorrect IP address, so it in fact is dead.
Comment 5 _ tboudreau 2009-07-25 07:19:58 UTC
Created attachment 85209 [details]
Patch to quickly test if there is definitely no project
Comment 6 _ tboudreau 2009-07-25 07:29:08 UTC
Patch attached simply returns null quickly if an nbproject directory exists.  Could be even more efficient if instead of
"nbproject", some other name were used, or if a uniquely named marker file could be expected to be present in all php
projects, so that the positive test does not have to go through FileOwnerQuery (but it is probably too late for this). 
fastCheckIsPossibleProject() takes ~0.25ms on my machine, and should solve the majority of the hangs.

See related issue 169166 - there are two things that make this problem worse:
 - If you are running under $NBSRC/nbbuild/testuserdir, PhpVisibilityQuery.isVisible() is called every time there is a
file change in any file in the system filesystem
 - It is called for many php files which are underneath $netbeans.home, where we can guarantee no project exists (issue
169166 is about that)
Comment 7 _ tboudreau 2009-07-25 07:46:29 UTC
exists -> does not exist
Comment 8 Petr Jiricka 2009-07-27 10:04:18 UTC
Tim, thanks many times for the patch. Tomas, can you please evaluate? One thing to verify is the situation when project
metadata are in a different directory than sources (see checkbox on the first panel of the New PHP Project wizard), and
whether this patch could affect this. Thanks.
Comment 9 _ tboudreau 2009-07-27 17:26:26 UTC
> One thing to verify is the situation when project metadata are in a different directory than sources

I don't know how you'd ever detect this except by scanning the entire filesystem of the OS, unless there's some
backreference in the sources (which probably means don't try) - although looking at open and recent projects is an
option for a partial answer.  

However, we can at least guarantee that no project exists under $NB_INSTALL and skip that.
Comment 10 Tomas Mysik 2009-07-29 10:27:50 UTC
This issue will be fixed automatically by fixing issue #169038, or more precisely issue #169036.
Comment 11 Tomas Mysik 2009-08-13 09:51:55 UTC
Will be fixed by fixing issue #170308.

*** This issue has been marked as a duplicate of 170308 ***