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: fix up warning text about character devices by addaleax · Pull Request #22569 · nodejs/node

Conversation

@addaleax

@addaleax addaleax commented Aug 28, 2018

Copy link
Copy Markdown
Member

The text contained a number of inaccuracies:

  • The main thread is never blocked by a stream close.
  • There is no such thing as an EOF character on the OS level,
    the libuv level, or the Node.js stream level.
  • These streams do respond to .close(), but pending
    reads can delay this indefinitely.
  • Pushing a random character into the stream works only when
    the source data can be controlled; Using the JS .push()
    method is something different, and does not “unblock” any threads.

Refs: #21212

Pinging previous reviewers: @gireeshpunathil @vsemozhetbyt @jasnell @trivikr

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • 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.

vsemozhetbyt, yuanxin7835, and antsmartian reacted with thumbs up emoji
All reactions
  • 👍 3 reactions
@addaleax
doc: fix up warning text about character devices
56578ba
The text contained a number of inaccuracies:

- The main thread is never blocked by a stream close.
- There is no such thing as an EOF character on the OS level,
  the libuv level, or the Node.js stream level.
- These streams *do* respond to `.close()`, but pending
  reads can delay this indefinitely.
- Pushing a random character into the stream works only when
  the source data can be controlled; Using the JS `.push()`
  method is something different, and does not “unblock” any threads.

Refs: nodejs#21212
@nodejs-github-bot

nodejs-github-bot commented Aug 28, 2018

Copy link
Copy Markdown
Collaborator

@addaleax build started: https://ci.nodejs.org/blue/organizations/jenkins/node-test-pull-request-lite-pipeline/detail/node-test-pull-request-lite-pipeline/713/pipeline

All reactions

Sorry, something went wrong.

Uh oh!

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

@nodejs-github-bot nodejs-github-bot added doc Issues and PRs related to Node.js documentation. fs Issues and PRs related to file-system APIs and the fs module. labels Aug 28, 2018
gireeshpunathil
gireeshpunathil approved these changes Aug 28, 2018
View reviewed changes
@gireeshpunathil

gireeshpunathil commented Aug 28, 2018

Copy link
Copy Markdown
Member

@addaleax - thanks for the rework. I am not fully aligned to your PR description, but the doc change is much more crisp and cleaner than mine, so I am good here. The inner details of what is happening at the thread and descriptor level is here: #15439 (comment) in case if you haven't already seen that.

All reactions

Sorry, something went wrong.

Uh oh!

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

@addaleax

addaleax commented Aug 28, 2018

Copy link
Copy Markdown
Member Author

@gireeshpunathil You can feel free to point out if I’m mistaken about anything. Regarding your linked comment:

As the file system work is carried out by internal worker thread, and it has initiated a blocking read from the device, and the data won't come, the main thread is unable to move ahead - it is held up in the polling for an async event that has to come from the said worker.

That issue pops up when we exhaust the thread pool, or when we try to exit the process (which involves waiting for all threads on POSIX systems), but before that the main thread should be unaffected?

gireeshpunathil 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.

@gireeshpunathil

gireeshpunathil commented Aug 28, 2018

Copy link
Copy Markdown
Member

this is how I visualized the issue:

  • a stream read is initiated. a worker thread is assigned to read.
  • as long as reads are happening, everything is fine.
  • when the device has no data, the worker thread blocks.
  • stream close has no effect as the fd in question is already engaged in reading.
  • when there is no other work pending (other than reading), loop thread invokes epoll_wait() with infinite timeout on the async handle pertinent to the async work. there is no way to alter this, so main thread blocks (this is not necessarily the exit route I guess)

EOF: character devices differ from block devices (such as files) in that the later issue a special character that causes the syscall.read() to yield. In char devices, the reader has to decide when to stop. When streams are abstracted around such devices, this mechanism is missing.

All reactions

Sorry, something went wrong.

Uh oh!

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

@addaleax

addaleax commented Aug 28, 2018

Copy link
Copy Markdown
Member Author

when there is no other work pending (other than reading), loop thread invokes epoll_wait() with infinite timeout on the async handle pertinent to the async work. there is no way to alter this, so main thread blocks (this is not necessarily the exit route I guess)

I guess that’s right, but we don’t usually refer to this as the main thread being blocked when it’s waiting for something to happen (but rather when it cannot get to the state of waiting for something to happen), do we?

And for the EOF character – that might be OS-dependent, but whether or not a special character is used on the hardware level is transparent to everything provided from the syscall level and upward, so it’s probably not a topic for our own docs?

All reactions

Sorry, something went wrong.

Uh oh!

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

@gireeshpunathil

gireeshpunathil commented Aug 28, 2018

Copy link
Copy Markdown
Member

agreed to both your points, thanks!

All reactions

Sorry, something went wrong.

Uh oh!

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

lpinca
lpinca approved these changes Aug 28, 2018
View reviewed changes
trivikr
trivikr approved these changes Aug 29, 2018
View reviewed changes
@addaleax

addaleax commented Aug 31, 2018

Copy link
Copy Markdown
Member Author

Landed in f2338ed

All reactions

Sorry, something went wrong.

Uh oh!

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

@addaleax addaleax closed this Aug 31, 2018
@addaleax
addaleax deleted the fixup-fs-text branch August 31, 2018 17:16
addaleax added a commit that referenced this pull request Aug 31, 2018
@addaleax
doc: fix up warning text about character devices
f2338ed
The text contained a number of inaccuracies:

- The main thread is never blocked by a stream close.
- There is no such thing as an EOF character on the OS level,
  the libuv level, or the Node.js stream level.
- These streams *do* respond to `.close()`, but pending
  reads can delay this indefinitely.
- Pushing a random character into the stream works only when
  the source data can be controlled; Using the JS `.push()`
  method is something different, and does not “unblock” any threads.

Refs: #21212

PR-URL: #22569
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
addaleax added a commit that referenced this pull request Aug 31, 2018
@addaleax
doc: fix up warning text about character devices
09f733e
The text contained a number of inaccuracies:

- The main thread is never blocked by a stream close.
- There is no such thing as an EOF character on the OS level,
  the libuv level, or the Node.js stream level.
- These streams *do* respond to `.close()`, but pending
  reads can delay this indefinitely.
- Pushing a random character into the stream works only when
  the source data can be controlled; Using the JS `.push()`
  method is something different, and does not “unblock” any threads.

Refs: #21212

PR-URL: #22569
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
targos pushed a commit that referenced this pull request Sep 3, 2018
@addaleax @targos
doc: fix up warning text about character devices
bfdb28e
The text contained a number of inaccuracies:

- The main thread is never blocked by a stream close.
- There is no such thing as an EOF character on the OS level,
  the libuv level, or the Node.js stream level.
- These streams *do* respond to `.close()`, but pending
  reads can delay this indefinitely.
- Pushing a random character into the stream works only when
  the source data can be controlled; Using the JS `.push()`
  method is something different, and does not “unblock” any threads.

Refs: #21212

PR-URL: #22569
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
@targos targos mentioned this pull request Sep 5, 2018
Release proposal: v10.10.0 #22716
Merged
targos pushed a commit that referenced this pull request Sep 6, 2018
@addaleax @targos
doc: fix up warning text about character devices
2a83628
The text contained a number of inaccuracies:

- The main thread is never blocked by a stream close.
- There is no such thing as an EOF character on the OS level,
  the libuv level, or the Node.js stream level.
- These streams *do* respond to `.close()`, but pending
  reads can delay this indefinitely.
- Pushing a random character into the stream works only when
  the source data can be controlled; Using the JS `.push()`
  method is something different, and does not “unblock” any threads.

Refs: #21212

PR-URL: #22569
Reviewed-By: Gireesh Punathil <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Trivikram Kamat <[email protected]>
This was referenced Sep 6, 2018
2018-09-06 Version 10.10.0 (Current) @targos beevelop/docker-android-nodejs#236
Closed
2018-09-06 Version 10.10.0 (Current) @targos beevelop/docker-nodejs#221
Closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@lpinca lpinca lpinca 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

doc Issues and PRs related to Node.js documentation. fs Issues and PRs related to file-system APIs and the fs module.

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.

5 participants

@addaleax @nodejs-github-bot @gireeshpunathil @lpinca @trivikr
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.