Bug 232489 - [Contributions] Switching editors updates TooItems updated due to calls to org.eclipse.ui.menus.CommandContributionItem.updateIcons()
Summary: [Contributions] Switching editors updates TooItems updated due to calls to or...
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.4   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.4 RC3   Edit
Assignee: Paul Webster CLA
QA Contact:
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks: 232655
  Show dependency tree
 
Reported: 2008-05-16 08:47 EDT by Dani Megert CLA
Modified: 2008-05-29 10:46 EDT (History)
4 users (show)

See Also:
Mike_Wilson: pmc_approved+
bokowski: review+
emoffatt: review+


Attachments
Profiler Data (10.60 KB, application/zip)
2008-05-16 08:50 EDT, Dani Megert CLA
no flags Details
Change to CommandContributionItem (1.06 KB, patch)
2008-05-26 14:08 EDT, Paul Webster CLA
no flags Details | Diff
CommandContributionItem v02 (1.06 KB, patch)
2008-05-28 10:20 EDT, Paul Webster CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Dani Megert CLA 2008-05-16 08:47:05 EDT
I20080515-2000.

When switching between two editors in 3.3 there were no calls to org.eclipse.ui.menus.CommandContributionItem.updateIcons(). Now in 3.4 this method is called 9 times due to CommandEvent/s being handled (call see stack below). This causes SWT ToolItems to be update/redrawn.

This is responsible for 1/3 of the regression seen in JDT Text editor activation tests. On my machine this is 40-60 ms.


Thread [main] (Suspended (breakpoint at line 303 in CommandContributionItem$2))	
	CommandContributionItem$2.commandChanged(CommandEvent) line: 303	
	Command$1.run() line: 511	
	SafeRunner.run(ISafeRunnable) line: 37	
	Command.fireCommandChanged(CommandEvent) line: 506	
	Command.setHandler(IHandler) line: 995	
	HandlerAuthority.updateCommand(String, IHandlerActivation) line: 457	
	HandlerAuthority.deactivateHandler(IHandlerActivation) line: 292	
	HandlerService.deactivateHandler(IHandlerActivation) line: 148	
	SlaveHandlerService.deactivateHandler(IHandlerActivation) line: 205	
	EditorActionBars(SubActionBars).setGlobalActionHandler(String, IAction) line: 523	
	TextEditorActionContributor.doSetActiveEditor(IEditorPart) line: 101	
	TextEditorActionContributor.setActiveEditor(IEditorPart) line: 143	
	EditorActionBars.partChanged(IWorkbenchPart) line: 335	
	WorkbenchPage$3.run() line: 628	
	SafeRunner.run(ISafeRunnable) line: 37	
	Platform.run(ISafeRunnable) line: 880	
	WorkbenchPage.activatePart(IWorkbenchPart) line: 617	
	WorkbenchPage.setActivePart(IWorkbenchPart) line: 3451	
	WorkbenchPage.requestActivation(IWorkbenchPart) line: 2998	
	EditorPane(PartPane).requestActivation() line: 272	
	EditorPane.requestActivation() line: 98	
	EditorPane(PartPane).setFocus() line: 318	
	EditorPane.setFocus() line: 127	
	EditorStack(PartStack).presentationSelectionChanged(IPresentablePart) line: 846	
	PartStack.access$1(PartStack, IPresentablePart) line: 829	
	PartStack$1.selectPart(IPresentablePart) line: 139	
	TabbedStackPresentation$1.handleEvent(TabFolderEvent) line: 133	
	DefaultTabFolder(AbstractTabFolder).fireEvent(TabFolderEvent) line: 267	
	DefaultTabFolder(AbstractTabFolder).fireEvent(int, AbstractTabItem) line: 276	
	DefaultTabFolder.access$1(DefaultTabFolder, int, AbstractTabItem) line: 1	
	DefaultTabFolder$2.handleEvent(Event) line: 87	
	EventTable.sendEvent(Event) line: 84	
	CTabFolder(Widget).sendEvent(Event) line: 1002	
	CTabFolder(Widget).sendEvent(int, Event, boolean) line: 1026	
	CTabFolder(Widget).sendEvent(int, Event) line: 1011	
	CTabFolder(Widget).notifyListeners(int, Event) line: 769	
	CTabFolder.setSelection(int, boolean) line: 3238	
	CTabFolder.onMouse(Event) line: 2013	
	CTabFolder$1.handleEvent(Event) line: 316	
	EventTable.sendEvent(Event) line: 84	
	CTabFolder(Widget).sendEvent(Event) line: 1002	
	Display.runDeferredEvents() line: 3801	
	Display.readAndDispatch() line: 3400	
	Workbench.runEventLoop(Window$IExceptionHandler, Display) line: 2387	
	Workbench.runUI() line: 2351	
	Workbench.access$4(Workbench) line: 2203	
	Workbench$5.run() line: 493	
	Realm.runWithDefault(Realm, Runnable) line: 288	
	Workbench.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 488	
	PlatformUI.createAndRunWorkbench(Display, WorkbenchAdvisor) line: 149	
	IDEApplication.start(IApplicationContext) line: 112	
	EclipseAppHandle.run(Object) line: 193	
	EclipseAppLauncher.runApplication(Object) line: 110	
	EclipseAppLauncher.start(Object) line: 79	
	EclipseStarter.run(Object) line: 379	
	EclipseStarter.run(String[], Runnable) line: 179	
	NativeMethodAccessorImpl.invoke0(Method, Object, Object[]) line: not available [native method]	
	NativeMethodAccessorImpl.invoke(Object, Object[]) line: 39	
	DelegatingMethodAccessorImpl.invoke(Object, Object[]) line: 25	
	Method.invoke(Object, Object...) line: 597	
	Main.invokeFramework(String[], URL[]) line: 549	
	Main.basicRun(String[]) line: 504	
	Main.run(String[]) line: 1236	
	Main.main(String[]) line: 1212
Comment 1 Dani Megert CLA 2008-05-16 08:50:13 EDT
Created attachment 100631 [details]
Profiler Data
Comment 2 Dani Megert CLA 2008-05-16 11:45:24 EDT
This also slows down editor opening (tests).
Comment 3 Paul Webster CLA 2008-05-26 14:08:33 EDT
Created attachment 102018 [details]
Change to CommandContributionItem

This changes the updateIcons to only update on creation or if an Icon is deliberately set.

Below is for information only, it was taken on linux where the system doesn't exhibit the same slowdown w.r.t. icons.  I'll get a windows box tomorrow to test.

My baseline:
  Elapsed Process:        9.18s         (95% in [8.91s, 9.46s])        Measurable effect: 538ms (0.7 SDs) (required sample size for an effect of 5% of mean: 42)
  CPU Time:               2.35s         (95% in [2.12s, 2.58s])        Measurable effect: 450ms (0.7 SDs) (required sample size for an effect of 5% of mean: 442)

With icon change:
  Elapsed Process:        9.73s         (95% in [9.46s, 10s])          Measurable effect: 521ms (0.7 SDs) (required sample size for an effect of 5% of mean: 35)
  CPU Time:               2.17s         (95% in [1.96s, 2.38s])        Measurable effect: 412ms (0.7 SDs) (required sample size for an effect of 5% of mean: 437)
Comment 4 Paul Webster CLA 2008-05-28 10:20:29 EDT
Created attachment 102377 [details]
CommandContributionItem v02

Only call updateIcons() on creation or when the icon is set.

PW
Comment 5 Paul Webster CLA 2008-05-28 10:41:05 EDT
This change to updateIcons() resulted in a 7% savings in my SwitchEditor tests.

  Elapsed Process:         3.5s         (95% in [3.43s, 3.56s])        Measurable effect: 135ms (0.3 SDs)
  CPU Time:               3.27s         (95% in [3.2s, 3.33s])         Measurable effect: 134ms (0.3 SDs)

  Elapsed Process:        3.25s         (95% in [3.19s, 3.31s])        Measurable effect: 123ms (0.3 SDs)
  CPU Time:               3.01s         (95% in [2.95s, 3.07s])        Measurable effect: 125ms (0.3 SDs)

PW
Comment 6 Paul Webster CLA 2008-05-28 10:45:32 EDT
I think this is worth submitting for RC3
Comment 7 Eric Moffatt CLA 2008-05-28 12:39:44 EDT
+1 no calls at all with the fix (it also used to spam the method on activation...), nice

Comment 8 Boris Bokowski CLA 2008-05-29 09:34:08 EDT
Paul explained to me what the patch does. Looks good.
Comment 9 Paul Webster CLA 2008-05-29 10:46:23 EDT
Released for I20080529-1300
PW