Closed
Bug 944127
Opened 11 years ago
Closed 7 years ago
[Meta] jQuery $("<div>") DOM element append test is 1.3x slower than Chrome
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
INCOMPLETE
Performance Impact | high |
People
(Reporter: cpeterson, Assigned: smaug)
References
(Depends on 1 open bug, )
Details
(Keywords: perf, Whiteboard: [platform-rel-jQuery])
Attachments
(2 files)
Compare the following jsperf test in Firefox and Chrome: http://jsperf.com/jquery-performance-dom-creation Chrome 31: * with jquery: 274,230 ops/sec * with pure js: 837,447 ops/sec // "pure js" is 3x faster than with jQuery Firefox 28: * with jquery: 14,740 ops/sec // 19x slower than Chrome * with pure js: 7,431 ops/sec // 113x slower than Chrome and 2x slower than with jQuery?! "with jquery" test case: > var div = $("<div>"); > document.documentElement.appendChild(div[0]); "with pure js" test case: > var div = document.createElement("div") > document.documentElement.appendChild(div);
Assignee | ||
Comment 1•11 years ago
|
||
pure js is at least all about appendChild. We're updating some content list all the time
Assignee | ||
Comment 2•11 years ago
|
||
...which ends up calling PositionIsBefore(). Same with jQuery case.
Summary: jQuery $("<div>") DOM element creation test is 100x slower than Chrome (and pure js test is 2x slower than with jQuery) → jQuery $("<div>") DOM element append test is 100x slower than Chrome (and pure js test is 2x slower than with jQuery)
Assignee | ||
Comment 3•11 years ago
|
||
That code in nsContentList is _old_.
Comment 4•11 years ago
|
||
> We're updating some content list all the time
Presumably another artefact of all the random extra code jsperf loads into the window it runs the tests in.
That said, shouldn't PositionIsBefore be pretty quick in this case, since we are in fact appending every time?
Assignee | ||
Comment 5•11 years ago
|
||
With up-to-date it is harder to see where the time is spent, since I don't understand what jsperf actually measures. Element creation and appendChild don't take too much time.
Assignee | ||
Comment 6•11 years ago
|
||
js::regexp_exec takes about as much time as appendChild, and creating element a bit less.
Assignee | ||
Comment 7•11 years ago
|
||
Comment 8•11 years ago
|
||
jquery test Nightly (with bug 944149 fixed) - 1559ms Chrome 31 - 749ms Firefox Beta - slow script dialog IE 11 - I gave up after running after more than 1 minute non-jquery test Nightly (with bug 944149 fixed) - 6373ms Chrome 31 - 1934ms Firefox Beta - slow script dialog IE 11 - I gave up after running after more than 1 minute
Comment 9•11 years ago
|
||
Sorry, I switched the names. The first results are for the 'non-jquery' test, and the last results for the jquery one.
Reporter | ||
Comment 10•11 years ago
|
||
My test results on the latest Nightly 28 (with bug 944149) are similar to Guilherme's: Aurora 27: 12,466 vs 8,294 ops/sec (jquery vs pure js) Nightly 28: 125,497 vs 512,734 ops/sec Chrome 31: 238,859 vs 723,286 ops/sec Given that real content should construct an element tree before attaching it to the DOM instead of adding thousands of individual elements one-by-one, can we call this microbenchmark perf as "good enough" and resolve this bug as WORKSFORME? :)
Flags: needinfo?(bugs)
Assignee | ||
Comment 11•11 years ago
|
||
I wouldn't call this WFM. The jQuery case needs to be improved at least by fixing JS eng's regexp handling, and creating elements can be faster once we optimize extra addref/release out.
Flags: needinfo?(bugs)
Reporter | ||
Comment 12•10 years ago
|
||
Nightly 30 is much faster than Firefox 27, but Chrome 33 has also improved since this bug was filed: * Firefox 27: 19,643 vs 8,593 ops/sec (jquery vs pure js) * Nightly 30: 283,616 vs 988,758 ops/sec * Chrome 33: 537,758 vs 1,247,556 ops/sec
Summary: jQuery $("<div>") DOM element append test is 100x slower than Chrome (and pure js test is 2x slower than with jQuery) → jQuery $("<div>") DOM element append test is 1.3x slower than Chrome
Updated•8 years ago
|
Whiteboard: [platform-rel-jQuery]
Reporter | ||
Comment 13•8 years ago
|
||
jsperf.com is down, but the standalone tests that Olli attached to this bug still run: * The non-jquery test is still slightly (~15%) slower in Firefox than Chrome on my MacBook Pro, e.g. 515 ms in Firefox 50 vs 447 ms in Chrome 51. * I let the jquery test run for over a minute before I gave up..
status-firefox50:
--- → affected
Assignee | ||
Comment 14•8 years ago
|
||
jquery test took 1546ms here, and non-jquery 476ms.
Assignee | ||
Comment 15•8 years ago
|
||
bug 984690 shows up rather badly here, in the DOM/layout side.
Depends on: 984690
Updated•8 years ago
|
platform-rel: --- → ?
Updated•8 years ago
|
platform-rel: ? → +
Updated•8 years ago
|
Rank: 36
Updated•7 years ago
|
Blocks: QF-Frameworks
Updated•7 years ago
|
Whiteboard: [platform-rel-jQuery] → [platform-rel-jQuery][qf]
Updated•7 years ago
|
Whiteboard: [platform-rel-jQuery][qf] → [platform-rel-jQuery][qf:p1]
Assignee | ||
Updated•7 years ago
|
Assignee: nobody → bugs
Flags: needinfo?(bugs)
Assignee | ||
Comment 16•7 years ago
|
||
Need to download the tests and run locally since they use http. Chrome 60 dev seems to be a bit slower with jQuery test even in the best case, and when running the test several times Chrome has some huge GC pauses causing the test to take up to 10x more time. And same thing seems to happen without jQuery too, and speed it better in FF. This is on 64 bit linux. But there are things to optimize here. I'll file some bugs.
Assignee | ||
Comment 17•7 years ago
|
||
Hmm, on Windows Chrome is definitely faster (in those cases GC doesn't kick in).
Assignee | ||
Updated•7 years ago
|
Flags: needinfo?(bugs)
Summary: jQuery $("<div>") DOM element append test is 1.3x slower than Chrome → [Meta] jQuery $("<div>") DOM element append test is 1.3x slower than Chrome
Assignee | ||
Comment 18•7 years ago
|
||
Unusual issue with the non-jquery test in jsperf. We are now fast enough that we overflow the internal ATTRCHILD_ARRAY_MAX_CHILD_COUNT limit. https://jsperf.com/simple-jquery-performance-test is testing just the jQuery part. On a Windows 10 laptop Nightly gives 472,899 ops/sec, Chrome 152,892 ops/sec. I think Chrome has regressed badly, but that also means that this particular bug isn't really actionable right now.
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → INCOMPLETE
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
Updated•2 years ago
|
Performance Impact: --- → P1
Whiteboard: [platform-rel-jQuery][qf:p1] → [platform-rel-jQuery]
You need to log in
before you can comment on or make changes to this bug.
Description
•