Closed
Description
Hi,
I'm not sure if my expectations of using IPC are unreasonable, and if so please tell me / close this issue. I planned to use a forked child_process to do some background ops for a nwjs app, and intended to send roughly 40MB of JSON data to the forked ps, and I'd get back a pojo describing that data; I measured the timing at roughly 250-300 seconds on a maxed out 2015 macbook pro (sad face); a Worker
in chromium is doing the same job in 1-2 milliseconds.
I then decided to measure the example in the documentation on my personal maxed macbook air (less ram, slower cpu, fast ssd):
// index.js
var cp = require('child_process'),
n = cp.fork(__dirname + '/sub.js'),
precise = require('precise'),
timer = precise();
n.on('message', function(m) {
timer.stop();
console.log('PARENT got message:', m);
console.log('Message received in', timer.diff() / 1000000, 'ms');
});
timer.start();
n.send({ hello: 'world' });
// sub.js
process.on('message', function(m) {
console.log('CHILD got message:', m);
});
process.send({ foo: 'bar' });
// Console output:
// PARENT got message: { foo: 'bar' }
// CHILD got message: { hello: 'world' }
// Message received in 94.963261 ms
In both hardware scenarios, a simple small text message takes 90-100ms. Not writing to console saves roughly 5-10ms in the provided example.