From f01518edfd83e2235d84485d87621e61f675b4a7 Mon Sep 17 00:00:00 2001 From: Anna Henningsen Date: Tue, 23 Oct 2018 08:23:02 +0200 Subject: src: improve StreamBase write throughput Improve performance by transferring information about write status to JS through an `AliasedBuffer`, rather than object properties set from C++. PR-URL: https://github.com/nodejs/node/pull/23843 Reviewed-By: James M Snell Reviewed-By: Anatoli Papirovski --- lib/internal/child_process.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/internal/child_process.js') diff --git a/lib/internal/child_process.js b/lib/internal/child_process.js index a2478ec69d..ddb7e58d7c 100644 --- a/lib/internal/child_process.js +++ b/lib/internal/child_process.js @@ -26,6 +26,7 @@ const { WriteWrap, kReadBytesOrError, kArrayBufferOffset, + kLastWriteWasAsync, streamBaseState } = internalBinding('stream_wrap'); const { Pipe, constants: PipeConstants } = internalBinding('pipe_wrap'); @@ -716,10 +717,10 @@ function setupChannel(target, channel) { } var req = new WriteWrap(); - req.async = false; var string = JSON.stringify(message) + '\n'; var err = channel.writeUtf8String(req, string, handle); + var wasAsyncWrite = streamBaseState[kLastWriteWasAsync]; if (err === 0) { if (handle) { @@ -729,7 +730,7 @@ function setupChannel(target, channel) { obj.postSend(message, handle, options, callback, target); } - if (req.async) { + if (wasAsyncWrite) { req.oncomplete = function() { control.unref(); if (typeof callback === 'function') -- cgit v1.2.3