Skip to content

Commit

Permalink
child_process: improve ipc write performance
Browse files Browse the repository at this point in the history
  • Loading branch information
CaramelFur committed Jun 15, 2022
1 parent abd50a0 commit 24da8ae
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions lib/internal/child_process/serialization.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,15 +106,17 @@ const advanced = {
const sizeBuffer = Buffer.allocUnsafe(4);
sizeBuffer.writeUInt32BE(serializedMessage.length);

const buffer = Buffer.concat([
sizeBuffer,
serializedMessage,
]);
const result = channel.writeBuffer(req, buffer, handle);
const result_sizeBuffer = channel.writeBuffer(req, sizeBuffer, handle);
const result_serializedMessage = channel.writeBuffer(req, serializedMessage, handle);

// Mirror what stream_base_commons.js does for Buffer retention.
if (streamBaseState[kLastWriteWasAsync])
req.buffer = buffer;
return result;
req.buffer = [
sizeBuffer,
serializedMessage,
];

return result_sizeBuffer ?? result_serializedMessage;
},
};

Expand Down

0 comments on commit 24da8ae

Please sign in to comment.