Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 336058 - poor XML editor performance if folding is enabled
Summary: poor XML editor performance if folding is enabled
Status: RESOLVED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.sse (show other bugs)
Version: 3.1   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.2.4   Edit
Assignee: Nitin Dahyabhai CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: performance
Depends on:
Blocks:
 
Reported: 2011-02-02 07:22 EST by Walter Brunauer CLA
Modified: 2011-03-23 19:14 EDT (History)
3 users (show)

See Also:
nsand.dev: review+


Attachments
possible patch, haven't verified performance impact (3.55 KB, patch)
2011-02-03 15:40 EST, Nitin Dahyabhai CLA
no flags Details | Diff
patch 2 (3.59 KB, patch)
2011-03-01 13:28 EST, Nitin Dahyabhai CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Walter Brunauer CLA 2011-02-02 07:22:50 EST
Build Identifier: org.eclipse.wst.sse.ui 1.2.3v201010160450 28.10.2010 23:38:14

Seems, the algorithm to find the foldings in org.eclipse.wst.sse.ui.internal.projection.AbstractStructuredFoldingStrategy.getIndexedRegions(IStructuredModel, IStructuredDocumentRegion[]) is really poor: on a XML file with about 1 MB, 6000 lines and 12000 XML regions, e.g. org.eclipse.wst.xml.core.internal.document.NodeImpl.getEndOffset() is called about 50 (!) million (!!) times (plus some other methods similar often), and because of this consuming several seconds CPU time during opening the XML editor. Disabling folding reduces this to a acceptable amount of time (several 100 ms only).

Reproducible: Always

Steps to Reproduce:
Open a large XML file containing 1000+ XML regions, having folding enabled.
Comment 1 Martin Oberhuber CLA 2011-02-02 09:25:11 EST
CQ:WIND00253653
Comment 2 Nitin Dahyabhai CLA 2011-02-03 15:40:26 EST
Created attachment 188275 [details]
possible patch, haven't verified performance impact
Comment 3 Nick Sandonato CLA 2011-02-09 17:36:42 EST
(In reply to comment #2)
> Created attachment 188275 [details]
> possible patch, haven't verified performance impact

I ran some fairly informal tests that basically calculated the time it took to get the indexed regions in AbstractStructuredFoldingStrategy. Before the patch, it took on average 2867.16ms to get the indexed regions. After the patch, it went down to an average of 1258ms. This was for a file at about 2.9MB.
Comment 4 Martin Oberhuber CLA 2011-03-01 11:36:15 EST
Walter: Do you think 1.2 sec are acceptable for a 3 MB file ?
Nitin: Since your patch does seem to improve things, can it be committed?
       Do you see potential for more improvement?
Nick: Anything else I'm forgetting?
Comment 5 Walter Brunauer CLA 2011-03-01 12:27:50 EST
Hm, given the fact, that all this is in memory, the time being used feels still way too high. However, I understand the algorithm might be hard to change in a simple way, but it should not behave non-linear after all.
Comment 6 Nitin Dahyabhai CLA 2011-03-01 13:28:48 EST
Created attachment 190069 [details]
patch 2

(In reply to comment #4)
> Nitin: Since your patch does seem to improve things, can it be committed?
>        Do you see potential for more improvement?

After rereading it a bit, here's a newer version that tightens things up a little more.  I don't think it will have a measurable improvement over the original, but it's a little more straightforward.  Yes, I believe that it can be committed.
Comment 7 Nick Sandonato CLA 2011-03-02 16:19:01 EST
New patch looks fine as well.
Comment 8 Nitin Dahyabhai CLA 2011-03-23 19:14:35 EDT
Released in 3.2.4 and committed to HEAD.