Open Bug 1481080 Opened 7 years ago Updated 3 years ago

DOMParser parsing text/xml is 4 times slower than text/html

Categories

(Core :: XML, defect, P5)

61 Branch
defect

Tracking

()

UNCONFIRMED
Tracking Status
firefox61 --- affected

People

(Reporter: tom, Unassigned)

Details

(Keywords: perf)

User Agent: Mozilla/5.0 (X11; Linux x86_64; rv:61.0) Gecko/20100101 Firefox/61.0 Build ID: 20180705213349 Steps to reproduce: When parsing a valid XML document I'd expect parsing it as XML would be faster due to less error checking/fixing. I tried the following on a 1000 line XML document: performance.mark("start"); for (var i = 0; i < 1000; i++) { var parser = new DOMParser(); xmlDoc = parser.parseFromString(xmlString, "text/xml"); } performance.mark("end"); performance.measure( 'parse', "start", "end" ); var measures = performance.getEntriesByName("parse"); var measure = measures[0]; console.log("parse milliseconds:", measure.duration) performance.clearMarks(); performance.clearMeasures(); Actual results: When using text/html I get ~3700ms. When using text/xml (or application/xml) I get around 13500ms. I'm not sure why this is but as it stands you are better off using text/html to parse large but valid XML documents. Expected results: I'd expect the performance of XML parsing to be at least as good as text/html if not faster.
Based on other similar reports I think the correct component would be Core:XML. Please change if this is not the right component!
Component: Untriaged → XML
Product: Firefox → Core
Keywords: perf
Priority: -- → P5

Out of interest I just tried this in Firefox 70 and I'm now seeing much better results.

I'm now seeing roughly equivalent for both XML and HTML. Around 550ms for both.

Interestingly, in Chromium, it's ~650ms for XML and 6620ms for HTML so firefox is slightly faster at parsing XML and a lot faster at parsing HTML. Nice job.

Severity: normal → S3
You need to log in before you can comment on or make changes to this bug.