Skip to content

Commit

Permalink
stream: default hwm based on Buffer.poolSize
Browse files Browse the repository at this point in the history
Slightly increase default Buffer.poolSize and make streams default
HWM correspond to Buffer.poolSize.
  • Loading branch information
ronag committed Oct 19, 2021
1 parent 4d82b9e commit 90603fc
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ const constants = ObjectDefineProperties({}, {
}
});

Buffer.poolSize = 8 * 1024;
Buffer.poolSize = 16 * 1024;
let poolSize, poolOffset, allocPool;

const encodingsMap = ObjectCreate(null);
Expand Down
3 changes: 2 additions & 1 deletion lib/internal/streams/state.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const {
MathFloor,
NumberIsInteger,
} = primordials;
const { Buffer } = require('buffer');

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

Expand All @@ -13,7 +14,7 @@ function highWaterMarkFrom(options, isDuplex, duplexKey) {
}

function getDefaultHighWaterMark(objectMode) {
return objectMode ? 16 : 16 * 1024;
return objectMode ? 16 : Buffer.poolSize;
}

function getHighWaterMark(state, options, duplexKey, isDuplex) {
Expand Down

0 comments on commit 90603fc

Please sign in to comment.