Skip to content

Commit 207a3f5

Browse files
committed
stream: bump default highWaterMark
This should give a performance boost accross the board. Given that the old limit is a decod old and memory capacity has doubled many times since I think it is appropriate to slightly bump the default limit. PR-URL: nodejs#52037 Refs: nodejs#46608 Refs: nodejs#50120
1 parent 1f19316 commit 207a3f5

18 files changed

+34
-19
lines changed

benchmark/net/net-c2s.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const net = require('net');
66
const PORT = common.PORT;
77

88
const bench = common.createBenchmark(main, {
9-
len: [64, 102400, 1024 * 1024 * 16],
9+
len: [64, 102400, 1024 * 64 * 16],
1010
type: ['utf', 'asc', 'buf'],
1111
dur: [5],
1212
}, {

benchmark/net/net-pipe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const net = require('net');
66
const PORT = common.PORT;
77

88
const bench = common.createBenchmark(main, {
9-
len: [2, 64, 102400, 1024 * 1024 * 16],
9+
len: [2, 64, 102400, 1024 * 64 * 16],
1010
type: ['utf', 'asc', 'buf'],
1111
dur: [5],
1212
}, {

benchmark/net/net-s2c.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const common = require('../common.js');
55
const PORT = common.PORT;
66

77
const bench = common.createBenchmark(main, {
8-
sendchunklen: [256, 32 * 1024, 128 * 1024, 16 * 1024 * 1024],
8+
sendchunklen: [256, 32 * 1024, 128 * 1024, 16 * 64 * 1024],
99
type: ['utf', 'asc', 'buf'],
1010
recvbuflen: [0, 64 * 1024, 1024 * 1024],
1111
recvbufgenfn: ['true', 'false'],

benchmark/net/net-wrap-js-stream-passthrough.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ const common = require('../common.js');
55
const { PassThrough } = require('stream');
66

77
const bench = common.createBenchmark(main, {
8-
len: [64, 102400, 1024 * 1024 * 16],
8+
len: [64, 102400, 1024 * 64 * 16],
99
type: ['utf', 'asc', 'buf'],
1010
dur: [5],
1111
}, {

benchmark/net/tcp-raw-c2s.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const util = require('util');
99
// run the function with those settings.
1010
// if not, then queue up a bunch of child processes.
1111
const bench = common.createBenchmark(main, {
12-
len: [102400, 1024 * 1024 * 16],
12+
len: [102400, 1024 * 64 * 16],
1313
type: ['utf', 'asc', 'buf'],
1414
dur: [5],
1515
}, {

benchmark/net/tcp-raw-pipe.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const util = require('util');
99
// run the function with those settings.
1010
// if not, then queue up a bunch of child processes.
1111
const bench = common.createBenchmark(main, {
12-
len: [102400, 1024 * 1024 * 16],
12+
len: [102400, 1024 * 64 * 16],
1313
type: ['utf', 'asc', 'buf'],
1414
dur: [5],
1515
}, {

benchmark/net/tcp-raw-s2c.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const util = require('util');
99
// run the function with those settings.
1010
// If not, then queue up a bunch of child processes.
1111
const bench = common.createBenchmark(main, {
12-
len: [102400, 1024 * 1024 * 16],
12+
len: [102400, 1024 * 64 * 16],
1313
type: ['utf', 'asc', 'buf'],
1414
dur: [5],
1515
}, {

doc/api/stream.md

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3495,12 +3495,15 @@ changes:
34953495
pr-url: https://github.com/nodejs/node/pull/18438
34963496
description: Add `emitClose` option to specify if `'close'` is emitted on
34973497
destroy.
3498+
- version: REPLACEME
3499+
pr-url: https://github.com/nodejs/node/pull/52037
3500+
description: bump default highWaterMark
34983501
-->
34993502

35003503
* `options` {Object}
35013504
* `highWaterMark` {number} Buffer level when
35023505
[`stream.write()`][stream-write] starts returning `false`. **Default:**
3503-
`16384` (16 KiB), or `16` for `objectMode` streams.
3506+
`65536` (64 KiB), or `16` for `objectMode` streams.
35043507
* `decodeStrings` {boolean} Whether to encode `string`s passed to
35053508
[`stream.write()`][stream-write] to `Buffer`s (with the encoding
35063509
specified in the [`stream.write()`][stream-write] call) before passing
@@ -3868,12 +3871,15 @@ changes:
38683871
pr-url: https://github.com/nodejs/node/pull/22795
38693872
description: Add `autoDestroy` option to automatically `destroy()` the
38703873
stream when it emits `'end'` or errors.
3874+
- version: REPLACEME
3875+
pr-url: https://github.com/nodejs/node/pull/52037
3876+
description: bump default highWaterMark
38713877
-->
38723878

38733879
* `options` {Object}
38743880
* `highWaterMark` {number} The maximum [number of bytes][hwm-gotcha] to store
38753881
in the internal buffer before ceasing to read from the underlying resource.
3876-
**Default:** `16384` (16 KiB), or `16` for `objectMode` streams.
3882+
**Default:** `65536` (64 KiB), or `16` for `objectMode` streams.
38773883
* `encoding` {string} If specified, then buffers will be decoded to
38783884
strings using the specified encoding. **Default:** `null`.
38793885
* `objectMode` {boolean} Whether this stream should behave

lib/internal/streams/state.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ const { validateInteger } = require('internal/validators');
88

99
const { ERR_INVALID_ARG_VALUE } = require('internal/errors').codes;
1010

11-
let defaultHighWaterMarkBytes = 16 * 1024;
11+
// TODO (fix): For some reason Windows CI fails with bigger hwm.
12+
let defaultHighWaterMarkBytes = process.platform === 'win32' ? 16 * 1024 : 64 * 1024;
1213
let defaultHighWaterMarkObjectMode = 16;
1314

1415
function highWaterMarkFrom(options, isDuplex, duplexKey) {

test/parallel/test-http-no-read-no-dump.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ const server = http.createServer((req, res) => {
3434
}, common.mustCall((res) => {
3535
res.resume();
3636

37-
post.write(Buffer.alloc(16 * 1024).fill('X'));
37+
post.write(Buffer.alloc(64 * 1024).fill('X'));
3838
onPause = () => {
3939
post.end('something');
4040
};

0 commit comments

Comments
 (0)