Re: nsGenericElement::InsertBefore performance
Boris Zbarsky <[email protected]>
| Newsgroups | gmane.comp.mozilla.devel.dom |
|---|---|
| Message-ID | <[email protected]> |
Andreas Pflug wrote: > I'm not sure if this is the right group, so please redirect me to > another one that's more appropriate if necessary. Redirecting to .dom for now, but see below. > So I downloaded the code, had it build and applied some profiling code > to selected lines of code. I can see nsGenericElement::InsertBefore > consuming 6-7ms (compiled for debugging) on each call. I found that > nsCSFrameConstructor::ContentAppended as called from > nsGenericElement::doInsertChildAt will take half of the time (with many > time consuming calls nsNodeUtils::CloneAndAdopt, and the final > mozAutoDocUpdate destructor calling nsDocument::EndUpdate the other half. I can't say much without seeing either your actual profile data or your testcase (or ideally both), but here are the things that need to happen under ContentAppended: * Adopt the node and its descendants into the document if needed. For optimal performance, make sure this isn't needed by creating the node in the right document to start with. * Resolve style for the node and all its descendants. * Create the rendering objects for the node and its descendants. * Attach any XBL bindings that need attaching, creating their anonymous subtrees and so forth. * Run any XBL constructors that have been queued up. For what it's worth, I just tried timing (on P3-733) how long it takes to create a <div>, insert it into an otherwise empty HTML body, then remove that div. It takes about 0.7ms on branch. Obviously if you have a bigger subtree or XBL attached to it or complicated styling things will be slower... It's hard to tell where the pain points are given just the information you've provided so far. A profile with calltrees would help a lot. -Boris