Bug 561217 - Performance problem with large layouts in RCP applications on a Windows PC
Summary: Performance problem with large layouts in RCP applications on a Windows PC
Status: RESOLVED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 4.13   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: Platform-UI-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2020-03-18 10:54 EDT by Julia Kurde CLA
Modified: 2020-04-20 05:12 EDT (History)
5 users (show)

See Also:


Attachments
RCP 3.x application showing the problem (64.20 KB, application/octet-stream)
2020-03-18 10:54 EDT, Julia Kurde CLA
no flags Details
Dump: Open Editor (18.03 KB, text/plain)
2020-03-24 09:09 EDT, Julia Kurde CLA
no flags Details
VisualVM profiling: Open Editor (125.35 KB, image/png)
2020-04-02 10:01 EDT, Julia Kurde CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Julia Kurde CLA 2020-03-18 10:54:34 EDT
Created attachment 282132 [details]
RCP 3.x application showing the problem

Hello, I'd like to report a performance problem with large layouts in RCP applications on a Windows PC.

My example layout (see attachment) has a size of 2550 x 7200 pixels and contains about 1300 children (Texts and Labels).

When it is run as a simple Java Application, independent of any RCP application, there is no problem.

But if an editor in an RCP application is showing this layout it is extremely slow: it takes several seconds to open, it often freezes when it is scrolled and when switching between editors it can even cause the whole application to hang itself.

Where I tested this layout so far:
* Java Application (no RCP)
=> No Problem

* 3.x RCP in Eclipse for RCP and RAP Developers
Indigo Service Release 2, Build id: 20120216-1857
=> No Problem

* 3.x RCP in Eclipse for RCP and RAP Developers
2019-09 R (4.13.0), Build id: 20190917-1200
=> slow as described above

* 4.x RCP in Eclipse for RCP and RAP Developers
2019-09 R (4.13.0), Build id: 20190917-1200
=> slow as described above

These RCP applications are based on the corresponding Examples available in the New Project Wizard.

So obviously there are some changes between the Eclipse version from 2012 and 2019 (in between versions not tested). 

This problem occurs on Windows systems, not on a Linux system (Mac not tested).

In the attachment there is a RCP 3.x application showing the problem.
The layout snipped to be run independently as a Java Application is in package test01.test.
(I could also add the RCP 4.x application but it seems I can only add one attachment.)

Thanks for caring about this problem!
Comment 1 Lars Vogel CLA 2020-03-18 10:56:22 EDT
Can you activate UI freeze monitor and post stack traces during the freeze? https://www.vogella.com/tutorials/EclipsePerformance/article.html#eclipse_uifreeze_monitor
Comment 2 Thomas Schindl CLA 2020-03-18 11:01:49 EDT
If I had to guess - i'd say this is because of the CSS - turn of CSS and it will be as fast as before
Comment 3 Julia Kurde CLA 2020-03-18 11:06:00 EDT
It's not the '-cssTheme none' option.
Sorry not mentioning it.

It made a visible difference on Linux, where it was anyway faster also without that option.
But on Windows this option does not make any difference.
Comment 4 Julia Kurde CLA 2020-03-21 08:07:50 EDT
(In reply to Lars Vogel from comment #1)
> Can you activate UI freeze monitor and post stack traces during the freeze?
> https://www.vogella.com/tutorials/EclipsePerformance/article.
> html#eclipse_uifreeze_monitor

This monitor is activated with default values (Warning: 500 ms, Error: 1000 ms), but the Error Log view does not show any UI freeze messages.
Although I can see the 'Not Responding' message in the window title of the application.
Comment 5 Rolf Theunissen CLA 2020-03-23 12:49:15 EDT
(In reply to jule from comment #4)
> (In reply to Lars Vogel from comment #1)
> > Can you activate UI freeze monitor and post stack traces during the freeze?
> > https://www.vogella.com/tutorials/EclipsePerformance/article.
> > html#eclipse_uifreeze_monitor
> 
> This monitor is activated with default values (Warning: 500 ms, Error: 1000
> ms), but the Error Log view does not show any UI freeze messages.
> Although I can see the 'Not Responding' message in the window title of the
> application.

If the automatic generation of stack traces is not working, you can try to manually create the stack traces. Check the following page for instructions:
https://wiki.eclipse.org/How_to_report_a_deadlock
Comment 6 Julia Kurde CLA 2020-03-24 09:09:06 EDT
Created attachment 282206 [details]
Dump: Open Editor
Comment 7 Thomas Schindl CLA 2020-03-24 09:12:31 EDT
well did you try attaching flight recorder to see where time is spent?
Comment 8 Julia Kurde CLA 2020-03-24 09:15:13 EDT
(In reply to jule from comment #6)
> Created attachment 282206 [details]
> Dump: Open Editor

(Somehow the text below was not submitted the first time)
So what I did: Export the project as RCP product, start the executable with a terminal and hitting Ctrl+Break to get a stack trace at certain points:

- During editor open directly after the createPartControl method had finished
- During editor open shortly before the editor is actually open
- During no response after scrolling
- During switching from the empty editor to the editor in question
- During switching from the editor in question to the empty editor

Which of these is of interest for you? 

The eclipse.ini file of the exported application looks like this:
-consoleLog
-cssTheme none
-vmargs
-XX:+HeapDumpOnOutOfMemoryError
Comment 9 Julia Kurde CLA 2020-03-24 09:46:55 EDT
(In reply to Thomas Schindl from comment #7)
> well did you try attaching flight recorder to see where time is spent?

No, never used this tool. It seems it is only available with a commercial Java-Version.
Comment 10 Thomas Schindl CLA 2020-03-24 11:27:10 EDT
no it is not anymore, it got opensourced - anyways you need so profiler to see where the time is really spend
Comment 11 Rolf Theunissen CLA 2020-03-24 11:45:31 EDT
From the attached trace its seems that the CSS engine is not disabled.

Could you try to disable the CSS engine via plugin_customization.ini by adding:

org.eclipse.e4.ui.workbench.renderers.swt/themeEnabled=false
Comment 12 Julia Kurde CLA 2020-03-24 12:06:39 EDT
(In reply to Rolf Theunissen from comment #11)
> From the attached trace its seems that the CSS engine is not disabled.
> 
> Could you try to disable the CSS engine via plugin_customization.ini by
> adding:
> 
> org.eclipse.e4.ui.workbench.renderers.swt/themeEnabled=false

I added this line to plugin_customization.ini in 
plugins\org.eclipse.platform_4.13.0.v20190916-1045
of the eclipse install directory.

But there is no change in performance nor in the stack trace.
Comment 13 Julia Kurde CLA 2020-03-24 12:08:09 EDT
(In reply to Thomas Schindl from comment #10)
> no it is not anymore, it got opensourced - anyways you need so profiler to
> see where the time is really spend

Which tool do you recommend and where can I get it?
Comment 14 Julia Kurde CLA 2020-04-02 10:01:35 EDT
Created attachment 282319 [details]
VisualVM profiling: Open Editor

From the result of the CPU sampling in VisualVM the time consuming call is
org.eclipse.swt.internal.win32.OS.GetProp[native] ()
which is called by 
org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.applyStyles ()

So the CSS styling is still there (as already seen in the dump before) although

* The application is run with the '-cssTheme none' argument 
* Eclipse has the line
org.eclipse.e4.ui.workbench.renderers.swt/themeEnabled=false
in
plugins\org.eclipse.platform_4.13.0.v20190916-1045\plugin_customization.ini
Comment 15 Julia Kurde CLA 2020-04-02 11:27:31 EDT
Just for comparison: 
On a linux machine the '-cssTheme none' argument works:
Without it there are method calls like
org.eclipse.e4.ui.css.core.impl.engine.AbstractCSSEngine.applyStyles ()
in the CPU sampling (consuming only 0.4% of the total time).
When setting this css none option there are no calls from 
org.eclipse.e4.ui.css any more.
Comment 16 Mike Marchand CLA 2020-04-10 11:42:52 EDT
Hi Julie, I believe this was fixed in 4.15 (see bug #558227).

The issue was also discussed on StackOverflow
https://stackoverflow.com/questions/58451881/eclipse-4-ui-slow-css-engine-called-too-often-windows
Comment 17 Julia Kurde CLA 2020-04-14 06:58:55 EDT
(In reply to Mike Marchand from comment #16)
> Hi Julie, I believe this was fixed in 4.15 (see bug #558227).
> 
> The issue was also discussed on StackOverflow
> https://stackoverflow.com/questions/58451881/eclipse-4-ui-slow-css-engine-
> called-too-often-windows

Yes it's fixed in 4.15.
Perfect!!
Comment 18 Lars Vogel CLA 2020-04-14 07:10:38 EDT
Still strange that '-cssTheme none' still does perform some work on Window. 

Jule, I'm a Linux user, can you test the upcoming Gerrit on Windows and tell me if that improves performance?
Comment 19 Lars Vogel CLA 2020-04-14 07:15:50 EDT
(In reply to Lars Vogel from comment #18)
> Still strange that '-cssTheme none' still does perform some work on Window. 
> 
> Jule, I'm a Linux user, can you test the upcoming Gerrit on Windows and tell
> me if that improves performance?

https://git.eclipse.org/r/#/c/160897/
Comment 20 Julia Kurde CLA 2020-04-14 08:08:37 EDT
(In reply to Lars Vogel from comment #19)
> (In reply to Lars Vogel from comment #18)
> > Still strange that '-cssTheme none' still does perform some work on Window. 
> > 
> > Jule, I'm a Linux user, can you test the upcoming Gerrit on Windows and tell
> > me if that improves performance?
> 
> https://git.eclipse.org/r/#/c/160897/

Lars, actually, I have no idea how to do that! I never used Gerrit before.
I'll try to work with the "How to Contribute" instructions and see how far I get...
Comment 21 Lars Vogel CLA 2020-04-14 08:51:47 EDT
(In reply to jule from comment #20)
> (In reply to Lars Vogel from comment #19)
> > (In reply to Lars Vogel from comment #18)
> > > Still strange that '-cssTheme none' still does perform some work on Window. 
> > > 
> > > Jule, I'm a Linux user, can you test the upcoming Gerrit on Windows and tell
> > > me if that improves performance?
> > 
> > https://git.eclipse.org/r/#/c/160897/
> 
> Lars, actually, I have no idea how to do that! I never used Gerrit before.
> I'll try to work with the "How to Contribute" instructions and see how far I
> get...

See https://www.vogella.com/tutorials/EclipsePlatformDevelopment/article.html#exericse-eclipse-user-creation-and-gerrit-server-configuration After this setup use Ctrl+3 Fetch from Gerrit and enter the Gerrit change ID (160897) in the dialog. This will fetch the change. If you add the workspace plug-in to your runtime, the updated version will be used.
Comment 22 Julia Kurde CLA 2020-04-14 08:59:07 EDT
Maybe this information is already helpful:

With Version 4.15 (on Windows) I don't see any calls from 
org.eclipse.e4.ui.css
in the VisualVM CPU sampling when opening an editor,
no matter if the '-cssTheme none' option is set or not.
Comment 23 Lars Vogel CLA 2020-04-14 09:10:15 EDT
(In reply to jule from comment #22)
> Maybe this information is already helpful:
> 
> With Version 4.15 (on Windows) I don't see any calls from 
> org.eclipse.e4.ui.css
> in the VisualVM CPU sampling when opening an editor,
> no matter if the '-cssTheme none' option is set or not.

Can you put a breakpoint into PartRenderingEngine and see if the CSS Engine is still called? See https://git.eclipse.org/r/#/c/160897/1/bundles/org.eclipse.e4.ui.workbench.swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
Comment 24 Julia Kurde CLA 2020-04-14 09:31:31 EDT
(In reply to Lars Vogel from comment #23)
> (In reply to jule from comment #22)
> > Maybe this information is already helpful:
> > 
> > With Version 4.15 (on Windows) I don't see any calls from 
> > org.eclipse.e4.ui.css
> > in the VisualVM CPU sampling when opening an editor,
> > no matter if the '-cssTheme none' option is set or not.
> 
> Can you put a breakpoint into PartRenderingEngine and see if the CSS Engine
> is still called? See
> https://git.eclipse.org/r/#/c/160897/1/bundles/org.eclipse.e4.ui.workbench.
> swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java

My project has no dependency to the plugin
org.eclipse.e4.ui.workbench.swt
which contains the PartRenderingEngine.

So I guess it's not called.

It is a RCP 3.x application, not a 4.x one.
Comment 25 Julia Kurde CLA 2020-04-14 09:48:17 EDT
(In reply to jule from comment #24)
> (In reply to Lars Vogel from comment #23)
> > (In reply to jule from comment #22)
> > > Maybe this information is already helpful:
> > > 
> > > With Version 4.15 (on Windows) I don't see any calls from 
> > > org.eclipse.e4.ui.css
> > > in the VisualVM CPU sampling when opening an editor,
> > > no matter if the '-cssTheme none' option is set or not.
> > 
> > Can you put a breakpoint into PartRenderingEngine and see if the CSS Engine
> > is still called? See
> > https://git.eclipse.org/r/#/c/160897/1/bundles/org.eclipse.e4.ui.workbench.
> > swt/src/org/eclipse/e4/ui/internal/workbench/swt/PartRenderingEngine.java
> 
> My project has no dependency to the plugin
> org.eclipse.e4.ui.workbench.swt
> which contains the PartRenderingEngine.
> 
> So I guess it's not called.
> 
> It is a RCP 3.x application, not a 4.x one.

I just see several calls from 
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine
in the CPU sampling.

It seems I'm misunderstanding the plugin dependency thing here.

If I don't see this class in my workspace, how can I set a breakpoint there?
Comment 26 Eclipse Genie CLA 2020-04-14 09:58:20 EDT
New Gerrit change created: https://git.eclipse.org/r/160897
Comment 27 Lars Vogel CLA 2020-04-14 10:13:48 EDT
(In reply to jule from comment #25)

> If I don't see this class in my workspace, how can I set a breakpoint there?

Ctrl+Shift+T to open it, if you set "Include all plug-ins from target..." via preferences (Windows -> Preferences -> Plug-in Development) tab.
Comment 28 Mike Marchand CLA 2020-04-14 10:18:19 EDT
Hi Lars, I should be able to give your Gerrit patch a try as well.
Comment 29 Lars Vogel CLA 2020-04-14 10:30:25 EDT
(In reply to Mike Marchand from comment #28)
> Hi Lars, I should be able to give your Gerrit patch a try as well.

Thanks.
Comment 30 Julia Kurde CLA 2020-04-14 10:39:43 EDT
(In reply to Lars Vogel from comment #27)
> (In reply to jule from comment #25)
> 
> > If I don't see this class in my workspace, how can I set a breakpoint there?
> 
> Ctrl+Shift+T to open it, if you set "Include all plug-ins from target..."
> via preferences (Windows -> Preferences -> Plug-in Development) tab.

OK, going into 
org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.initializeStyling(Display, IEclipseContext)

with a breakpoint, I see that
String cssTheme = (String) appContext.get(E4Application.THEME_ID);
is 
org.eclipse.e4.ui.css.theme.high-contrast
no matter if I use '-cssTheme none' or not.

So the lines you changed are not called.
Comment 31 Rolf Theunissen CLA 2020-04-14 11:43:07 EDT
(In reply to jule from comment #30)
> with a breakpoint, I see that
> String cssTheme = (String) appContext.get(E4Application.THEME_ID);
> is 
> org.eclipse.e4.ui.css.theme.high-contrast
> no matter if I use '-cssTheme none' or not.

Do you have a high contrast theme selected in Windows?

When the high contrast mode is detected, the theme selection in E4Application#setCSSContextVariables always selects the high-contrast theme. Probably, it should only change the 'default' to high-contrast, i.e., only select high-contrast when no theme is provided.
Comment 32 Julia Kurde CLA 2020-04-15 07:08:14 EDT
(In reply to Rolf Theunissen from comment #31)
 
> Do you have a high contrast theme selected in Windows?
> 
Yes.
Comment 33 Julia Kurde CLA 2020-04-17 05:58:56 EDT
Just checked performance with and without high-contrast theme selected in Windows and with and without the css none option:

Eclipse 4.13:
                high-contrast
             selected | not selected
css default   slow    | slow
css none      slow    | fast

Eclipse 4.15:
                high-contrast
             selected | not selected
css default   fast    | fast
css none      fast    | fast

So in 4.15 all cases are fast, in 4.13 it is only fast when no high-contrast is selected and css none option is set.

There is no difference between the two version for
String cssTheme = (String) appContext.get(E4Application.THEME_ID);
in org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.initializeStyling(Display, IEclipseContext)

Eclipse 4.13 / 4.15:
                        high-contrast
                 selected   | not selected
css default   high-contrast | e4_default
css none      high-contrast | none
Comment 35 Lars Vogel CLA 2020-04-17 10:20:46 EDT
I merged the small optimization and the theme issue will be handled by Bug 562237.

Hence I mark this bug as solved.
Comment 36 Mike Marchand CLA 2020-04-17 14:32:20 EDT
Hi Julia, if you are concerned about performance and theming, you can also look at bug 562127, it should have a positive impact on performance of large layouts with many children.
Comment 37 Julia Kurde CLA 2020-04-20 05:12:50 EDT
This Windows high-contrast theme is nice to make the screen look mostly black, which i really like. But in the end it makes more problems than benefits (not only with Eclipse). So finally after many years I'll now giving up using it. 

Anyway, thanks for all your help!