Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Saner default highWaterMark for streams in objectMode #8574

Closed
daguej opened this issue Oct 17, 2014 · 2 comments
Closed

Saner default highWaterMark for streams in objectMode #8574

daguej opened this issue Oct 17, 2014 · 2 comments

Comments

@daguej
Copy link

daguej commented Oct 17, 2014

The default highWaterMark for streams is 16,384.

This is perfectly acceptable for normal streams that deal in bytes, since buffering 16 kB is fine.

However, for objectMode streams, this is not a sane default. The highWaterMark applies to the count of buffered objects, not their total size. A single object can occupy many thousands of bytes on the heap. If dealing with larger objects (say, 16 kB each because they contain long strings), a single stream can buffer 256 MB in memory, which is not fine. With large enough data and/or number of streams, this can easily lead to an unexpected crash.

We should set a smaller default highWaterMark on streams created in objectMode. I'm not exactly sure what the right number is or what kind of impact that change would have on existing programs, but if there's agreement with the idea, I'm happy to whip up a patch.

@daguej
Copy link
Author

daguej commented Oct 17, 2014

I see, this is already coming in 0.12. Excellent!

(In 0.10, there is no difference for objectMode)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants