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.
First invocation is exceptionally slow.
*** Issue 27539 has been marked as a duplicate of this issue. ***
Mila Metelka wrote in issue 27539: The performance of opening the java editor popup menu mainly suffers from displaying of the "Goto Source" and "Goto Declaration" items. For them to be displayed they current caret context needs to be evaluated by the code completion which can be slow especially in cases when the code completion was not initialized yet.
First invocation of context menu takes about 2.5 sec (in current dev builds, ColorPreview.java, at the very beginning of the file). Eliminating "Goto Declaration" and "Goto Source" actions reduces the time to cca 900ms. Invoking menu on DataObject first (ColorPreview.java) gives about 650ms. Still too much for a context menu...
The editor's popup menu also displays some additional actions, ToolsAction etc. It should be possible to disable individual actions and see the invocation differences.
Just for reference - editor context menu performance was already being solved year ago - see issue 15794.
Dafe's measurements - testing conditions: PC Dell Pentium III, 600Mhz, 512 MB memory, JDK 1.4.1, Netbeans Main trunk build, mounted sampledir local filesystem, opened 8 java source files, 3 plain text files. times in milliseconds, first number shows first invocation, followed by subsequent invocations. 3234, 94, 94, 140
Marian's measurement (time in milliseconds): conditions: - SUN UltraSparc60 / 512 MB RAM / Solaris 5.8 / CDE - JDK1.4.1(01) - [nb_dev](200211140100) , MDI - mounted sampledir bring editor popup menu on positions (cursor - <>): ColorPreview - "class <>ColorPreview" 2774 84 110 ColorPreview - "javax.swing.JPa<>nel" 3755 112 99 Test cases are described on page : http://performance.netbeans.org/qa/TestSuites.html#popup_menu_source_editor_java_file
I think one way (if possible) to improve this is to try to have a static context menu created just once for each file (automatically after opening the file in the editor). The "Goto..." actions would not be enabled according to context (caret position), but permanently, doing nothing if not valid. The question is whether the menu can be static (have fixed content), and whether there is a reasonable moment when to pre-create the menu (should be when a file is displayed or focused, not just when opened).
Radim's measurement: PIII/800MHz, Linux (2.4.17), 512MB NetBeans IDE Dev (Build 200211180100) Java; VM; Vendor = 1.4.1; Java HotSpot(TM) Client VM 1.4.1-b21; Sun Microsystems Inc. mounted sample dir and openide/src directory 2. Editor context menu 5270, 310, 217, 212 2956, 247, 240, 198
Should wait cursor be set while constructing & showing the context menu?
IMO once we no longer wait for the code completion to evaluate the context menu could popup fairly quickly so the wait cursor would not be necessary. We'll try and see.
fixed in [maintrunk] The slow responsivness was caused by slow "Go to source" and "Margin" menu item. During the first invocation of the context menu the code completion DB is checked, whether it is initialized. If not, initialization runs in RequestProcessor and the menu item is displayed without the name of the class. It could be possible, that first invocation of the menu can be faster than further, because in the next invocations the "Go to source" menu item retrieves the name of searched class and the completion query is performing. Please, try to make some measurements to verify it. If the responsiveness will not be sufficient, querying will be omitted. /cvs/editor/libsrc/org/netbeans/editor/Annotations.java,v <-- Annotations.java new revision: 1.10; previous revision: 1.9 /cvs/editor/src/org/netbeans/modules/editor/java/Bundle.properties,v <-- Bundle.properties new revision: 1.44; previous revision: 1.43 /cvs/editor/src/org/netbeans/modules/editor/java/JCStorage.java,v <-- JCStorage.java new revision: 1.43; previous revision: 1.42 /cvs/editor/src/org/netbeans/modules/editor/java/JavaKit.java,v <-- JavaKit.java new revision: 1.48; previous revision: 1.47 done
The responsiveness is much better (first invocation went down from cca 2500 ms to 600ms), but it's still not quite perfect. I also noticed the subsequent invocations can be slow - most probably caused by computing the source name for the Goto Source action. I think it is bad to slow whole context menu just for one menu item (which the user might not be interested in at all). What about to create a "Goto" submenu with "Declaration" and "Source" items? Then the slowness would appear only if user really wanted the Goto Source action (clicked on the Goto submenu). HIE opinion? I've tried to eliminate the source name computation and the first menu invocation went down to 500ms - not so big improvement - but the subsequent invocations were much more fluent. So I think it's worth trying.
Created attachment 8626 [details] Done. Waiting for UI approval before commiting.
I would like to ask about situation, when only one subitem (e.g. Go to Declaration) will be active. Does it mean, that First Context menu will contain "Go to" item a second one only "Go to Declaration" item ? It's curious a bit. OR will second context menu include both items always (Go to Declaration and Go to Source), but some of them will be disabled ?
There is only "go to declaration" subitem under "Go to" item, if "go to source" is disabled. I can change it to "disabled go to source" behaviour. Would it be better?
fixed in [maintrunk] in accordance with UI team comments /cvs/editor/libsrc/org/netbeans/editor/Annotations.java,v <-- Annotations.java new revision: 1.11; previous revision: 1.10 /cvs/editor/src/org/netbeans/modules/editor/NbEditorKit.java,v <-- NbEditorKit.java new revision: 1.37; previous revision: 1.36 /cvs/editor/src/org/netbeans/modules/editor/java/Bundle.properties,v <-- Bundle.properties new revision: 1.45; previous revision: 1.44 /cvs/editor/src/org/netbeans/modules/editor/java/JavaKit.java,v <-- JavaKit.java new revision: 1.49; previous revision: 1.48 /cvs/editor/src/org/netbeans/modules/editor/resources/layer.xml,v <-- layer.xml new revision: 1.32; previous revision: 1.31
OK, after the last commit, the first context menu invocation time was around 500ms (dev build 20030127, 733MHz P3, W2K). Implementing warm-up in issue 27769 helped significantly, so the time is now around 250ms (dev build 20030128). Quite good improvement comparing to the original 2.5s I think...
Marian's measurement (time in milliseconds): conditions: - SUN UltraSparc60 / 1024 MB RAM / Solaris 5.8 / CDE - JDK1.4.1(01) - [nb_dev](200302040100) , MDI - mounted sampledir bring editor popup menu on positions (cursor - <>): ColorPreview - "class <>ColorPreview" 1018 143 266 ColorPreview - "javax.swing.JPa<>nel" 1016 190 223
I'm reopening to suggest new wording in the menu. Go to -> Go To [we have an editorial guideline that says all prepositions are capitalized if they are the last word] Go to Source -> Source Go to Declaration -> Declaration "Go To" doesn't need to be repeated. If possible, I'd like to see this change be made (I'm speaking on behalf of Docs). Do others agree?
I agree. I'll do the change and integrate it.
Done. /cvs/editor/libsrc/org/netbeans/editor/Bundle.properties new revision: 1.31; previous revision: 1.30 /cvs/editor/src/org/netbeans/modules/editor/java/Bundle.properties new revision: 1.46; previous revision: 1.45
integrated into [prj40_prototype] also. /cvs/java/completion/src/org/netbeans/modules/java/completion/updater/Attic/JCStorage.java,v <-- JCStorage.java new revision: 1.1.2.1.2.2.2.6; previous revision: 1.1.2.1.2.2.2.5 /cvs/java/editor/src/org/netbeans/modules/editor/java/Attic/Bundle.properties,v <-- Bundle.properties new revision: 1.1.2.1.4.1; previous revision: 1.1.2.1 /cvs/java/editor/src/org/netbeans/modules/editor/java/Attic/JavaKit.java,v <-- JavaKit.java new revision: 1.1.2.1.2.1.2.5; previous revision: 1.1.2.1.2.1.2.4 /cvs/java/editor/src/org/netbeans/modules/java/editor/resources/Attic/layer.xml,v <-- layer.xml new revision: 1.1.2.1.4.3; previous revision: 1.1.2.1.4.2 /cvs/editor/libsrc/org/netbeans/editor/Annotations.java,v <-- Annotations.java new revision: 1.9.10.1; previous revision: 1.9 /cvs/editor/libsrc/org/netbeans/editor/Bundle.properties,v <-- Bundle.properties new revision: 1.29.18.2; previous revision: 1.29.18.1 /cvs/editor/src/org/netbeans/modules/editor/NbEditorKit.java,v <-- NbEditorKit.java new revision: 1.35.10.3; previous revision: 1.35.10.2