From d9fcde6cdec62b5ec0749509fc7a66d5ab28ac69 Mon Sep 17 00:00:00 2001 From: Jamie Davis Date: Sat, 9 Jun 2018 14:29:51 -0400 Subject: [PATCH 1/4] doc: note synchronous part of child_process.spawn If an application has a large RSS (GB), jorangreef observed that child_process.spawn will block the event loop for ms-s. This is surprising behavior and merits documentation. Refs: https://github.com/nodejs/node/issues/14917 --- doc/api/child_process.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 1fc2855e4f65f5..fc5f2cf583ba6e 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -39,6 +39,11 @@ without blocking the Node.js event loop. The [`child_process.spawnSync()`][] function provides equivalent functionality in a synchronous manner that blocks the event loop until the spawned process either exits or is terminated. +*Note*: On some operating systems, the [`child_process.spawn()`][] method +performs memory operations synchronously before decoupling the event loop +from the child. Applications with a large memory footprint may find frequent +[`child_process.spawn()`][] calls to be a bottleneck. + For convenience, the `child_process` module provides a handful of synchronous and asynchronous alternatives to [`child_process.spawn()`][] and [`child_process.spawnSync()`][]. *Note that each of these alternatives are From 3119e9bd037d705c7da74efec69be7e48171ab46 Mon Sep 17 00:00:00 2001 From: Jamie Davis Date: Sun, 10 Jun 2018 01:35:48 -0400 Subject: [PATCH 2/4] doc: add reference to V8 issue --- doc/api/child_process.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index fc5f2cf583ba6e..10a5bb5785ed12 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -42,7 +42,8 @@ the event loop until the spawned process either exits or is terminated. *Note*: On some operating systems, the [`child_process.spawn()`][] method performs memory operations synchronously before decoupling the event loop from the child. Applications with a large memory footprint may find frequent -[`child_process.spawn()`][] calls to be a bottleneck. +[`child_process.spawn()`][] calls to be a bottleneck. For more information, +see [V8 issue 7381](https://bugs.chromium.org/p/v8/issues/detail?id=7381). For convenience, the `child_process` module provides a handful of synchronous and asynchronous alternatives to [`child_process.spawn()`][] and From 217acc416e28b4a1d82f3bd012ad7fb0bfc2982d Mon Sep 17 00:00:00 2001 From: Jamie Davis Date: Thu, 14 Jun 2018 23:32:23 -0400 Subject: [PATCH 3/4] nit: UNIX-like OSes --- doc/api/child_process.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index 10a5bb5785ed12..ca94298437e4c5 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -39,7 +39,7 @@ without blocking the Node.js event loop. The [`child_process.spawnSync()`][] function provides equivalent functionality in a synchronous manner that blocks the event loop until the spawned process either exits or is terminated. -*Note*: On some operating systems, the [`child_process.spawn()`][] method +*Note*: On UNIX-like operating systems, the [`child_process.spawn()`][] method performs memory operations synchronously before decoupling the event loop from the child. Applications with a large memory footprint may find frequent [`child_process.spawn()`][] calls to be a bottleneck. For more information, From bbfd3618c17e8164c837c962f24519a86b3fc941 Mon Sep 17 00:00:00 2001 From: Jamie Davis Date: Fri, 15 Jun 2018 13:12:42 -0400 Subject: [PATCH 4/4] nits: relocate and drop prefix 'Note:' --- doc/api/child_process.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/api/child_process.md b/doc/api/child_process.md index ca94298437e4c5..51290bf251e3a8 100644 --- a/doc/api/child_process.md +++ b/doc/api/child_process.md @@ -39,12 +39,6 @@ without blocking the Node.js event loop. The [`child_process.spawnSync()`][] function provides equivalent functionality in a synchronous manner that blocks the event loop until the spawned process either exits or is terminated. -*Note*: On UNIX-like operating systems, the [`child_process.spawn()`][] method -performs memory operations synchronously before decoupling the event loop -from the child. Applications with a large memory footprint may find frequent -[`child_process.spawn()`][] calls to be a bottleneck. For more information, -see [V8 issue 7381](https://bugs.chromium.org/p/v8/issues/detail?id=7381). - For convenience, the `child_process` module provides a handful of synchronous and asynchronous alternatives to [`child_process.spawn()`][] and [`child_process.spawnSync()`][]. *Note that each of these alternatives are @@ -658,6 +652,12 @@ child registers an event handler for the [`'disconnect'`][] event or the [`'message'`][] event. This allows the child to exit normally without the process being held open by the open IPC channel.* +On UNIX-like operating systems, the [`child_process.spawn()`][] method +performs memory operations synchronously before decoupling the event loop +from the child. Applications with a large memory footprint may find frequent +[`child_process.spawn()`][] calls to be a bottleneck. For more information, +see [V8 issue 7381](https://bugs.chromium.org/p/v8/issues/detail?id=7381). + See also: [`child_process.exec()`][] and [`child_process.fork()`][]. ## Synchronous Process Creation