[webkit-dev] setTimeout as browser speed throttle
Mike Belshe
mike at belshe.com
Mon Sep 29 19:26:57 PDT 2008
Hi,
One of the differences between Chrome and Safari is that Chrome sets the
setTimeout clamp to 1ms as opposed to 10ms. This means that if the
application writer requests a timer of less than 10ms, Chrome will allow it,
whereas Safari will clamp the minimum timeout to 10ms. The reason we did
this was to minimize browser delays when running graphical javascript
applications.
This has been a concern for some, so I wanted to bring it up here and get an
open discussion going. My hope is to lower or remove the clamp over time.
To demonstrate the benefit, here is one test case which benefits from
removing the setTimeout clamp. Chrome gets about a ~4x performance boost by
reducing the setTimeout clamp. This programming pattern in javascript is
very common.
http://www.belshe.com/test/sort/sort.html<http://www.belshe.com/test/sort/sort.html>
One counter argument brought up is a claim that all other browsers use a
10ms clamp, and this might cause incompatibilities. However, it turns out
that browsers already use widely varying values. We also really haven't
seen any incompatibilities due to this change. It is true that having a
lower clamp can provide an easy way for web developers to accidentally spin
the CPU, and we have seen one high-profile instance of this. But of course
spinning the CPU can be done in javascript all by itself :-)
Here is a summary of the minimum timeout for existing browsers (you can test
your browser with this page: http://www.belshe.com/test/timers.html
)<http://www.belshe.com/test/timers.html>
Safari for the mac: 10ms
Safari for windows: 15.6ms
Firefox: 10ms or 15.6ms, depending on whether or not Flash
is running on the system
IE : 15.6ms
Chrome: 1ms (future - remove the clamp?)
So here are a couple of options:
1) Remove or lower the clamp so that javascript apps can run
substantially faster.
2) Keep the clamp and let them run slowly :-)
Thoughts? It would be great to see Safari and Chrome use the same clamping
values.
Thanks,
Mike
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.webkit.org/pipermail/webkit-dev/attachments/20080929/3ab62f48/attachment.html
More information about the webkit-dev
mailing list