Skip to content

Commit cc2c84d

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 cc2c84d

18 files changed

+30
-20
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: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,12 @@
22
'use strict';
33

44
const common = require('../common.js');
5-
const { PassThrough } = require('stream');
5+
const { PassThrough, setDefaultHighWaterMark } = require('stream');
6+
7+
setDefaultHighWaterMark(false, 16 * 1024);
68

79
const bench = common.createBenchmark(main, {
8-
len: [64, 102400, 1024 * 1024 * 16],
10+
len: [64, 102400, 1024 * 64 * 16],
911
type: ['utf', 'asc', 'buf'],
1012
dur: [5],
1113
}, {

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: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3500,7 +3500,7 @@ changes:
35003500
* `options` {Object}
35013501
* `highWaterMark` {number} Buffer level when
35023502
[`stream.write()`][stream-write] starts returning `false`. **Default:**
3503-
`16384` (16 KiB), or `16` for `objectMode` streams.
3503+
`65536` (64 KiB), or `16` for `objectMode` streams.
35043504
* `decodeStrings` {boolean} Whether to encode `string`s passed to
35053505
[`stream.write()`][stream-write] to `Buffer`s (with the encoding
35063506
specified in the [`stream.write()`][stream-write] call) before passing
@@ -3873,7 +3873,7 @@ changes:
38733873
* `options` {Object}
38743874
* `highWaterMark` {number} The maximum [number of bytes][hwm-gotcha] to store
38753875
in the internal buffer before ceasing to read from the underlying resource.
3876-
**Default:** `16384` (16 KiB), or `16` for `objectMode` streams.
3876+
**Default:** `65536` (64 KiB), or `16` for `objectMode` streams.
38773877
* `encoding` {string} If specified, then buffers will be decoded to
38783878
strings using the specified encoding. **Default:** `null`.
38793879
* `objectMode` {boolean} Whether this stream should behave

lib/internal/streams/state.js

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

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

11-
let defaultHighWaterMarkBytes = 16 * 1024;
11+
let defaultHighWaterMarkBytes = 64 * 1024;
1212
let defaultHighWaterMarkObjectMode = 16;
1313

1414
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)