[webkit-dev] support for navigator.cores or navigator.hardwareConcurrency

Brady Eidson beidson at apple.com
Wed May 7 19:58:39 PDT 2014


On May 7, 2014, at 5:38 PM, Rik Cabanier <cabanier at gmail.com> wrote:

> 
> 
> 
> On Wed, May 7, 2014 at 5:07 PM, Benjamin Poulain <benjamin at webkit.org> wrote:
> On 5/7/14, 4:13 PM, Benjamin Poulain wrote:
> On 5/7/14, 3:52 PM, Filip Pizlo wrote:
> Exactly. Ben, Oliver, and others have made arguments against web
> workers. Rik is not proposing web workers.  We already support them. The
> point is to give API to let developers opt into behaving nicely if they
> are already using web workers.
> 
> I have nothing against Web Workers. They are useful to dispatch
> background tasks.
> 
> They are basically the Web equivalent dispatch_async() of GCD, which is
> already a very useful tool.
> 
> What you are suggesting is useful for making Web Workers the tool to do
> high performance multi-thread computation.
> I don't think Web Workers are a great tool for that job at the moment. I
> would prefer something along TBB, GCD or something like that.
> 
> 
> For high performance computation, I think a more useful API would be
> something like TBB parallel_for with automatic chunking.
> It is actually had to do faster than that with the number of cores
> unless you know your task very very well.
> 
> It would be a little more work for us, but a huge convenience for the
> users of Web Workers.
> 
> After chatting with Filip, it seems such a model is unlikely to happen anytime soon for JavaScript.
> 
> In the absence of any tasks/kernels model, I am in favor of exposing a "good number of thread" API. It is definitely better than nothing.
> 
> Do we know what this number would be? My guess would be the number of cores for "regular" systems...

Define “regular” systems:  As Ryosuke mentioned, for systems that run on battery power (read: a vast majority of systems), keeping cores asleep to preserve battery life is often preferable to the user instead of waking up all available hardware and building up heat.

Also, what type of cores?  Physical cores, or logical cores?

> Boris Zbarsky indicated that Firefox figures out how many workers should run concurrently. Maybe we can reuse that algorithm?

I think it’s definitely worth looking in to.

~Brady
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.webkit.org/pipermail/webkit-dev/attachments/20140507/8c405ad8/attachment.html>


More information about the webkit-dev mailing list