Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 7aa7759

Browse filesBrowse files
GKJCJGtargos
authored andcommitted
doc: clarify role of writable.cork()
The syntax of the sentence describing the role of writable.cork() was unclear. This rephrase aims to make the distinction between writing to the buffer and draining immediately to the underlying destination clearer - while keeping performance considerations clearly in mind. PR-URL: #30442 Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Matteo Collina <matteo.collina@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Denys Otrishko <shishugi@gmail.com>
1 parent e45edab commit 7aa7759
Copy full SHA for 7aa7759

File tree

Expand file treeCollapse file tree

1 file changed

+10
-7
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+10
-7
lines changed
Open diff view settings
Collapse file

‎doc/api/stream.md‎

Copy file name to clipboardExpand all lines: doc/api/stream.md
+10-7Lines changed: 10 additions & 7 deletions
  • Display the source diff
  • Display the rich diff
Original file line numberDiff line numberDiff line change
@@ -355,13 +355,16 @@ The `writable.cork()` method forces all written data to be buffered in memory.
355355
The buffered data will be flushed when either the [`stream.uncork()`][] or
356356
[`stream.end()`][stream-end] methods are called.
357357

358-
The primary intent of `writable.cork()` is to avoid a situation where writing
359-
many small chunks of data to a stream do not cause a backup in the internal
360-
buffer that would have an adverse impact on performance. In such situations,
361-
implementations that implement the `writable._writev()` method can perform
362-
buffered writes in a more optimized manner.
363-
364-
See also: [`writable.uncork()`][].
358+
The primary intent of `writable.cork()` is to accommodate a situation in which
359+
several small chunks are written to the stream in rapid succession. Instead of
360+
immediately forwarding them to the underlying destination, `writable.cork()`
361+
buffers all the chunks until `writable.uncork()` is called, which will pass them
362+
all to `writable._writev()`, if present. This prevents a head-of-line blocking
363+
situation where data is being buffered while waiting for the first small chunk
364+
to be processed. However, use of `writable.cork()` without implementing
365+
`writable._writev()` may have an adverse effect on throughput.
366+
367+
See also: [`writable.uncork()`][], [`writable._writev()`][stream-_writev].
365368

366369
##### `writable.destroy([error])`
367370
<!-- YAML

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.