-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
src: refactor HasWriteQueue() away #18019
Conversation
CI: https://ci.nodejs.org/job/node-test-commit/15267/ |
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.
SGTM if the CI is green. When I worked on this last, there were some cross-system issues around having net
writes be async with no actual write queue (which is why we used to have the check for writeQueueSize
right in _writeGeneric
).
@apapirovski I’m not sure if that’s what you’re talking about, but the first commit here works around the fact that, while pipes on Windows can be set to blocking, they always need |
@addaleax It's been too long to remember. The bit re: Windows pipes makes sense and the code looks good to me. I feel like there might've been a different issue on linux, although it might've just been the repl test, as you mentioned. Either way, the code looks good to me. 👍 |
(this._handle instanceof Pipe) && | ||
process.platform === 'win32') { | ||
// Make stdout and stderr blocking on Windows | ||
var err = this._handle.setBlocking(true); | ||
if (err) | ||
throw errnoException(err, 'setBlocking'); | ||
|
||
this._writev = null; | ||
this._write = makeSyncWrite(fd); |
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.
Can we assign fd
to a symbol property here and do the if logic in Socket.prototype._write
to avoid the additional closure?
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.
@joyeecheung I have thought about making fd
a property for all net.Socket
s, but I’m not sure whether that’s a good idea or not.
We could add a symbol, but for now I’d probably leave the code as it is, especially given that the worst case is that this might create 2 closures for the entire process…
c394888
to
255630c
Compare
This avoids routing writes through the full LibuvStreamWrap write machinery. In particular, it enables the next commit, because otherwise the callback passed to `_write()` would not be called synchronously for pipes on Windows (because the latter does not support `uv_try_write()`, even for blocking I/O).
Tests are passing without it, and this otherwise makes the code harder to reason about because the `async` flag on the write request object would not be set even though the callback would still be pending.
255630c
to
72ff460
Compare
Did some experimenting to keep the benchmarks happy. I ran these on a largely unused machine, since the benchmark CI is currently blocked, for the combination of parameters that seemed most problematic, with 90 runs to be on the safe side:
I’m good with landing this in this state, there does not seem to be any performance difference anymore. (This would fit the symptoms – New CI: https://ci.nodejs.org/job/node-test-pull-request/12493/ Could somebody review the last commit here? Edit: Scheduled benchmark CI @ https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/94/ |
last commit lgtm |
Landed in c84582c...02fef8a |
This avoids routing writes through the full LibuvStreamWrap write machinery. In particular, it enables the next commit, because otherwise the callback passed to `_write()` would not be called synchronously for pipes on Windows (because the latter does not support `uv_try_write()`, even for blocking I/O). PR-URL: #18019 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Tests are passing without it, and this otherwise makes the code harder to reason about because the `async` flag on the write request object would not be set even though the callback would still be pending. PR-URL: #18019 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Tests are passing without it, and this otherwise makes the code harder to reason about because the `async` flag on the write request object would not be set even though the callback would still be pending. PR-URL: #18019 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #18019 Reviewed-By: James M Snell <[email protected]>
This broke writing non-ASCII data to the console on Windows because the result would be codepage-dependent. This partially reverts 8b751f7. Fixes: #18189 Refs: #18019 PR-URL: #18214 Fixes: #18189 Refs: #18019 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Add two regression tests for stdio over pipes. test-stdio-pipe-access tests if accessing stdio pipe that is being read by another process does not deadlocks Node.js. This was reported in #10836 and was fixed in v8.3.0. The deadlock would happen intermittently, so we run the test 5 times. test-stdio-pipe-redirect tests if redirecting one child process stdin to another process stdout does not crash Node as reported in #17493. It was fixed in #18019. PR-URL: #18614 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
This avoids routing writes through the full LibuvStreamWrap write machinery. In particular, it enables the next commit, because otherwise the callback passed to `_write()` would not be called synchronously for pipes on Windows (because the latter does not support `uv_try_write()`, even for blocking I/O). PR-URL: #18019 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Tests are passing without it, and this otherwise makes the code harder to reason about because the `async` flag on the write request object would not be set even though the callback would still be pending. PR-URL: #18019 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #18019 Reviewed-By: James M Snell <[email protected]>
This broke writing non-ASCII data to the console on Windows because the result would be codepage-dependent. This partially reverts 8b751f7. Fixes: #18189 Refs: #18019 PR-URL: #18214 Fixes: #18189 Refs: #18019 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Add two regression tests for stdio over pipes. test-stdio-pipe-access tests if accessing stdio pipe that is being read by another process does not deadlocks Node.js. This was reported in #10836 and was fixed in v8.3.0. The deadlock would happen intermittently, so we run the test 5 times. test-stdio-pipe-redirect tests if redirecting one child process stdin to another process stdout does not crash Node as reported in #17493. It was fixed in #18019. PR-URL: #18614 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Add two regression tests for stdio over pipes. test-stdio-pipe-access tests if accessing stdio pipe that is being read by another process does not deadlocks Node.js. This was reported in #10836 and was fixed in v8.3.0. The deadlock would happen intermittently, so we run the test 5 times. test-stdio-pipe-redirect tests if redirecting one child process stdin to another process stdout does not crash Node as reported in #17493. It was fixed in #18019. PR-URL: #18614 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
This broke writing non-ASCII data to the console on Windows because the result would be codepage-dependent. This partially reverts 8b751f7. Fixes: nodejs#18189 Refs: nodejs#18019 PR-URL: nodejs#18214 Fixes: nodejs#18189 Refs: nodejs#18019 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
Add two regression tests for stdio over pipes. test-stdio-pipe-access tests if accessing stdio pipe that is being read by another process does not deadlocks Node.js. This was reported in nodejs#10836 and was fixed in v8.3.0. The deadlock would happen intermittently, so we run the test 5 times. test-stdio-pipe-redirect tests if redirecting one child process stdin to another process stdout does not crash Node as reported in nodejs#17493. It was fixed in nodejs#18019. PR-URL: nodejs#18614 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
@addaleax should this be backported to |
Add two regression tests for stdio over pipes. test-stdio-pipe-access tests if accessing stdio pipe that is being read by another process does not deadlocks Node.js. This was reported in #10836 and was fixed in v8.3.0. The deadlock would happen intermittently, so we run the test 5 times. test-stdio-pipe-redirect tests if redirecting one child process stdin to another process stdout does not crash Node as reported in #17493. It was fixed in #18019. PR-URL: #18614 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Add two regression tests for stdio over pipes. test-stdio-pipe-access tests if accessing stdio pipe that is being read by another process does not deadlocks Node.js. This was reported in #10836 and was fixed in v8.3.0. The deadlock would happen intermittently, so we run the test 5 times. test-stdio-pipe-redirect tests if redirecting one child process stdin to another process stdout does not crash Node as reported in #17493. It was fixed in #18019. PR-URL: #18614 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Add two regression tests for stdio over pipes. test-stdio-pipe-access tests if accessing stdio pipe that is being read by another process does not deadlocks Node.js. This was reported in #10836 and was fixed in v8.3.0. The deadlock would happen intermittently, so we run the test 5 times. test-stdio-pipe-redirect tests if redirecting one child process stdin to another process stdout does not crash Node as reported in #17493. It was fixed in #18019. PR-URL: #18614 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
Add two regression tests for stdio over pipes. test-stdio-pipe-access tests if accessing stdio pipe that is being read by another process does not deadlocks Node.js. This was reported in #10836 and was fixed in v8.3.0. The deadlock would happen intermittently, so we run the test 5 times. test-stdio-pipe-redirect tests if redirecting one child process stdin to another process stdout does not crash Node as reported in #17493. It was fixed in #18019. PR-URL: #18614 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
I've gone ahead and landed this on v8.x as it fixes a broken test that was already landed 20f6aae was not included as |
This avoids routing writes through the full LibuvStreamWrap write machinery. In particular, it enables the next commit, because otherwise the callback passed to `_write()` would not be called synchronously for pipes on Windows (because the latter does not support `uv_try_write()`, even for blocking I/O). PR-URL: #18019 Reviewed-By: Anatoli Papirovski <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
PR-URL: #18019 Reviewed-By: James M Snell <[email protected]>
This broke writing non-ASCII data to the console on Windows because the result would be codepage-dependent. This partially reverts 8b751f7. Fixes: #18189 Refs: #18019 PR-URL: #18214 Fixes: #18189 Refs: #18019 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
process: use more direct sync I/O for stdio
This avoids routing writes through the full LibuvStreamWrap
write machinery. In particular, it enables the next commit,
because otherwise the callback passed to
_write()
would not be called synchronously for pipes on Windows
(because the latter does not support
uv_try_write()
,even for blocking I/O).
src: remove
HasWriteQueue()
Tests are passing without it now, and this otherwise makes the
code harder to reason about because the
async
flag on thewrite request object would not be set even though the callback
would still be pending.
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
src/stream_base
/cc @apapirovski