Closed
Bug 537362
Opened 15 years ago
Closed 15 years ago
Optimize appendChild(lastChild)
Categories
(Core :: DOM: Core & HTML, defect)
Core
DOM: Core & HTML
Tracking
()
RESOLVED
INVALID
People
(Reporter: codedread, Assigned: codedread)
Details
(Keywords: perf)
Attachments
(3 files)
676 bytes,
image/svg+xml
|
Details | |
937 bytes,
patch
|
Details | Diff | Splinter Review | |
526 bytes,
text/html
|
Details |
I ran into the following scenario where I was appending the existing last child of an element to the element many times. The result was that I was wasting a lot of JS cycles, but I also noticed that Mozilla ran orders of magnitudes slower than WebKit and still quite a bit slower than Opera. This surprised me: Chrome: appended lastChild 2934013 times in 2s Safari: appended lastChild 2970559 times in 2s Opera: appended lastChild 93344 times in 2s Firefox: appended lastChild 60257 times in 2s Since this is a really simple optimization that doesn't hurt in the general case (when the new element is not already a child of the element being appended to) I thought I'd submit it. Now I can build mozilla and run Firefox, but it's in Debug mode and I'm still learning how to do incremental builds, etc. I'm not sure how to test this type of patch properly to observe the differences in performance.
Comment 1•15 years ago
|
||
I assume you'll attach the patch soon?
Assignee: nobody → codedread
OS: Mac OS X → All
Hardware: x86 → All
Assignee | ||
Comment 2•15 years ago
|
||
Sorry, I tried to read https://developer.mozilla.org/en/Mozilla_automated_testing but couldn't figure out how to run the tests. P.S. I checked WebKit's code and they do indeed have this optimization :)
Attachment #419660 -
Flags: review?
Updated•15 years ago
|
Component: DOM → XSLT
QA Contact: general → xslt
Updated•15 years ago
|
Attachment #419660 -
Flags: review? → review?(jonas)
Updated•15 years ago
|
Component: XSLT → DOM
QA Contact: xslt → general
Comment 3•15 years ago
|
||
So the patch is about xslt, but the testcase doesn't seem to have much to do with xslt. Or am I missing something here.
Comment 4•15 years ago
|
||
This shows that WebKit has a bug here. It optimizes out the mutation events in this case, even though DOM 3 Core clearly specifies that when appending node should be first removed from the old parent.
Assignee | ||
Comment 5•15 years ago
|
||
Yes, the patch was completely incorrect (did not deal with DOM), sorry about that. Gavin set me straight in IRC. As for the WebKit optimization being a bug, you are also right.
Status: NEW → RESOLVED
Closed: 15 years ago
Resolution: --- → INVALID
Attachment #419660 -
Flags: review?(jonas)
Updated•5 years ago
|
Component: DOM → DOM: Core & HTML
You need to log in
before you can comment on or make changes to this bug.
Description
•