Bug 102992 - potential performance improvement when moving nodes within the DOM
Summary: potential performance improvement when moving nodes within the DOM
Status: NEW
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML DOM (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
Depends on:
Reported: 2012-11-21 16:49 PST by Ojan Vafai
Modified: 2012-11-21 16:49 PST (History)
4 users (show)

See Also:


Note You need to log in before you can comment on or make changes to this bug.
Description Ojan Vafai 2012-11-21 16:49:24 PST
Right now, appendChild will first remove the child if it's already in the tree and walk the whole subtree via ChildNodeRemovalNotifier(this).notify(child.get())) to call removedFrom and clear it's inDocument flag. If the nodes get appended right back into the document, there's no need to walk the whole subtree. The tricky bit is that there may be sync JS events that fire (e.g. blur, unload, mutation events). So, we could, in theory, do something like ChildNodesLazySnapshot, where we put off this work until dispatchEvent is actually called or until the appendChild is done, at which point we only need to make sure the inDocument bit is set correctly on the root.

One tricky bit will be making sure InspectorInstrumentation + DOM breakpoints continue to work right. Again, we only need to walk the subtree if there are DOM breakpoints set.

Avoiding other walks of the tree in the DOM modification code have proven to be a big performance improvement (e.g. ~10%).