Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 370758

Summary: [performance] Switching views: 30% of CPU goes on toolbar re-layout
Product: [Eclipse Project] Platform Reporter: Oleg Besedin <ob1.eclipse>
Component: UIAssignee: Oleg Besedin <ob1.eclipse>
Status: CLOSED DUPLICATE QA Contact:
Severity: normal    
Priority: P3 CC: ob1.eclipse, pwebster, remy.suen
Version: 4.2   
Target Milestone: ---   
Hardware: PC   
OS: Windows 7   
Whiteboard:

Description Oleg Besedin CLA 2012-02-06 14:21:32 EST
Testing switching between views, I noticed that about 30% of the time goes into toolbars being recreated.

The trigger point is:

ToolBarManagerRenderer
	private boolean processAddition(final MToolBar toolbarModel, ...
	...
		parentContext.runAndTrack(new RunAndTrack() {
	...
			record.updateVisibility(parentContext.getActiveLeaf());
			manager.update(true);
	...

Those RaTs use #getActiveLeaf() and, hence, are called every time active part changes. 

The call to ToolBarManager#update() disposes and re-creates the toolbar.

To reiterate, this code causes each and every toolbar to be completely re-created on every change in the active part, possibly more than one time, regardless of where any visibility changed occurred in toolbar elements.
Comment 1 Oleg Besedin CLA 2012-02-06 14:29:50 EST
There are several points to consider in there:

1) Do we really need to use active leaf context? Could we use context of the toolbar container instead?

2) Can we limit calls to ToolBarManager#update() to cases where we actually had some visibly changed?

3) We have multiple RaTs that are getting called more than once for every view switch. It seems that while debugging SDK I get about 10 RaTs each called 3 - 5 times. Both of those numbers seem high.
Comment 2 Oleg Besedin CLA 2012-02-06 16:53:43 EST
I made a patch and discovered that Remy fixed this on Thursday in bug 370337.

Well, great minds think alike :-).

*** This bug has been marked as a duplicate of bug 370337 ***
Comment 3 Remy Suen CLA 2012-02-06 17:02:23 EST
(In reply to comment #2)
> I made a patch and discovered that Remy fixed this on Thursday in bug 370337.

Go, go, performance fixes! :)