fxos-components / bridge

Exposes services between JavaScript contexts
https://fxos-components.github.io/bridge
MIT License
20 stars 8 forks source link

Limit total threads based on device 'capabilities'? #12

Closed wilsonpage closed 9 years ago

wilsonpage commented 9 years ago

Somehow we will derive a magic number of 'ideal number of threads'. This could be given at build time, or derived at runtime from some web-api. We then want to use this number to dictate the thread architecture.

We will keep creating new threads (Windows, Workers, SharedWorkers) until this number is reached. At which point, any further services should be 'injected' into pre-existing threads by the manager.

thread.loadService('path/to/service.js');
millermedeiros commented 9 years ago

are you sure this is needed? shouldn't Gecko be smarter than us on the resource allocation? (just wondering about added complexity and if there is going to be any real gain)

wilsonpage commented 9 years ago

You might be right. Let's try to get feedback from Vivien. On 17 Apr 2015 22:49, "Miller Medeiros" notifications@github.com wrote:

are you sure this is needed? shouldn't Gecko be smarter than us on the resource allocation? (just wondering about added complexity and if there is going to be any real gain)

— Reply to this email directly or view it on GitHub https://github.com/gaia-components/threads/issues/12#issuecomment-94082173 .

wilsonpage commented 9 years ago

It turns out there is a spec to get the number of cores using JavaScript: navigator.hardwareConcurrency (implemented in Chrome) https://wiki.whatwg.org/wiki/Navigator_HW_Concurrency

There is also a script to estimate this number: https://github.com/oftn/core-estimator @gmarty