In the browser, it is way faster to send buffers instead of regular arrays. This is done in the following way:
// create data that can be transfered
var myData = [1,3,5,78,1,2,45,6,5,12];
var buffer = new Float64Array(myData.slice());
var worker = new Worker("some_worker.js");
// transfer the buffer
worker.postMessage({buffer: buffer}, [buffer]);
Is there a way to pull off the same trick on child processes for Node.js? Does this speed up communication significantly?
For instance, how would I modify the following script to speed it up:
var cp = require('child_process');
// create data that can be transfered
var myData = [1,3,5,78,1,2,45,6,5,12];
var child = cp.fork('some_worker.js');
// transfer the buffer
child.send(myData);