Skip to content

Commit 1abff07

Browse files
authored
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: #52037 Refs: #46608 Refs: #50120 Reviewed-By: Rafael Gonzaga <[email protected]> Reviewed-By: Matteo Collina <[email protected]> Reviewed-By: Yagiz Nizipli <[email protected]> Reviewed-By: Chengzhong Wu <[email protected]> Reviewed-By: Moshe Atlow <[email protected]> Reviewed-By: Mohammed Keyvanzadeh <[email protected]> Reviewed-By: Trivikram Kamat <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 57d2e48 commit 1abff07

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
@@ -3479,6 +3479,9 @@ method.
34793479

34803480
<!-- YAML
34813481
changes:
3482+
- version: REPLACEME
3483+
pr-url: https://github.com/nodejs/node/pull/52037
3484+
description: bump default highWaterMark.
34823485
- version: v15.5.0
34833486
pr-url: https://github.com/nodejs/node/pull/36431
34843487
description: support passing in an AbortSignal.
@@ -3500,7 +3503,7 @@ changes:
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
@@ -3856,6 +3859,9 @@ constructor and implement the [`readable._read()`][] method.
38563859

38573860
<!-- YAML
38583861
changes:
3862+
- version: REPLACEME
3863+
pr-url: https://github.com/nodejs/node/pull/52037
3864+
description: bump default highWaterMark.
38593865
- version: v15.5.0
38603866
pr-url: https://github.com/nodejs/node/pull/36431
38613867
description: support passing in an AbortSignal.
@@ -3873,7 +3879,7 @@ changes:
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)