Unverified Commit 64d2ffe2 authored by Tobias Koppers's avatar Tobias Koppers Committed by GitHub

Turbopack: enable nodelay for node.js pool socket (#83942)

### What?

Removes delays from sending data from and to the worker process.
parent 8b0d684c
...@@ -80,6 +80,7 @@ function createIpc<TIncoming, TOutgoing>( ...@@ -80,6 +80,7 @@ function createIpc<TIncoming, TOutgoing>(
let state: State = { type: 'waiting' } let state: State = { type: 'waiting' }
let buffer: Buffer = Buffer.alloc(0) let buffer: Buffer = Buffer.alloc(0)
socket.once('connect', () => { socket.once('connect', () => {
socket.setNoDelay(true)
socket.on('data', (chunk) => { socket.on('data', (chunk) => {
buffer = Buffer.concat([buffer, chunk]) buffer = Buffer.concat([buffer, chunk])
......
...@@ -431,6 +431,7 @@ impl NodeJsPoolProcess { ...@@ -431,6 +431,7 @@ impl NodeJsPoolProcess {
bail!("timed out waiting for the Node.js process to connect ({timeout:?} timeout)\nProcess output:\n{stdout}\nProcess error output:\n{stderr}"); bail!("timed out waiting for the Node.js process to connect ({timeout:?} timeout)\nProcess output:\n{stdout}\nProcess error output:\n{stderr}");
}, },
}; };
connection.set_nodelay(true)?;
let child_stdout = BufReader::new(child.stdout.take().unwrap()); let child_stdout = BufReader::new(child.stdout.take().unwrap());
let child_stderr = BufReader::new(child.stderr.take().unwrap()); let child_stderr = BufReader::new(child.stderr.take().unwrap());
...@@ -540,6 +541,10 @@ impl NodeJsPoolProcess { ...@@ -540,6 +541,10 @@ impl NodeJsPoolProcess {
.write_all(&packet_data) .write_all(&packet_data)
.await .await
.context("writing packet data")?; .context("writing packet data")?;
self.connection
.flush()
.await
.context("flushing packet data")?;
Ok(()) Ok(())
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment