Bug 385394 - Performance issue regarding enabled state handling for menuContributions containing command (ToolItemUpdateTimer puts constant load on CPU)
Summary: Performance issue regarding enabled state handling for menuContributions cont...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.2   Edit
Hardware: PC Windows 7
: P3 major with 2 votes (vote)
Target Milestone: 4.4 M5   Edit
Assignee: Paul Webster CLA
QA Contact: Paul Webster CLA
URL:
Whiteboard:
Keywords: performance
: 360357 389221 392565 420310 (view as bug list)
Depends on:
Blocks: 392977 394341 425965
  Show dependency tree
 
Reported: 2012-07-18 07:41 EDT by Tobias Melcher CLA
Modified: 2018-03-21 04:58 EDT (History)
29 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tobias Melcher CLA 2012-07-18 07:41:06 EDT
Build Identifier: Version: 4.2.0 Build id: I20120608-1400

Hi colleagues,

we are using toolbar menu contributions pointing to a command like in following example:
 <extension
         point="org.eclipse.ui.menus">
      <menuContribution
          locationURI="toolbar:mytoolbar">
         <command
               commandId="mycommand" ...

Our handler implementation of the command overrides the methods setEnabled and isEnabled to calculate the enabled state of the toolbar entry. This implementation is not very efficient and can take some time (backend calls needed). 
We had no problems with this implementation in eclipse 3.7. With Eclipse 4.2, we are now running into performance problems; it looks like that the setEnabled method is called all 400 ms which looks very strange. Why is this method called so often? Is there another mechanism/possibility in Eclipse 4.2 to contribute toolbar menu entries where the setEnabled method is called only then when it is necessary (when current focus/selection/part is changed)?

With best regards,
Tobias



Reproducible: Always
Comment 1 Paul Webster CLA 2012-07-18 12:40:08 EDT
toolbar enablement is checked on a timer currently.  We're looking at a performance improvement for 4.3

PW
Comment 2 John Arthorne CLA 2012-09-11 10:35:09 EDT
*** Bug 389251 has been marked as a duplicate of this bug. ***
Comment 3 Lothar Werzinger CLA 2012-09-11 14:12:47 EDT
We have a scenario where a PropertyTester is called repeatedly in 4.2 and it worked fine in 3.7 I assume this is caused by the same issue as this bug report.
Comment 4 Wishwas Mohan CLA 2012-09-11 15:03:30 EDT
The problem that we are facing for the property tester seems to be related to the setEnabled problem. The method E4HandlerProxy.execute is called recursively when a selection is made in the viewer.
Comment 5 Nobody - feel free to take it CLA 2012-09-11 17:01:49 EDT
Paul I don't know if it is priority in the current situation but we should really consider the RAT approach for this story. I was working on some other issue and this timer solution to the enablemenet switch is really a pain. Of course the RunAndTrack will need bug 387299 taken care of but Tom told me we would need Oleg to take a look at it.
Comment 6 Paul Webster CLA 2012-10-02 15:58:26 EDT
*** Bug 389221 has been marked as a duplicate of this bug. ***
Comment 7 Paul Webster CLA 2012-10-22 07:55:47 EDT
*** Bug 392565 has been marked as a duplicate of this bug. ***
Comment 8 Paul Webster CLA 2013-04-29 12:27:23 EDT
This was introduced to for bug 340026.  I had hoped to turn most requests into RunAndTracks which would keep them up to date, based on the parameters used by the @CanExecute method.  But even in the test case from bug 340026 the tool item's enabled is determined from things not in the parameter list, so bug 396619 is not a viable solution.

This will need more thought.

PW
Comment 9 Markus Keller CLA 2013-08-21 11:01:47 EDT
A timer-based solution is not acceptable for a normal platform contribution mechanism. If this is really required in special occasions, then there must be an explicit opt-in mechanism for those who want to pay the price.
Comment 10 Paul Webster CLA 2014-01-14 13:29:25 EST
*** Bug 360357 has been marked as a duplicate of this bug. ***
Comment 11 Paul Webster CLA 2014-01-16 10:27:54 EST
Replace the timer with updates tied to the IEclipseContext variables: https://git.eclipse.org/r/20715

PW
Comment 13 Lars Vogel CLA 2014-01-16 14:13:41 EST
Thanks Paul. Just one clarification. How would I trigger the evaluation of the @CanExecute if the state of my tooltitems depend on non IEclipseContent variables?

E.g. button "Load server data" should be active if new data on the server is available?
Comment 14 Paul Webster CLA 2014-01-16 14:38:04 EST
(In reply to Lars Vogel from comment #13)
> 
> E.g. button "Load server data" should be active if new data on the server is
> available?

You'll have to open a new bug for that.  For Eclipse4 in theory you can set the "org.eclipse.ui.internal.services.EvaluationService.evaluate" variable to Boolean.TRUE or FALSE on the MApplication IEclipseContext, but that's not been formalized and it probably should be.

In the Workbench, re-evaluation can be requested using the IEvaluationService.

PW
Comment 15 Mickael Istria CLA 2014-01-17 05:50:37 EST
Thanks for this performance improvement. Just out of curiosity, do you use a tool or do you have a trick to measure the effect of such change on performance.
I know there used to be some global performance tests, but I'm more interested in finding way to benchmark effect of an individual change.
Comment 16 Paul Webster CLA 2014-01-17 06:05:54 EST
(In reply to Mickael Istria from comment #15)
> Thanks for this performance improvement. Just out of curiosity, do you use a
> tool or do you have a trick to measure the effect of such change on
> performance.

We haven't done our performance pass yet (in the past we used yorkit) and our perf tests will hopefully be up some time in M6.

This will remove the timer, the constant load on the CPU, and hopefully prevent bugs like bug 420310 :-)

PW
Comment 17 Paul Webster CLA 2014-01-17 06:06:27 EST
*** Bug 420310 has been marked as a duplicate of this bug. ***
Comment 18 Paul Webster CLA 2014-01-21 14:21:22 EST
In 4.4.0.I20140120-2000

PW
Comment 19 Martin Oberhuber CLA 2014-05-16 05:44:45 EDT
CQ:WIND00-WB4-3452