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 219507 - LowPerformance took 42153 ms.
Summary: LowPerformance took 42153 ms.
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: JDK Problems (show other bugs)
Version: 7.3
Hardware: All All
: P3 normal (vote)
Assignee: Stanislav Aubrecht
URL:
Keywords: PERFORMANCE
: 218910 220370 (view as bug list)
Depends on:
Blocks:
 
Reported: 2012-10-04 09:53 UTC by aldobrucale
Modified: 2012-11-14 14:47 UTC (History)
6 users (show)

See Also:
Issue Type: DEFECT
Exception Reporter: 192707


Attachments
nps snapshot (398.39 KB, application/nps)
2012-10-04 09:53 UTC, aldobrucale
Details
nps snapshot (180.27 KB, application/nps)
2012-10-21 20:11 UTC, everflux
Details
Cache calls to getScreenInsets for 10 seconds (3.68 KB, patch)
2012-10-30 20:27 UTC, everflux
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description aldobrucale 2012-10-04 09:53:46 UTC
This issue was reported manually by mentlicher.
It already has 1 duplicates 


Build: NetBeans IDE Dev (Build 201209240001)
VM: Java HotSpot(TM) Client VM, 23.3-b01, Java(TM) SE Runtime Environment, 1.7.0_07-b10
OS: Linux

User Comments:
aldobrucale: Autocompletion in breakpoint condition editor



Maximum slowness yet reported was 42153 ms, average is 42153
Comment 1 aldobrucale 2012-10-04 09:53:55 UTC
Created attachment 125369 [details]
nps snapshot
Comment 2 Martin Entlicher 2012-10-04 09:59:16 UTC
*** Bug 218910 has been marked as a duplicate of this bug. ***
Comment 3 everflux 2012-10-21 20:11:22 UTC
Created attachment 126274 [details]
nps snapshot
Comment 4 Dusan Balek 2012-10-22 08:16:04 UTC
Code completion is waiting for an extremely slow call to org.openide.util.Utilities.getUsableScreenBounds()
Comment 5 everflux 2012-10-22 20:02:54 UTC
Some information about my system configuration:
>10 GB ram, Nvidia graphics card, dual screen setup with 2x 2560x1600 resolution, Ubuntu Linux

Netbeans UI feels kind of sluggish, I am not sure if it is due to being Linux or the large resolution.

Eager to help out with more tests.
Comment 6 Antonin Nebuzelsky 2012-10-23 10:02:21 UTC
(In reply to comment #4)
> Code completion is waiting for an extremely slow call to
> org.openide.util.Utilities.getUsableScreenBounds()

Stando, another issue related to issue 218895?
Comment 7 Stanislav Aubrecht 2012-10-23 10:14:15 UTC
Looks like a problem in XToolkit as sun.awt.X11.XToolkit.getScreenInsets() is doing some wild things which can take more than half a minute to complete.

A workaround is to use -J-Dnetbeans.screen.insets=0,0,0,0 command-line switch.

This problem isn't related to #218895
Comment 8 everflux 2012-10-23 11:10:21 UTC
I will test the work-around and report back in the next days.

Additional remarks: I run Netbeans on the primary monitor, the secondary is left-of the primary monitor. Due to the nvidia proprietary driver my comments should be taken with a grain of salt, I always get confused how nvidia handles this stuff. (Most applications get the impression that I have in fact only one big screen.)
When I execute code completion I notice sometimes flickering, resizing grey boxes at the position the hints will finally appear when Netbeans finally decides what to display. I assumed this is due to the nightly builds, the behaviour is much slower than Netbeans 7.2 in this aspect. (Up to the point that I currently try to avoid code completion since it slows me down so much.)
I will try to verify this with a different machine.
Comment 9 everflux 2012-10-25 17:43:03 UTC
Tested with 201210250921 even without the -J-insets switch, it feels a hell of a lot faster.
With the -J-Dnetbeans.screen.insets=0,0,0,0  command line switch, auto-completion hints are on the wrong screen (dual screen setup), the performance does not feel different.
(With the insets specified it looks to me like the http://netbeans.org/bugzilla/show_bug.cgi?id=213733 issue seems to be solved by a JDK update.)

I didn't change the JDK, though.

java version "1.7.0_09"
Java(TM) SE Runtime Environment (build 1.7.0_09-b05)
Java HotSpot(TM) 64-Bit Server VM (build 23.5-b02, mixed mode)
Comment 10 everflux 2012-10-25 17:56:03 UTC
I just had the issue happening again
"It has now been added to the database with id #622144. It has been classified as a duplicate of report #192707."

What I noticed: The performance seems to be related to the number of possible suggestions.
When there is just 1 oder 3 options to choose from, it is blazingly fast. When there are many suggestions it is very slow.

Under that circumance I can confirm that
"-J-Dnetbeans.screen.insets=0,0,0,0"
fixes the issue, but the popups are then on the wrong display.

Without deep knowledge what is happening under the hoods - could the insets be cached some way to mitigate the problem?
Comment 11 everflux 2012-10-25 18:34:14 UTC
Looks like gathering the screen insets is a rather slow call on my machine:

Total time for 100 iterations 12250
Per iteration: 122
(On my current machine, 16GB ram, Nvidia graphics card, dual screen 2560x1600x2)
I used an older machine  (5 year old T60 laptop with 2gb ram, ati graphics card, 1400x1050 screen, 64bit server vm as well) as reference:
Total time for 10000 iterations 2123
Per iteration: 0

That is orders of magnitude difference.

I used this to measure the time taken to get the insets, but having no deep experience with AWT/Swing it might measure the wrong thing:

public class ScreenInsets
{
    public static void main(String[] args)
    {
        runInsets();
    }
    
    public static void runInsets()
    {
        int ITERATIONS = 100;
        GraphicsConfiguration graphicsConfiguration = new Frame().getGraphicsConfiguration();
        Toolkit defaultToolkit = Toolkit.getDefaultToolkit();
        
        long start = System.currentTimeMillis();
        
        int i = ITERATIONS;
        
        while(i-- > 0)
        {
            defaultToolkit.getScreenInsets(graphicsConfiguration);
            
        }
        
        long end = System.currentTimeMillis();
        System.out.println(String.format("Total time for %d iterations %d",ITERATIONS, end-start));
        System.out.println(String.format("Per iteration: %d", (end-start)/ITERATIONS));
    }

}
Comment 12 everflux 2012-10-25 18:47:23 UTC
After connecting a second screen to the Thinkpad, the resolution was
1400x1050 + 1920x1200
The time changed to
Total time for 10000 iterations 327851
Per iteration: 32
Total time for 100 iterations 7357
Per iteration: 73


One CPU core was saturated during the test.

Operating system: Ubuntu 12.10, 64bit
CPU: Intel (Thinkpad), AMD (Desktop)
Graphics: ATI (Thinkpad), AMD (Desktop)
Desktop Environment: Gnome (they call it "classic" or "fallback session")

I think this issue has impact on various points of perceived speed of Netbeans IDE, maybe even the Netbeans Platform.
Comment 13 everflux 2012-10-25 20:19:57 UTC
During my testing the load was generated by the X server process, not the java process.
Maybe this is something that can not be fixed easily on that low layer.

Is caching the insets a workaround?
Comment 14 everflux 2012-10-26 13:24:35 UTC
It seems like "the other IDE" had a similar problem in dual screen setups with Java 7, as described in these issues:
http://youtrack.jetbrains.com/issue/IDEA-73128
http://youtrack.jetbrains.com/issue/IDEA-72050

It looks like they tweaked the getScreenInsets Method somehow.
According to their (Open Source) code they use a cache for Linux and Solaris environments for the insets:

http://grepcode.com/file/repository.grepcode.com/java/ext/com.jetbrains/intellij-idea/11.0/com/intellij/ui/ScreenUtil.java
Comment 15 Antonin Nebuzelsky 2012-10-26 14:34:39 UTC
Stando, can you comment on the notes above?
Comment 16 everflux 2012-10-30 20:24:48 UTC
I have tested a (very simplistic) cache, it indeed solves the problem.
It makes Netbeans fly like never before on my machine :)

I will attach a patch, while assuming it will not meet the coding conventions and/or quality of Netbeans, since I have no experience with the platform.
Comment 17 everflux 2012-10-30 20:27:03 UTC
Created attachment 126804 [details]
Cache calls to getScreenInsets for 10 seconds
Comment 18 Stanislav Aubrecht 2012-10-31 10:52:23 UTC
core-main d84cc3c44e7c

Thanks for nice and clean patch!
Comment 19 Quality Engineering 2012-11-02 03:28:13 UTC
Integrated into 'main-golden', will be available in build *201211020001* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main-golden/rev/d84cc3c44e7c
User: S. Aubrecht <saubrecht@netbeans.org>
Log: #219507 - cache usable screen bounds on some platforms to work around performance problems
Comment 20 Dusan Balek 2012-11-14 14:47:11 UTC
*** Bug 220370 has been marked as a duplicate of this bug. ***