summaryrefslogtreecommitdiff
path: root/ext/node/polyfills/internal_binding/tcp_wrap.ts
diff options
context:
space:
mode:
authorDivy Srivastava <dj.srivastava23@gmail.com>2024-10-15 14:47:12 +0530
committerGitHub <noreply@github.com>2024-10-15 14:47:12 +0530
commitc7153838ec332d474c32b464b94f99382028bbbc (patch)
tree0bad18f8d4e8fede049ebe9be1e19fc26788a965 /ext/node/polyfills/internal_binding/tcp_wrap.ts
parent7bfec3817310c6197ef49694a51d53365ac8d038 (diff)
fix(ext/node): implement TCP.setNoDelay (#26263)
Fixes https://github.com/denoland/deno/issues/26177 The significant delay was caused by Nagel's algorithm + delayed ACKs in Linux kernels. Here's the [kernel patch](https://lwn.net/Articles/502585/) which added 40ms `tcp_default_delack_min` ``` $ deno run -A pg-bench.mjs # main Tue Oct 15 2024 12:27:22 GMT+0530 (India Standard Time): 42ms $ target/release/deno run -A pg-bench.mjs # this patch Tue Oct 15 2024 12:28:02 GMT+0530 (India Standard Time): 1ms ``` ```js import { Buffer } from "node:buffer"; import pg from 'pg' const { Client } = pg const client = new Client({ connectionString: 'postgresql://postgres:postgres@127.0.0.1:5432/postgres' }) await client.connect() async function fetch() { const startPerf = performance.now(); const res = await client.query(`select $1::int as int, $2 as string, $3::timestamp with time zone as timestamp, $4 as null, $5::bool as boolean, $6::bytea as bytea, $7::jsonb as json `, [ 1337, 'wat', new Date().toISOString(), null, false, Buffer.from('awesome'), JSON.stringify([{ some: 'json' }, { array: 'object' }]) ]) console.log(`${new Date()}: ${Math.round(performance.now() - startPerf)}ms`) } for(;;) await fetch(); ```
Diffstat (limited to 'ext/node/polyfills/internal_binding/tcp_wrap.ts')
-rw-r--r--ext/node/polyfills/internal_binding/tcp_wrap.ts4
1 files changed, 2 insertions, 2 deletions
diff --git a/ext/node/polyfills/internal_binding/tcp_wrap.ts b/ext/node/polyfills/internal_binding/tcp_wrap.ts
index 973a1d1c0..1321cc627 100644
--- a/ext/node/polyfills/internal_binding/tcp_wrap.ts
+++ b/ext/node/polyfills/internal_binding/tcp_wrap.ts
@@ -299,8 +299,8 @@ export class TCP extends ConnectionWrap {
* @param noDelay
* @return An error status code.
*/
- setNoDelay(_noDelay: boolean): number {
- // TODO(bnoordhuis) https://github.com/denoland/deno/pull/13103
+ setNoDelay(noDelay: boolean): number {
+ this[kStreamBaseField].setNoDelay(noDelay);
return 0;
}