GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — doc: note synchronous part of child_process.spawn by davisjam · Pull Request #21234 · nodejs/node

Conversation

@davisjam

@davisjam davisjam commented Jun 9, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

If an application has a large RSS (MB-GB), @jorangreef observed that child_process.spawn will block the event loop for milliseconds to seconds.

This is surprising behavior and merits documentation.

See discussion on #14917.

Checklist
  • documentation is changed or added
  • commit message follows commit guidelines

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@davisjam
doc: note synchronous part of child_process.spawn
d9fcde6
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: nodejs#14917
@nodejs-github-bot nodejs-github-bot added child_process Issues and PRs related to the child_process subsystem. doc Issues and PRs related to Node.js documentation. labels Jun 9, 2018
@davisjam davisjam mentioned this pull request Jun 9, 2018
spawn() is not asynchronous, blocks event loop for 2-3 seconds #14917
Closed
@vsemozhetbyt

vsemozhetbyt commented Jun 9, 2018

Copy link
Copy Markdown
Contributor

CI-lite: https://ci.nodejs.org/job/node-test-pull-request-lite/869/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@mscdex

mscdex commented Jun 9, 2018

Copy link
Copy Markdown
Contributor

Isn't this only an issue until V8 incorporates the patch mentioned in the original issue? If so, is this really worth it and are we going to remember to remove the text if/when V8 lands the proposed change?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@davisjam

davisjam commented Jun 9, 2018

Copy link
Copy Markdown
Contributor Author

@mscdex, fair point. However, I'm not aware of any movement on that patch since it was opened in January. On a related note, is there a system in place to track documentation tied to change requests to dependencies like V8 or libuv?

In favor of this PR, several people commented on #14917 and noted how long it took them to identify the root cause. Adding this documentation should help.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Jun 9, 2018

Copy link
Copy Markdown
Member

This might not be a good idea but maybe it is?: Include a link to the V8 issue with an explanation that after it lands and is downstreamed to Node.js core, the problem goes away. That will at least have the potential to tip someone else off that the paragraph can be removed at that time.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@davisjam

davisjam commented Jun 9, 2018

Copy link
Copy Markdown
Contributor Author

@Trott I like this idea. Something like

"As noted here, ...".

?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Jun 9, 2018

Copy link
Copy Markdown
Member

Maybe "As noted in V8 issue 7381" instead of "here"? But otherwise, yeah, something like that.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

gireeshpunathil
gireeshpunathil approved these changes Jun 10, 2018
View reviewed changes
@davisjam
doc: add reference to V8 issue
3119e9b
@davisjam

davisjam commented Jun 10, 2018

Copy link
Copy Markdown
Contributor Author

@Trott See tweaked wording in 3119e9b.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Jun 10, 2018

Copy link
Copy Markdown
Member

@nodejs/documentation @nodejs/child_process

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

bnoordhuis
bnoordhuis reviewed Jun 10, 2018
View reviewed changes

@bnoordhuis bnoordhuis left a comment

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm -.2 on documenting this because the synopsis is already too long.

For most people this will just be a piece of irrelevant trivia or possibly a source of irrational fear ("I can't use child processes because performance" even though it's insignificant 99.99% of the time.)

If you look at e.g. python's subprocess or ruby's process docs, they don't mention this caveat either even though they're just as susceptible.

(I didn't fully check perl since it has a gazillion ways to start a child process but the few I checked don't mention it either.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
Comment thread doc/api/child_process.md Outdated
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

@bnoordhuis bnoordhuis Jun 10, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be more specific and write "On UNIX-like operating systems" and tweak the wording to clarify that it's the underlying fork() system call that is responsible for copying memory, not child_process.spawn() (directly.)

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@davisjam davisjam Jun 15, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like "UNIX-like" (217acc4), but I don't think we need to go into detail on the root cause. The V8 link explains things.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@davisjam
nit: UNIX-like OSes
217acc4
@davisjam

davisjam commented Jun 15, 2018 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor Author

@bnoordhuis

If you look at e.g. python's subprocess or ruby's process docs, they don't mention this caveat either even though they're just as susceptible.

True. But Node embraces a single-threaded event loop, so I think it's more important that we document potential blocking calls -- especially calls that are listed as the "asynchronous" version of things.

because the synopsis is already too long.

I agree that the synopsis is pretty long. What about nestling this note in the API documentation for child_process.spawn here?

pauldraper reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@bnoordhuis

bnoordhuis commented Jun 15, 2018

Copy link
Copy Markdown
Member

Yep, sounds good.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell reviewed Jun 15, 2018
View reviewed changes
Comment thread doc/api/child_process.md Outdated
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

@jasnell jasnell Jun 15, 2018

Copy link
Copy Markdown
Member

There was a problem hiding this comment.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a nit: The *Note*: part is unnecessary.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Trott reacted with heart emoji
All reactions
  • ❤️ 1 reaction
@davisjam
nits: relocate and drop prefix 'Note:'
bbfd361
@davisjam

davisjam commented Jun 15, 2018

Copy link
Copy Markdown
Contributor Author

@bnoordhuis Check the new location.
@jasnell I dropped the "Note".

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell
jasnell approved these changes Jun 15, 2018
View reviewed changes
bnoordhuis
bnoordhuis approved these changes Jun 15, 2018
View reviewed changes
trivikr
trivikr approved these changes Jun 17, 2018
View reviewed changes
@Trott

Trott commented Jun 18, 2018

Copy link
Copy Markdown
Member

Lite CI: https://ci.nodejs.org/job/node-test-pull-request-lite/886/

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@davisjam

davisjam commented Jun 19, 2018

Copy link
Copy Markdown
Contributor Author

Looks like this PR has approval. Shall I merge?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@Trott

Trott commented Jun 19, 2018

Copy link
Copy Markdown
Member

Looks like this PR has approval. Shall I merge?

CI is green, nobody seems to object, it has multiple approvals, and it's been open more than 72 hours. GO FOR IT!

git node land 21234

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

jasnell pushed a commit that referenced this pull request Jun 21, 2018
@davisjam @jasnell
doc: note synchronous part of child_process.spawn
25e5ae4
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: #14917

PR-URL: #21234
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@jasnell

jasnell commented Jun 21, 2018

Copy link
Copy Markdown
Member

Landed in 25e5ae4

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@jasnell jasnell closed this Jun 21, 2018
targos pushed a commit that referenced this pull request Jun 22, 2018
@davisjam @targos
doc: note synchronous part of child_process.spawn
8a997a5
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: #14917

PR-URL: #21234
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Ben Noordhuis <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@targos targos mentioned this pull request Jul 3, 2018
v10.6.0 proposal #21629
Merged
@jgehrcke jgehrcke mentioned this pull request May 26, 2020
child_process.spawn: does not throw error when uv_spawn() fails #33566
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@bnoordhuis bnoordhuis bnoordhuis approved these changes
@jasnell jasnell jasnell approved these changes
@gireeshpunathil gireeshpunathil gireeshpunathil approved these changes
@trivikr trivikr trivikr approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

child_process Issues and PRs related to the child_process subsystem. doc Issues and PRs related to Node.js documentation.

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

9 participants

@davisjam @vsemozhetbyt @mscdex @Trott @bnoordhuis @jasnell @gireeshpunathil @trivikr @nodejs-github-bot
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.