W3C home > Mailing lists > Public > www-dom@w3.org > April to June 2009

Re: Mutation events - slowness examples

From: Sean Hogan <shogun70@westnet.com.au>
Date: Sun, 7 Jun 2009 08:37:46 +0800 (WST)
To: Boris Zbarsky <bzbarsky@MIT.EDU>
Cc: www-dom@w3.org, "Michael A. Puls II" <shadow2531@gmail.com>, Fran├žois REMY <fremycompany_pub@yahoo.fr>
Message-ID: <160518331.3496991244335066253.JavaMail.root@zim-store03.web.westnet.com.au>

----- "Boris Zbarsky" <bzbarsky@MIT.EDU> wrote:

> Fran├žois REMY wrote:
> > There's cleary two factors that apply :
> > ==> Time needed to move from managed C++ to unmanaged JScript
> > ==> Time of JScript execution
> You missed a third one: DOM event dispatch per se.
> For example, on your test2, I see the following in a current trunk 
> Firefox build:
> 10% of total time spent creating DOM nodes from the string.
> 40% of total time spent handling the insert internally
>     (creating the layout objects, etc).
> 45% of total time spent firing and handling the DOM event.
> That last 45% breaks down as follows (all percentages are of total 
> testcase time):
>    10% building up the event target chain and doing pre- and
>        post-dispatch handling of various sorts.
>     6% traversing that chain.
>     5% looking for listeners for this event on the various targets in
>        the chain.
>     6% setting up the right security context for the event dispatch.
>     8% creating the necessary JS objects (I have no idea why this
> takes
>        so long).
>     8% making the actual call into JS.
> Note that about half the "event dispatch time" is used even if there
> is 
> no listener to dispatch to (though if there is really no listener we 
> optimize away the mutation event dispatch altogether)...
> -Boris

Interesting. I may not be reading these results correctly - could you confirm these ratios:
- no listeners: 1x
- a DOMNodeInserted listener on the event chain: 2x (not counting listener execution time)
- a DOMNodeInserted listener NOT on the event chain: 1.5x

That doesn't seem so bad. If the 1.5x for the last case could be optimized to 1.1x then I would say just stick with the current spec. Can the dispatch algorithm check for listeners while building the event target chain and abort if there aren't any? 
Received on Sunday, 7 June 2009 00:38:28 UTC

This archive was generated by hypermail 2.3.1 : Tuesday, 20 October 2015 10:46:14 UTC