Closed Bug 944192 Opened 11 years ago Closed 11 years ago

Optimize out common cases when calling nsContentList::ContentAppended

Categories

(Core :: DOM: Core & HTML, defect)

x86_64
Linux
defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla28
Tracking Status
firefox28 --- fixed

People

(Reporter: smaug, Assigned: smaug)

Details

(Whiteboard: [qa-])

Attachments

(1 file)

This gives 65x speed up (ops/js) in js only case and 8x in jQuery case of Bug 944127.
(We're trying to match applet and form contentlists most of the time!)

I'm looking at various things to optimize here,  this is the initial simple case.
Attachment #8339634 - Flags: review?(bzbarsky)
> (We're trying to match applet and form contentlists most of the time!)

Hmm.  I wonder whether some of those rarely-used lists should in fact have a flag to go lazy faster.

I also wonder why those are even touched on the jsperf page...

An interesting question: did those have a JS wrapper when we tried to match them?  If not, maybe we could even use _that_ as a signal that no one cares about the list and hence it should go lazy.
Another interesting possibility is to simply special-case document.forms and document.applets and make the relevant tags explicitly add/remove themselves on bind/unbind instead of using a generic live list for them.  We should seriously consider that.
Comment on attachment 8339634 [details] [diff] [review]
optimize_out_common_contentlist_append.diff

This is OK, but common wisdom is to build up a DOM tree and insert it at once, so for everything except silly microbenchmarks this won't win us much. We should seriously consider some of the other suggestions here.
Attachment #8339634 - Flags: review?(bzbarsky) → review+
(In reply to Boris Zbarsky [:bz] from comment #1) 
> An interesting question: did those have a JS wrapper when we tried to match
> them?  If not, maybe we could even use _that_ as a signal that no one cares
> about the list and hence it should go lazy.

That I like.

But given the current setup in nsContentList::ContentAppended, that wouldn't help us with the test.
We're doing tons of appends, and nsContentUtils::PositionIsBefore can't handle them efficiently.
Lazyness check is afterwards.
https://hg.mozilla.org/mozilla-central/rev/026aec496a07
Status: NEW → RESOLVED
Closed: 11 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla28
Whiteboard: [qa-]
Component: DOM → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: