Status: New
Owner: ----
New issue 2230 by [email protected]: Auto-parallelize pure map-style loops
http://code.google.com/p/v8/issues/detail?id=2230
Ok, this is my last crackpot ponycorn "make JS faster than C" issue for now:
Expensive map-style loops with side-effectless loop bodies could be sort-of
kind-of parallelized automatically (in Web Workers at least, DOM JS has
some nasty pre-emptive events).
In essence, turning
for (var i=0; i<pixels.length; i++) {
pixels[i] = calculateMandelbrotForIndex(i);
}
into
var threads = [];
var segLength = pixels.length / CPU_CORES;
for (var c=0; c<CPU_CORES; c++) {
threads.push(new Thread(c, function(c){
for (var i=0; i<segLength; i++) {
pixels[i+c*segLength] = calculateMandelbrotForIndex(i+c*segLength);
}
}));
}
threads.forEach(function(t) { t.join(); });
Anyway, might be impossible to do in a performance-improving manner
(especially if it needs to spin up new threads at XX us startup overhead
per thread).
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev