Re: [webkit-dev] EventListener Invocation Cost?

2011-01-10 Thread Darin Adler
On Jan 9, 2011, at 11:56 AM, Alex Milowski wrote:

 I'm not sure there is a lot that can be done about it.

I’m sure we can speed it up if we have a reason to. Step one is to find out 
exactly where the time is spent. Then we figure out ways to streamline the code 
path. The experts on this may not have the same priorities you do, so they may 
not have plans to spend time improving it.

 The only question I have right now is whether the event handler function from 
 Javascript is JIT compiled.

The answer is yes.

There’s nothing special about the event handler function. In fact at the time 
it is compiled the engine doesn’t know it will be an event handler function.

Unless you’re talking about a handler from a content attribute such as onclick. 
Those are also compiled, though.

-- Darin

___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


Re: [webkit-dev] EventListener Invocation Cost?

2011-01-10 Thread Alex Milowski
On Mon, Jan 10, 2011 at 10:19 AM, Darin Adler da...@apple.com wrote:
 On Jan 9, 2011, at 11:56 AM, Alex Milowski wrote:

 I'm not sure there is a lot that can be done about it.

 I’m sure we can speed it up if we have a reason to. Step one is to find out 
 exactly where the time is spent. Then we figure out ways to streamline the 
 code path. The experts on this may not have the same priorities you do, so 
 they may not have plans to spend time improving it.

I will certainly spend some time trying to narrow this down but I also
think my current situation is rather extreme and so I may have spoke
too soon.  Digging deeper into the performance of the API I'm
experimenting with shows, by no surprise, that it delivers an extreme
number of small event objects.  There is always going to be a penalty
for that but the relative performance of the execution of the event
listener is actually rather good if you take the number of events
delivered into account.  I'm certain that a listener within C++ would
perform better, but that isn't a big surprise either.

When you take the overall application speed into account, things look
very different.  That is, not just the speed of parsing and delivering
the XML information but how long does it take the application to load
or use the data it has received.

-- 
--Alex Milowski
The excellence of grammar as a guide is proportional to the paucity of the
inflexions, i.e. to the degree of analysis effected by the language
considered.

Bertrand Russell in a footnote of Principles of Mathematics
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev


[webkit-dev] EventListener Invocation Cost?

2011-01-09 Thread Alex Milowski
I'm working on an experiment that uses EventListener instances to
handle a large number of events.  I've noticed there is quite a bit of
overhead when invoking a Javascript-based event listener.

I'm not sure there is a lot that can be done about it.  I've looked
through the implementation of how the Javascript function gets
evaluated.  The only question I have right now is whether the event
handler function from Javascript is JIT compiled.

I'm not sure that really matters.  It seems to be the invocation which
causes the most cost.  If I attach an empty function for the event,
the processing slows down (i.e. the cost is incurred regardless of
what is going on inside the function).  It just seems like the cost of
crossing the language boundary between C++ and Javascript is quite
expensive.

I've only tried this with JavascriptCore.  I've not looked into
bindings for v8 as of yet.

Thoughts on this?

-- 
--Alex Milowski
The excellence of grammar as a guide is proportional to the paucity of the
inflexions, i.e. to the degree of analysis effected by the language
considered.

Bertrand Russell in a footnote of Principles of Mathematics
___
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev