From 90603fce4ec7ee524ce22412a0f81c3e1f30d405 Mon Sep 17 00:00:00 2001 From: Robert Nagy Date: Tue, 19 Oct 2021 07:56:00 +0200 Subject: [PATCH] stream: default hwm based on Buffer.poolSize Slightly increase default Buffer.poolSize and make streams default HWM correspond to Buffer.poolSize. --- lib/buffer.js | 2 +- lib/internal/streams/state.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/buffer.js b/lib/buffer.js index 1f4f0a2e89deb8..cb5c29f5acdc3c 100644 --- a/lib/buffer.js +++ b/lib/buffer.js @@ -140,7 +140,7 @@ const constants = ObjectDefineProperties({}, { } }); -Buffer.poolSize = 8 * 1024; +Buffer.poolSize = 16 * 1024; let poolSize, poolOffset, allocPool; const encodingsMap = ObjectCreate(null); diff --git a/lib/internal/streams/state.js b/lib/internal/streams/state.js index 83050a62f9cedc..d263b4edd25b63 100644 --- a/lib/internal/streams/state.js +++ b/lib/internal/streams/state.js @@ -4,6 +4,7 @@ const { MathFloor, NumberIsInteger, } = primordials; +const { Buffer } = require('buffer'); const { ERR_INVALID_ARG_VALUE } = require('internal/errors').codes; @@ -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) {