Skip to content

Commit 6a344e4

Browse files
committed
doc: correct default highWaterMark values
File write streams inherit the default byte-stream highWaterMark. The fixed 16 KiB value became stale when that default changed. Also document the Windows-specific byte-stream default. Signed-off-by: umuoy1 <burningdian@gmail.com>
1 parent 2b350bb commit 6a344e4

2 files changed

Lines changed: 17 additions & 6 deletions

File tree

doc/api/fs.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,6 +323,9 @@ fd.createReadStream({ start: 90, end: 99 });
323323
<!-- YAML
324324
added: v16.11.0
325325
changes:
326+
- version: v22.0.0
327+
pr-url: https://github.com/nodejs/node/pull/52037
328+
description: bump default highWaterMark.
326329
- version:
327330
- v21.0.0
328331
- v20.10.0
@@ -335,7 +338,8 @@ changes:
335338
* `autoClose` {boolean} **Default:** `true`
336339
* `emitClose` {boolean} **Default:** `true`
337340
* `start` {integer}
338-
* `highWaterMark` {number} **Default:** `16384`
341+
* `highWaterMark` {number} **Default:** See
342+
[`stream.getDefaultHighWaterMark()`][].
339343
* `flush` {boolean} If `true`, the underlying file descriptor is flushed
340344
prior to closing it. **Default:** `false`.
341345
* Returns: {fs.WriteStream}
@@ -3066,6 +3070,9 @@ If `options` is a string, then it specifies the encoding.
30663070
<!-- YAML
30673071
added: v0.1.31
30683072
changes:
3073+
- version: v22.0.0
3074+
pr-url: https://github.com/nodejs/node/pull/52037
3075+
description: bump default highWaterMark.
30693076
- version:
30703077
- v21.0.0
30713078
- v20.10.0
@@ -3123,7 +3130,8 @@ changes:
31233130
* `start` {integer}
31243131
* `fs` {Object|null} **Default:** `null`
31253132
* `signal` {AbortSignal|null} **Default:** `null`
3126-
* `highWaterMark` {number} **Default:** `16384`
3133+
* `highWaterMark` {number} **Default:** See
3134+
[`stream.getDefaultHighWaterMark()`][].
31273135
* `flush` {boolean} If `true`, the underlying file descriptor is flushed
31283136
prior to closing it. **Default:** `false`.
31293137
* Returns: {fs.WriteStream}
@@ -9357,6 +9365,7 @@ the file contents.
93579365
[`minimatch`]: https://github.com/isaacs/minimatch
93589366
[`node:stream/iter`]: stream_iter.md
93599367
[`statfs.bsize`]: #statfsbsize
9368+
[`stream.getDefaultHighWaterMark()`]: stream.md#streamgetdefaulthighwatermarkobjectmode
93609369
[`stream/iter pipeTo()`]: stream_iter.md#pipetosource-transforms-writer-options
93619370
[`stream/iter pull()`]: stream_iter.md#pullsource-transforms-options
93629371
[`stream/iter pullSync()`]: stream_iter.md#pullsyncsource-transforms

doc/api/stream.md

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3652,8 +3652,9 @@ added:
36523652
* `objectMode` {boolean}
36533653
* Returns: {integer}
36543654

3655-
Returns the default highWaterMark used by streams.
3656-
Defaults to `65536` (64 KiB), or `16` for `objectMode`.
3655+
Returns the default highWaterMark used by streams. Defaults to `16` for
3656+
`objectMode`. For byte streams, it defaults to `65536` (64 KiB) on non-Windows
3657+
platforms and `16384` (16 KiB) on Windows.
36573658

36583659
### `stream.setDefaultHighWaterMark(objectMode, value)`
36593660

@@ -3783,7 +3784,7 @@ changes:
37833784
* `options` {Object}
37843785
* `highWaterMark` {number} Buffer level when
37853786
[`stream.write()`][stream-write] starts returning `false`. **Default:**
3786-
`65536` (64 KiB), or `16` for `objectMode` streams.
3787+
See [`stream.getDefaultHighWaterMark()`][].
37873788
* `decodeStrings` {boolean} Whether to encode `string`s passed to
37883789
[`stream.write()`][stream-write] to `Buffer`s (with the encoding
37893790
specified in the [`stream.write()`][stream-write] call) before passing
@@ -4157,7 +4158,7 @@ changes:
41574158
* `options` {Object}
41584159
* `highWaterMark` {number} The maximum [number of bytes][hwm-gotcha] to store
41594160
in the internal buffer before ceasing to read from the underlying resource.
4160-
**Default:** `65536` (64 KiB), or `16` for `objectMode` streams.
4161+
**Default:** See [`stream.getDefaultHighWaterMark()`][].
41614162
* `encoding` {string} If specified, then buffers will be decoded to
41624163
strings using the specified encoding. **Default:** `null`.
41634164
* `objectMode` {boolean} Whether this stream should behave
@@ -5098,6 +5099,7 @@ contain multi-byte characters.
50985099
[`stream.cork()`]: #writablecork
50995100
[`stream.duplexPair()`]: #streamduplexpairoptions
51005101
[`stream.finished()`]: #streamfinishedstream-options-callback
5102+
[`stream.getDefaultHighWaterMark()`]: #streamgetdefaulthighwatermarkobjectmode
51015103
[`stream.pipe()`]: #readablepipedestination-options
51025104
[`stream.pipeline()`]: #streampipelinesource-transforms-destination-callback
51035105
[`stream.uncork()`]: #writableuncork

0 commit comments

Comments
 (0)