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 221482 - Long delay with PHP editor code completion
Summary: Long delay with PHP editor code completion
Status: RESOLVED FIXED
Alias: None
Product: editor
Classification: Unclassified
Component: CSL (API & infrastructure) (show other bugs)
Version: 7.2
Hardware: All All
: P3 normal (vote)
Assignee: Svata Dedic
URL:
Keywords: PERFORMANCE
Depends on:
Blocks:
 
Reported: 2012-11-05 12:56 UTC by _ wadechandler
Modified: 2012-11-19 21:22 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 190382


Attachments
nps snapshot (232.55 KB, application/nps)
2012-11-05 12:56 UTC, _ wadechandler
Details

Note You need to log in before you can comment on or make changes to this bug.
Description _ wadechandler 2012-11-05 12:56:47 UTC
Build: NetBeans IDE 7.2 (Build 201207171143)
VM: Java HotSpot(TM) 64-Bit Server VM, 23.1-b03, Java(TM) SE Runtime Environment, 1.7.0_05-b06
OS: Linux

User Comments:
wadechandler: I am in the PHP editor. I am on an empty new line. I press CTRL+SPACE. Long delay. Over and over I can make this happen it. The long delay varies, but it happens over and over. I have installed the updates. I have restarted. My Java editor does not do this.

GUEST: editing PHP file



Maximum slowness yet reported was 32350 ms, average is 25705
Comment 1 _ wadechandler 2012-11-05 12:56:52 UTC
Created attachment 127141 [details]
nps snapshot
Comment 2 _ wadechandler 2012-11-05 13:09:59 UTC
This is in the full version of the IDE: JEE, PHP, C++, etc
Comment 3 Milos Kleint 2012-11-05 13:27:54 UTC
(In reply to comment #2)
> This is in the full version of the IDE: JEE, PHP, C++, etc

And Scala as well.

just my personal pet peeve.. have you tried killing (deleting) the ergonomicsX folder in netbeans installation?


There doesn't seem to be a one specific problem at hand. PHP support through PhpSourcePath.getFileType() is querying Classpath for a file. that in turn invokes java and cls classpath providers which most likely iterate project. Then in Maven project types we get some slowness in lookup resolutions but it's unclear to me what could have caused that. Maybe some sort of synchronization issue. In 7.3 I've done some optimizations in project lookup construction, not sure if it has any significant measurable effect though.

It's unclear to me why is all this happening in AWT thread, php guys want to comment on that?
Comment 4 Milos Kleint 2012-11-05 13:28:21 UTC
how many projects do you have open at a time?
Comment 5 _ wadechandler 2012-11-05 13:42:41 UTC
I use the project groups feature. So, in this case, I only have a single PHP project opened. I do have another group which I had opened prior to this one being opened which has maybe 20 projects in it with a good number of classes. Not sure if that could impact it. I'm restarting so that the PHP group opens first. Will update.
Comment 6 _ wadechandler 2012-11-05 13:54:19 UTC
The blocking the EDT is really bad though. For instance, when I restarted, I see "Scanning in progress" and if I CTRL+SPACE, then I'm blocked until that project completes scanning, and too, it depends on the size of your PHP installation I guess. That on top of this other issue of completing hanging for a while. Code completion seems fine enough if I am not on an empty newline, but the UI blocking issue would come into play depending on the speed of the drive and other factors.
Comment 7 Milos Kleint 2012-11-05 13:56:22 UTC
in 7.3 timeframe there is a change in how MavenFileOwnerQuery (class that links maven projects together via local repository paths) works within project groups. In 7.2 we persisted a global list of "known" projects, known being those at least once opened, or their parent pom project was opened.
in 7.3 the setting became project group specific, each project group having it's own list of "known projects".
Comment 8 _ wadechandler 2012-11-05 14:00:26 UTC
I should probably rephrase the last sentence. It is fine if say I type my| and where | is the cursor do a CTRL+SPACE. Were I to arrow up onto a line which has code, yet be in white space I still have the issue. On an empty new line, then the same.

So (where _ is a space to allow showing the cursor):
______pr|int '';

fine (some where in the middle of real code)

___|___print '';

hangs (white space of a line with code)

____|_____

hangs (empty new line)
Comment 9 _ wadechandler 2012-11-05 14:01:39 UTC
Restarting with just PHP project opened had the same exact affect. In other words, the project was opened when I closed, and was the only thing the IDE opened when I restarted. Does the issue you mentioned mean *ever opened* once or only per IDE run?
Comment 10 _ wadechandler 2012-11-05 14:03:05 UTC
Seems strange this is only affected in the cases of white space. Perhaps there is some kind of passed in context or text which is checked and causes the logic to go down separate paths?
Comment 11 Tomas Mysik 2012-11-05 14:05:06 UTC
(In reply to comment #3)
> It's unclear to me why is all this happening in AWT thread, php guys want to
> comment on that?

Ondra can explain, I guess.

For NB 7.3, we changed the recognition of "file type" (source, include) for PHP to use ClassPath (otherwise we are not able to recognize INCLUDE file). I can optimize it in PHP but this seems to me to be a more general problem...
Comment 12 Tomas Mysik 2012-11-05 14:06:19 UTC
Adding Tomas to CC...
Comment 13 Tomas Mysik 2012-11-05 14:08:35 UTC
One more idea - how many PHP files do you have on your Global PHP Include Path?
Comment 14 Ondrej Brejla 2012-11-05 14:09:13 UTC
Milos: that getRhsHtml method of php completion item is called from CSL, so csl
calls it from AWT
Comment 15 Milos Kleint 2012-11-05 14:12:06 UTC
(In reply to comment #9)
> Restarting with just PHP project opened had the same exact affect. In other
> words, the project was opened when I closed, and was the only thing the IDE
> opened when I restarted. Does the issue you mentioned mean *ever opened* once
> or only per IDE run?

Ever.
you can check the list in your config/Preferences/org/netbeans/modules/maven/externalOwners.properties file in netbeans user directory. if you delete it and restart the ide, you loose all your inter-project connections..
Comment 16 Milos Kleint 2012-11-05 14:22:27 UTC
(In reply to comment #14)
> Milos: that getRhsHtml method of php completion item is called from CSL, so csl
> calls it from AWT

so we reassign to CSL (whatever that is)? What is the component in bugzilla?
Comment 17 Ondrej Brejla 2012-11-05 14:45:28 UTC
Editor/CSL
Comment 18 _ wadechandler 2012-11-05 14:49:37 UTC
Milos: Got it. I think I will leave those for now then. I am just helping a NB user from the IRC chat out by tracking down some PHP issues he mentioned. I might check that out later or something to see how that behaves, but my main work is happening in Maven and Java right now :-)

Tomas: As it relates to my include_path, php.ini says it defaults to the pear path, and it isn't set, so if I run:
pear list

then I see:

Installed packages, channel pear.php.net:
=========================================
Package          Version State
Archive_Tar      1.3.7   stable
Benchmark        1.2.7   stable
Console_Getopt   1.3.0   stable
PEAR             1.9.4   stable
Structures_Graph 1.0.4   stable
XML_Util         1.2.1   stable

This is my dev box, and I'm not really jamming on any PHP right now, and that really doesn't seem like a lot of packages necessarily. I can run an example and see what the install_path is set to at runtime though.
Comment 19 Tomas Zezula 2012-11-05 14:50:38 UTC
FileOwnerQuery should be fast enough to be called from EDT as all the project queries delegate to it.
Not allowing it disables also the ClassPath, SFBQ, BSFQ, JFBQ, SLQ, etc. There is lots of code in project ui doing it.
Comment 20 _ wadechandler 2012-11-05 14:50:46 UTC
This is Ubuntu 12.04 64-bit if that helps any.
Comment 21 _ wadechandler 2012-11-05 14:52:52 UTC
Just noticed the ergonomicsx comment. I will try to move that off and see how it behaves. Will let you know if it helps at all.
Comment 22 _ wadechandler 2012-11-05 15:00:47 UTC
The NB "Global Include Path" is blank btw.
Comment 23 _ wadechandler 2012-11-05 15:04:13 UTC
Milos: Was looking at config/Preferences/org/netbeans/modules/maven/externalOwners.properties. That guy seems like it could get pretty big. Is there a limit placed on its size? Or does it just grow to the max size which will support a Properties instance? Curious side note.
Comment 24 Tomas Mysik 2012-11-05 15:07:24 UTC
(In reply to comment #22)
> The NB "Global Include Path" is blank btw.

Thanks, this is exactly what I have asked for (NetBeans does not know anything about your php.ini and does not use at all).

Thanks.
Comment 25 _ wadechandler 2012-11-05 15:16:51 UTC
I deleted the "ergnomics" directory under my 7.2 install and this had no effect on this issue.
Comment 26 _ wadechandler 2012-11-05 15:30:06 UTC
Milos: Last thing I can think of out of the things I think that were mentioned. I tried to move off externalOwners.properties, and this seems to have had no effect either.

Are any of you guys able to replicate with the full version of the IDE?
Comment 27 Tomas Zezula 2012-11-05 15:40:38 UTC
Not sure that the CSL is the right component.
Moving the call outside the EDT does not solve the root cause the slow FileOwnerQuery.
Comment 28 Svata Dedic 2012-11-08 10:29:34 UTC
I am rather against moving the computation off EDT in GSF. If RHS / LHS html strings are difficult to compute in PHP, then PHPCompletionItem should preinitialize them in the completion provider, so the calls are fast. And since they used from getPreferredSize(), they may be called pretty frequently.

There's about 15,2secs of Maven Project implementation running out of 20secs of the reported slowness... so I am tempted to move the attribute the slowness to Maven support, but I'd wait for a confirming report from 7.3, since perf. optimizations have been made, according to Milos.

The second fix candidate is IMHO PHP; the isPlatform() call result might be either precomputed directly in PHP Element during parsing or (as even getFileObject() is lazy) possibly when PHPCompletionProvider creates the CompletionElements.

PHP owners, can it be done ?
Comment 29 Tomas Mysik 2012-11-08 12:32:01 UTC
(In reply to comment #28)
> PHP owners, can it be done ?

We could try to cache platform files themselves (these files are part of NetBeans); but the current code is:

    private static boolean isInternalFile(FileObject file) {
        for (FileObject dir : CommonPhpSourcePath.getInternalPath()) {
            if (dir.equals(file)
                    || FileUtil.isParentOf(dir, file)) {
                return true;
            }
        }
        return false;
    }

where CommonPhpSourcePath.getInternalPath() is already cached. Will it help? What do you think? I am not sure that we will improve something...

Thanks.
Comment 30 _ wadechandler 2012-11-08 13:06:57 UTC
Why adverse to taking it off the EDT? This seems a prime example of why it should be done. Unknown  issues creep in in strange places and other modules. If the EDT is blocked then the IDE is u sable. Were it not this could be bearable.
Comment 31 Ondrej Brejla 2012-11-08 13:11:40 UTC
So after discussion with Svata, we will move that isPlatform() call to CompletionItem constructor, which is not processed in AWT, but in CC thread, so AWT should not longer be blocked now.
Comment 32 Ondrej Brejla 2012-11-08 13:28:50 UTC
So editor part is done web-main #6a54085bc220
Comment 33 _ wadechandler 2012-11-08 13:29:31 UTC
On the other part, yes, there must be something in the maven module causing some long delays. I will see if I can replicate this in 7.3 full (everything enabled). If I can, then I will see if I can find some time to debug it with a daily hg grab. If I can't, then I will see if I can do the same with the 7.2.1 sources. I should be able to run that against my code and it shouldn't be any different than what is happening to me now as it relates to using the IDE. I will use the same userdir. Perhaps I can better pinpoint it.
Comment 34 _ wadechandler 2012-11-08 14:01:35 UTC
I meant to say: Thank you for jumping on the EDT bits guys.
Comment 35 Svata Dedic 2012-11-08 15:48:01 UTC
OK, setting as fixed, as both maven & processing in EDT were supposedly improved from 7.2. _wadechandler: please check the issue with 7.3dev build, when the fix becomes available. Reopen and attach a fresh profiler snapshot if necessary; thanks.
Comment 36 Quality Engineering 2012-11-09 02:53:32 UTC
Integrated into 'main-golden', will be available in build *201211090001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/6a54085bc220
User: Ondrej Brejla <obrejla@netbeans.org>
Log: #221482 - Long delay with PHP editor code completion