-
Notifications
You must be signed in to change notification settings - Fork 286
Use pipe_wrap for IO #834
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Use pipe_wrap for IO #834
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
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.
Original version did use
pipe_wrap3913479, however the comment about deprecated api made the transition to the bug prone tty.ReadStream usage for write.It should be fine now with the fallback we have in place and also the deprecated comment is not correct https://github.com/nodejs/node/blob/05f8772096f974190b11eabce0ea657bc5c8c1b1/lib/internal/bootstrap/realm.js#L84-L163
Uh oh!
There was an error while loading. Please reload this page.
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.
On the other hand, we could implement the pipe_wrap equivalent version using uv_write which does the polling for us and also remove the fallback.
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 knew about pty.js but didn't realize you also used to use this approach!
I have also considered doing this, and possibly go even a step further and not use libuv at all (synchronous PTY calls should be a little bit faster). But @Tyriar suggested that ideally, we'd use as little C/C++ as possible in this project. Reading through node.js didn't give me the impression that process.binding or pipe_wrap are expected to go away any time soon. Perhaps I misjudged that, however. Essentially, we'd simply copy the pipe_wrap code, wouldn't we? I could do that.
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.
You are right, there was some confusion around this. But my latest take based on nodejs/TSC#1482 (comment) and the redirection to internal binding https://github.com/nodejs/node/blob/05f8772096f974190b11eabce0ea657bc5c8c1b1/lib/internal/bootstrap/realm.js#L84-L163 this is not going away anytime soon.
It is also the approach currently being implemented in libuv/libuv#4802. The reason we started non-blocking mode is for the PTY host in VS Code to remain responsive to multiple terminal sessions and other process interactions (extension host, workbench), seems like a deal breaker ?
Right, I was thinking we replace the write part with native
uv_writeand the read part can be based off tty.ReadStream. However if we bring in the buffer handling pieces it would almost be equivalent to write implementation in pipe_wrap. Maybe we just go back to only having the current pipe_wrap code in this PR (remove the fallback) till either@Tyriar thoughts ?
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.
This was a bug with the implementation I was aware of, I just wasn't hitting it in my ascii test as the codepoint offset is the byte offset in that case. #835 looks good but I suspect we still need to handle
EAGAIN. Will look at that.@deepak1556 this would be a hack that you'd have to maintain as monkey patching could break at any time and you're the one that daals with the node updates. Given what we've learned the last week, it's up to you how you'd like to handle it considering: