[whatwg] [Web workers] An attribute describing the "best" number of worker to invoke in a delegation use case

David Bruant bruant at enseirb-matmeca.fr
Wed Nov 11 19:19:17 PST 2009


This is a new proposal taking into account the feedback I recieved to
the "[WebWorkers] About the delegation example" message.

In the delegation example of the WebWorker spec, we can see this line :
"var num_workers = 10;"

My concern is about the arbitrarity of the "10".
Regarding the hardware, the operating system and the WebWorker
implementation, on one hand, this "10" may not result in a better
performance than if num_worker was equal to 1. On the other hand, the
user agent configuration may have better performances with a greater
number of workers (16 ? 100 ?).

My proposal is to add an attribute to the navigator object to write this :
"var num_workers = navigator.optimalWorkerNumber;
var items_per_worker = 10000000/num_workers;" (uneven dividing can
easily be solved)
(the name "optimalWorkerNumber" is not good, but I will use it in the
rest of this e-mail)

This attribute have the following properties :
- It's only dependant on the hardware, the operating system and the
WebWorker implementation (thus, it is not dynamically computed by the
user agent at each call and two calls in the same
hardware//OS//WebWorker implementation have the same result).
- In the same running conditions (same memory available, same number of
process running concurrently...) running the "same algorithm" (an easy
delegation algorithm) has a significantly better performance with
(navigator.optimalWorkerNumber) workers than
(navigator.optimalWorkerNumber - 1) workers
- In the same running conditions, running the same algorithm has no
significantly better performance with (navigator.optimalWorkerNumber +1)
workers than (navigator.optimalWorkerNumber) workers

Thanks for your feedback (previous and coming)


More information about the whatwg mailing list