Bug 520720 - [Progress] Update progress label asynchronously
Summary: [Progress] Update progress label asynchronously
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.7   Edit
Hardware: All All
: P3 normal (vote)
Target Milestone: 4.8 M3   Edit
Assignee: Karsten Thoms CLA
QA Contact:
URL:
Whiteboard:
Keywords: noteworthy, performance
Depends on:
Blocks:
 
Reported: 2017-08-08 19:12 EDT by Karsten Thoms CLA
Modified: 2017-10-13 03:30 EDT (History)
5 users (show)

See Also:
mistria: pmc_approved+


Attachments
Screenshot: Profiler (944.06 KB, image/png)
2017-08-08 19:12 EDT, Karsten Thoms CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Karsten Thoms CLA 2017-08-08 19:12:41 EDT
Created attachment 269751 [details]
Screenshot: Profiler

When the progress monitor is updated a lot of times in a tight loop, a reasonable amount of time is spent updating it and slowing down UI. This effect can be observed for example when having a Git repo in the repositories view and use the context action "Import Projects". The import wizard will start scanning the git repository and the currently processed files are displayed.

Attached profiler screenshot shows that ~2 sec is spent updating the label (reference repository used is lsp4e).

Another place where ProgressMonitorPart.updateLabel() is when projects are deleted from the workspace.

When executing the code org.eclipse.jface.wizard.ProgressMonitorPart.updateLabel() asynchronously the performance of the dialog improves reasonable. The "negative" effect is now that the progress label is updated so fast that no single entry could be read really.
Comment 1 Eclipse Genie CLA 2017-08-08 19:17:17 EDT
New Gerrit change created: https://git.eclipse.org/r/102730
Comment 2 Mikaël Barbero CLA 2017-08-09 03:37:01 EDT
We've faced similar issues in bug 445802 and bug 500332. While you say that executing the update asynchronously improves the situation, I think that a better way to handle this issue is to introduce throttling (like we did in bug 500332). If you want, you can easily reause the throttler utility class (https://git.eclipse.org/c/platform/eclipse.platform.ui.git/tree/bundles/org.eclipse.ui.workbench/Eclipse%20UI/org/eclipse/ui/internal/progress/Throttler.java)
Comment 3 Karsten Thoms CLA 2017-08-09 07:50:32 EDT
This is helpful and would be the right way to go, thanks for the pointer.

But Throttler is in org.eclipse.ui.workbench and ProgressMonitor in org.eclipse.platform.ui. I think this would be an undesired dependency? And copying it? How about moving the class to platform.ui and make the dependency the other way around (o.e.ui.workbench depending on o.e.platform.ui, which isn't the case yet)? Please advise.
Comment 4 Mikaël Barbero CLA 2017-08-09 08:52:11 EDT
I guess the best solution would be to move the Throttler class to jface (maybe make it a public utility class in org.eclipse.jface.util?) and to change the usage in org.eclipse.ui.workbench. 

Is anyone against such a thing? I could do this change and then you could use Throttler from the ProgressMonitorPart.
Comment 5 Eclipse Genie CLA 2017-08-09 15:12:47 EDT
New Gerrit change created: https://git.eclipse.org/r/102810
Comment 6 Eclipse Genie CLA 2017-08-09 15:12:51 EDT
New Gerrit change created: https://git.eclipse.org/r/102809
Comment 7 Eclipse Genie CLA 2017-08-09 15:12:55 EDT
New Gerrit change created: https://git.eclipse.org/r/102811
Comment 8 Mikaël Barbero CLA 2017-08-10 02:14:38 EDT
What about the performance with the throttler? Do you see any improvement? I think you can try to set the timer to 16ms (to reach 60FPS). In my experience, it does not impact the performance.
Comment 9 Karsten Thoms CLA 2017-08-10 09:24:22 EDT
It has the desired effect, i.e. the dialogs improved performance. Other usages of Throttler also used 100ms and I think this value is OK. No one can recognize changing labels at 60 FPS.
Comment 10 Mikaël Barbero CLA 2017-08-10 10:22:45 EDT
Cool, let's wait for feedbacks about the new public API in JFace. Dani, Lars, any opinion?
Comment 11 Mickael Istria CLA 2017-09-07 03:03:08 EDT
Does changing a public method from synchronous to asynchronous enable a specific API policy?
Comment 12 Andrey Loskutov CLA 2017-09-07 03:07:44 EDT
(In reply to Mickael Istria from comment #11)
> Does changing a public method from synchronous to asynchronous enable a
> specific API policy?

Just my 2 cents: Possible breaking behavior change. But it also depends on what the javadoc says and how severe is the behavior change for the client.
Comment 13 Mickael Istria CLA 2017-09-12 03:00:37 EDT
(In reply to Andrey Loskutov from comment #12)
> (In reply to Mickael Istria from comment #11)
> > Does changing a public method from synchronous to asynchronous enable a
> > specific API policy?
> Just my 2 cents: Possible breaking behavior change. But it also depends on
> what the javadoc says and how severe is the behavior change for the client.

Ok, let's ask for PMC opinion on this one.
Comment 14 Mickael Istria CLA 2017-09-13 03:45:11 EDT
Wouldn't it be simpler, from API POV, to have the updateLabel method (protected API) remain as it, and to introduce a "queueUpdateLabel" or similar method that would go through the Throttler and make all usage of the updateLabel() method in the classes replaced by this queueUpdateLabel() ?
I think it would be the same behavior change but wouldn't affect API, so it should be OK to merge it in a minor version.
Comment 15 Karsten Thoms CLA 2017-09-13 04:32:57 EDT
Good idea! However, we still need the Throttler move first.
Comment 16 Dani Megert CLA 2017-10-03 10:14:45 EDT
(In reply to Mickael Istria from comment #14)
> Wouldn't it be simpler, from API POV, to have the updateLabel method
> (protected API) remain as it, and to introduce a "queueUpdateLabel" or
> similar method that would go through the Throttler and make all usage of the
> updateLabel() method in the classes replaced by this queueUpdateLabel() ?
> I think it would be the same behavior change but wouldn't affect API, so it
> should be OK to merge it in a minor version.

See my comment in the Gerrit change.
Comment 17 Mickael Istria CLA 2017-10-04 02:56:38 EDT
(Fixing Dani pmc_reviewed flag as per discussion on Gerrit)
Comment 18 Dani Megert CLA 2017-10-04 09:36:26 EDT
(In reply to Mickael Istria from comment #17)
> (Fixing Dani pmc_reviewed flag as per discussion on Gerrit)

Fine with me, but strange that you can do that ;-).
Comment 19 Mickael Istria CLA 2017-10-04 09:38:47 EDT
(In reply to Dani Megert from comment #18)
> Fine with me, but strange that you can do that ;-).

It worked but it did change the owner of the flag from you to me (which wasn't desired).
Comment 21 Eclipse Genie CLA 2017-10-05 09:25:44 EDT
New Gerrit change created: https://git.eclipse.org/r/106295
Comment 24 Mickael Istria CLA 2017-10-05 16:28:06 EDT
Thank you Karsten!
I'm actually not sure this has to get into the N&N as a dedicated entry. Maybe it's better to add a note about the various performance issue in the final N&N for Photon. What do you think?
Comment 25 Karsten Thoms CLA 2017-10-06 02:22:51 EDT
I agree to collect performance news to one. Usually you have screenshots in N&N for separate entries, and this is nothing you can capture in a screenshot. We could leave the keywords and select them in a query later.
Comment 26 Lars Vogel CLA 2017-10-13 00:54:46 EDT
I suggest adding the new Throttler API to the N&N M3. Other projects might want to use it also to improve performance.
Comment 27 Eclipse Genie CLA 2017-10-13 03:19:19 EDT
New Gerrit change created: https://git.eclipse.org/r/109963