This Bugzilla instance is deprecated, and most Eclipse projects now use GitHub or Eclipse GitLab. Please see the deprecation plan for details.
Bug 206568 - [performance] improve performance and resource usage of bug reports with ~100 comments
Summary: [performance] improve performance and resource usage of bug reports with ~100...
Status: CLOSED MOVED
Alias: None
Product: z_Archived
Classification: Eclipse Foundation
Component: Mylyn (show other bugs)
Version: dev   Edit
Hardware: PC Windows Vista
: P3 enhancement with 1 vote (vote)
Target Milestone: ---   Edit
Assignee: Project Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
: 208915 (view as bug list)
Depends on:
Blocks: 158921
  Show dependency tree
 
Reported: 2007-10-17 00:41 EDT by Willian Mitsuda CLA
Modified: 2009-08-17 23:57 EDT (History)
4 users (show)

See Also:


Attachments
mylyn/context/zip (5.07 KB, application/octet-stream)
2007-10-23 17:43 EDT, Mik Kersten CLA
no flags Details
mylyn/context/zip (15.77 KB, application/octet-stream)
2007-12-18 19:56 EST, Mik Kersten CLA
no flags Details
the layout manager that we use (1.85 KB, application/octet-stream)
2007-12-20 23:33 EST, David Green CLA
no flags Details
don't reflow sections when opening editor (2.61 KB, patch)
2008-01-11 02:36 EST, Steffen Pingel CLA
no flags Details | Diff
mylyn/context/zip (1.72 KB, application/octet-stream)
2008-03-27 18:57 EDT, Steffen Pingel CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Willian Mitsuda CLA 2007-10-17 00:41:53 EDT
It seems task editor performance does not scale well with the amount of comments.

My machine is a: Core 2 duo, 2GB, Windows Vista.

If you try to open a bug with ~100 comments, like bug#8009, and compare with another one with < 5 comments, like this one, you can note that:

- The first one takes more time to open the editor, ~3 seconds on my machine, the second one ~1 second.
- Expand the "Comments" section takes ~0,5 second, while the second one ~0,1 second.
- Expand a single comment takes ~0,5 second, while the second one ~0,1 second.

The comment expansion particularly bugs me, because while the ~0,1s in a "normal" bug is acceptable, it is sufficient to make the mouse cursor turn into a busy circle for a very quick moment. In the "big bug" scenario, it sounds strange because it looks like it is doing some heavy computation, but it is only repositioning the other controls.

I don't know if there is something we could do at Mylyn's side because it looks like the only thing we could optimize here is control creation and layout optimization.

I took a look at the forms API, and it appears the only way to handle the expansion correctly (and is the way actually used) is to invoke IManagedForm.reflow(true), but in the big task editor this means to invalidate and layout all the form == at least 100 * (expandable composites + icons + textviewer + hyperlinks, that composes a unique comment).

I don't remember any application that uses so many controls in a unique UI, and perhaps there should be some optimization in SWT/Forms side.
Comment 1 Mik Kersten CLA 2007-10-23 12:07:02 EDT
Shawn: could you please put your latest Sleak profiling results here?  

Beyond finding any opportunities to share fonts or colors across comments, the underlying problem here is the fact that we instantiate multiple SourceViewers. 
Comment 2 Shawn Minto CLA 2007-10-23 16:22:28 EDT
From what I found, there is 1 color created per comment:

2 comments: 41 colors, 1 font, 12 images
69 comments: 108 colors, 1 font, 12 images

If both of these are open at the same time, the base colors (39 or so) are shared.  The main problem seems to be that there is a color per comment created.
Comment 3 Mik Kersten CLA 2007-10-23 17:43:02 EDT
Shawn pointed out to me that the JFace DefaultHyperlinkPresenter class was instantiating a color on us because we were passing it an RGB, so changed that to pass it a color constant instead.  The number of colors should no longer grow with the number of comments. 

Shawn: please verify.
Comment 4 Mik Kersten CLA 2007-10-23 17:43:11 EDT
Created attachment 81000 [details]
mylyn/context/zip
Comment 5 Mik Kersten CLA 2007-11-06 21:18:55 EST
*** Bug 208915 has been marked as a duplicate of this bug. ***
Comment 6 Kevin Bracey CLA 2007-11-07 06:43:27 EST
I've been suffering from similar performance problems with large bugs, but it's the redraw during scrolling that's been bugging me (on Windows XP), rather than any layout time.

When viewing a task with a long list of comments, with all comments expanded, the time taken to perform any redraw is a significant fraction of a second on my Pentium-M class laptop. When paging up and down, this isn't too painful in itself - you just click on the scroll well, then wait for the content to appear.

But when scrolling up and down by dragging the scroll bar or using a scroll
wheel, with immediate scrolling enabled, you're left with a big smear of text
across the window unless you pause scrolling long enough for the redraw to happen;
the event prioritisation is such that it never gets round to redrawing any new
areas, only doing rectangle copies until you stop scrolling, giving a window full
of rendering artifacts. This isn't pretty.

The slow redraw can also be seen when dragging a window in front of the task
editor, although in that case the drag is frozen until the redraw catches up,
so you don't see visual artifacts.
Comment 7 Willian Mitsuda CLA 2007-11-07 09:21:19 EST
Kevin, I see this too, and I guess this is not necessarily because of the large comment list, but it just exposes a redrawing problem.

This is very easy to reproduce: just open any task editor with a sufficient large list of comments to have a vertical scroll bar, and scroll with the mouse wheel. You will see a "dirty repaint" effect on editor while scrolling.
Comment 8 Mik Kersten CLA 2007-12-11 13:15:47 EST
Not enough time for feedback on major UI changes of this sort for 2.2, so unfortunately pushing to 2.3.
Comment 9 Mik Kersten CLA 2007-12-18 19:55:55 EST
I am concerned that it is too easy to get into an excessive amount of use of handles with task editors, especially on Windows Vista (bug 211124).  What I have done to address this for now is put in a hard limit on task editor reuse, where the least-frequently used editor will be auto closed when the max is hit.  Dirty editors or those with incomings and outgoings will not be closed.  The max is currently hard-wired to 12 and I would like to avoid making it a preference.  It is not likely for anyone to hit max handles until they've got a few times that in number of editors open, so we can consider raising it.  However, task editor bloat has usability problems of its own, so it could be good to keep the max under 20.
Comment 10 Mik Kersten CLA 2007-12-18 19:56:01 EST
Created attachment 85504 [details]
mylyn/context/zip
Comment 11 Robert Elves CLA 2007-12-18 20:15:50 EST
Sounds good to me Mik. And in 2.3 we can reduce this number of handles per editor by reducing the number of viewers.
Comment 12 Eugene Kuleshov CLA 2007-12-18 20:44:46 EST
(In reply to comment #9)
> I am concerned that it is too easy to get into an excessive amount of use of
> handles with task editors, especially on Windows Vista (bug 211124).  What I
> have done to address this for now is put in a hard limit on task editor reuse,
> where the least-frequently used editor will be auto closed when the max is hit.
> Dirty editors or those with incomings and outgoings will not be closed.  The max
> is currently hard-wired to 12 and I would like to avoid making it a preference.

I am concerned about this, as with other hidden policies. Even if it is documented somewhere, it is still not very obvious to the end user when editors will be closed. For example I can envision scenario when user opens editor for the currently active task and then goes into the Task List or the Search view to browse trough some other tasks (it can go way beyond 12). In result interesting task editors will be unexpectedly closed. So, all in all property similar to Platform's "close editors automatically" will give more visibility to this feature.
Comment 13 David Green CLA 2007-12-19 16:40:51 EST
We have an editor with similar design to the Mylyn issue editor (multiple SourceViewers in ExpandableComposites) that exhibits similar performance problems.  We have come up with a solution that works well for our editor, drastically reducing the initialization time.  In case it might be of use for the Mylyn editor, I'm posting a summary of what we did here.

Our solution relies reducing the number of SourceViewers for a given editor instance.

SourceViewers are only instantiated if they're visible.  If an ExpandableComposite is expanded, the SourceViewer is added to it in an IExpansionListener, and if it is collapsed, the SourceViewer is disposed.  

In our editor this approach greatly reduces the number of SourceViewers that exist at any given point in time (granted if someone expands all composites, this approach would have no benefit -- however we've found that typical use rarely involves expanding all composites)

I hope that helps.

David

Comment 14 Robert Elves CLA 2007-12-19 17:32:52 EST
David, this is exactly what we plan to do so it is great to hear this has been done with some success! Were any extra tricks required to reduce the amount of form re-layout required after expanding/collapsing the expandable composites?
Comment 15 David Green CLA 2007-12-20 23:31:16 EST
I didn't mention that we also use a Composite container for each SourceViewer, where the Composite has a custom LayoutManager and no other children.  The LayoutManager might have an effect on performance, however that's not why we introduced it.  We find that the line wrapping behaviour of the StyledText is better using our LayoutManager.

I haven't yet used a profiler to analyze the new setup, so it's hard to say exactly what is working.  Our initialization time though has gone from about 2s to < 0.2s.  

I'm off work now until the 2nd, and probably won't get to it until the 16th of January -- so I'm afraid that I can't give you much more information with any degree of certainty.
Comment 16 David Green CLA 2007-12-20 23:33:45 EST
Created attachment 85698 [details]
the layout manager that we use

attached the layout manager that we're using.  Notice that is uses a width hint but no height hint, which will cause the StyledText to compute a size that shows all of the text without a scrollbar.
Comment 17 Mik Kersten CLA 2007-12-21 01:39:15 EST
Thanks David!  
Comment 18 Steffen Pingel CLA 2007-12-21 05:42:37 EST
That is great to hear David! I'll implement performance tests to collect some data on the improvements once the new code is merged.
Comment 19 Robert Elves CLA 2007-12-21 13:53:54 EST
Awesome, thanks for the info David. In the new year we'll see a much faster editor!
Comment 20 Steffen Pingel CLA 2008-01-11 01:23:36 EST
Here are my results of a quick profiling of the improved task editor:

On open :

 - The editor spends a bunch of time doing reflows. It looks like the editor is fully "reflown"  when each section is created causing it to burn  more time the more widgets are added. Is it possible to delay reflowing until all widgets are created?

On expand of (all) comments:

 - The parser of the StyledText widgets consumes a lot of time parsing the comments. The parsing rules might need a refactoring to make them more efficient.

 - The hyperlink detector triggers SWT exceptions that are ignored but cause 30% of the overhead. That might be a Linux only problem (looks similar to bug 203991).
Comment 21 Steffen Pingel CLA 2008-01-11 02:36:27 EST
Created attachment 86644 [details]
don't reflow sections when opening editor

This patch supresses reflows while constructing sections. According to the profiler editor opening went down from 6 seconds to 600 ms. Rob, it would be great if you could the patch to your bootstrap workspace and let me know if you can confirm that on Windows. Please note that the patch breaks the bold font style of section headers.
Comment 22 Robert Elves CLA 2008-01-11 15:08:40 EST
With this patch, creation of the editor sections for bug#8009 takes ~420ms!  Without this refresh patch section creation takes ~1420ms for that same bug.
Comment 23 Mik Kersten CLA 2008-01-11 15:25:59 EST
Excellent!  I am noticing a huge difference when going through incomings.
Comment 24 Steffen Pingel CLA 2008-01-16 22:33:19 EST
Committed minor improvements to avoid unnecessary section expansion which saves a few reflows.
Comment 25 Willian Mitsuda CLA 2008-01-21 23:45:18 EST
Very good improvements!
Comment 26 Mik Kersten CLA 2008-01-22 13:00:36 EST
I'm very impressed too.  This 25 comment bug took way less time to pop up then the tooltip for it did :)
Comment 27 Robert Elves CLA 2008-02-20 17:45:25 EST
I'm enjoying the speed improvements we've seen to date! Thanks again David for you input on this. Further improvements pushed to 3.0.
Comment 28 Eugene Kuleshov CLA 2008-02-20 19:15:49 EST
Rob, there is still issue with showing large comments (opened bug 219481 for that) and you can use bug 188524 as an example
Comment 29 David Green CLA 2008-02-21 00:41:48 EST
no problem.... but it seems to me that you did all of the hard work!
Comment 30 Steffen Pingel CLA 2008-03-27 18:57:12 EDT
Committed a patch to head (attached to bug 216677) that gets rid of form reflows during editor construction.
Comment 31 Steffen Pingel CLA 2008-03-27 18:57:17 EDT
Created attachment 93904 [details]
mylyn/context/zip
Comment 32 maarten meijer CLA 2008-03-31 08:32:49 EDT
As I noted in bug 224009 this may also be related to using serialization to realize a deep copy, which is what the editor does.
> To further the discussion I quote a bit from http://www.codeguru.com/java/tij/tij0127.shtml
> [...]
>Here is the output from three different runs:
>Duplication via serialization: 3400 Milliseconds
>Duplication via cloning: 110 Milliseconds
>
>Duplication via serialization: 3410 Milliseconds
>Duplication via cloning: 110 Milliseconds
>
>Duplication via serialization: 3520 Milliseconds
>Duplication via cloning: 110 Milliseconds
>[...]
Comment 33 Steffen Pingel CLA 2008-04-28 19:06:28 EDT
Deferring to 3.1. We will consider further performance improvements as part of the next release cycle.
Comment 34 Eclipse Webmaster CLA 2022-11-15 11:45:08 EST
Mylyn has been restructured, and our issue tracking has moved to GitHub [1].

We are closing ~14K Bugzilla issues to give the new team a fresh start. If you feel that this issue is still relevant, please create a new one on GitHub.

[1] https://github.com/orgs/eclipse-mylyn