我在我的 Electron 应用程序中使用了子进程。我仅在前一个子进程结束后才 fork 子进程。而且如果我 fork 多个进程,也不会提高速度。
我可以使用 Electron 应用程序中的集群模块同时 fork 多个子进程吗?
let doneFunction = {}
let queue = createQueue(1);
this.state.files.forEach((file, i) => {
queue.defer(function(details, done) {
readSizeRecursive(details.path, e); // inside that i forked child
doneFunction = done;
}, file);
});
childFinished = () => {
doneFunction()
}
我之前问过Child process maximum limit但我无法回答。
- 如果我 fork 两个集群均值,并且 fork 两个子进程均值,每个子进程会在两个不同的集群中并行运行?
最佳答案
And also if I fork multiple processes, it won't increase the speed.
要提高速度,您需要加快瓶颈,即您的情况下的磁盘 IO(目录大小计算等...)。 CPU 比磁盘 IO 快得多,因此多/单线程/进程并不重要。
if I forked two cluster means, and I fork two child process means, each child runs parallel in two different clusters?
是的,但它不会像上面提到的那样加快你的最终结果
关于javascript - 对集群和子进程如何工作的困惑,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56948862/