Bug 213550 - make xml formatter use text edits to make it faster
Summary: make xml formatter use text edits to make it faster
Status: CLOSED FIXED
Alias: None
Product: WTP Source Editing
Classification: WebTools
Component: wst.xml (show other bugs)
Version: 3.0   Edit
Hardware: PC Windows XP
: P3 normal (vote)
Target Milestone: 3.0 M4   Edit
Assignee: Amy Wu CLA
QA Contact: Nitin Dahyabhai CLA
URL:
Whiteboard:
Keywords: performance, plan
Depends on:
Blocks:
 
Reported: 2007-12-19 23:47 EST by Amy Wu CLA
Modified: 2008-01-04 22:53 EST (History)
1 user (show)

See Also:


Attachments
sse.ui.xml.core.xml.ui.patch (79.80 KB, patch)
2007-12-20 00:28 EST, Amy Wu CLA
no flags Details | Diff
xml.core.tests.patch (21.05 KB, patch)
2007-12-20 00:33 EST, Amy Wu CLA
no flags Details | Diff
formattingresults.txt (9.33 KB, text/plain)
2007-12-20 00:50 EST, Amy Wu CLA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Amy Wu CLA 2007-12-19 23:47:51 EST
wtp 3.0 m3

There've been many complaints in the past regarding how slow the xml formatter is.  Improvements have been already been made, but one way to speed it up even more is to use TextEdits to format the document.

The formatter now currently modifies the text as it attempts to format each node.  This results in many document/model notifications and constant updates.

Using text edits would batch up all the edits and the edits would be made after determining how to format each node.
Comment 1 Amy Wu CLA 2007-12-20 00:28:06 EST
Created attachment 85626 [details]
sse.ui.xml.core.xml.ui.patch

xml.core
new classes
-DefaultXMLPartitionFormatter - the new xml formatter
-XMLFormattingConstraints - formatting context passed from node to node during formatting (available line width, whether or not currently indenting)
-XMLFormattingPreferences - contains formatting preferences
-XMLFormatterFormatProcessor - turns the new formatting into the old istructuredformatprocessor (still necessary for cleanup and file formatting)

xml.ui
-created an xml formatting strategy and in the xml viewer configuration, when setting up multipasscontentformatter, use the new xml formatting strategy
-the xml formatting strategy basically calls the Default

sse.ui
-just added a debug statement in StructuredTextMultiPassContentFormatter to time how long formatting takes
Comment 2 Amy Wu CLA 2007-12-20 00:33:14 EST
Created attachment 85627 [details]
xml.core.tests.patch

Unit tests for new xml formatter.  I basically took the existing unit tests for the old xml formatter and made them use the new formatter.  There were instances where the results were different, but upon further investigation, it looked like the results were still correct.  So in those cases, I just updated the results so they reflected the new results from the new formatter.
Comment 3 Amy Wu CLA 2007-12-20 00:50:40 EST
Created attachment 85631 [details]
formattingresults.txt

Running the FormatTest performance test in xml.ui.tests.performance, the new xml formatter was over 50% faster.
I also compared formatting results when formatting a.xml from bug 144224 (a.xml is 323kb & semi-formatted)
Unless I messed up on the math, the new xml formatter was 70-90% faster!

I've attached the performance test details in case anyone was interested.
Comment 4 Amy Wu CLA 2007-12-20 00:53:13 EST
fix released for this week's wtp 3.0 m4 build.
Comment 5 Amy Wu CLA 2008-01-04 22:53:48 EST
verified using wtp3.0M4 20080103204922