node/test/parallel/test-https-hwm.js
Robert Nagy 1abff07392
stream: bump default highWaterMark
This should give a performance boost accross the board.

Given that the old limit is a decod old and memory capacity has
doubled many times since I think it is appropriate to slightly bump
the default limit.

PR-URL: https://github.com/nodejs/node/pull/52037
Refs: https://github.com/nodejs/node/pull/46608
Refs: https://github.com/nodejs/node/pull/50120
Reviewed-By: Rafael Gonzaga <rafael.nunu@hotmail.com>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: Yagiz Nizipli <yagiz.nizipli@sentry.io>
Reviewed-By: Chengzhong Wu <legendecas@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
2024-03-13 19:02:14 +00:00

67 lines
1.8 KiB
JavaScript

'use strict';
// Test https highWaterMark
const common = require('../common');
if (!common.hasCrypto)
common.skip('missing crypto');
const assert = require('assert');
const https = require('https');
const fixtures = require('../common/fixtures');
let counter = 0;
function loadCallback(highWaterMark) {
return common.mustCall(function(res) {
assert.strictEqual(highWaterMark, res.readableHighWaterMark);
counter--;
console.log('back from https request. ',
`highWaterMark = ${res.readableHighWaterMark}`);
if (counter === 0) {
httpsServer.close();
console.log('ok');
}
res.resume();
});
}
// create server
const httpsServer = https.createServer({
key: fixtures.readKey('agent1-key.pem'),
cert: fixtures.readKey('agent1-cert.pem')
}, common.mustCall(function(req, res) {
res.writeHead(200, {});
res.end('ok');
}, 3)).listen(0, common.mustCall(function(err) {
console.log(`test https server listening on port ${this.address().port}`);
assert.ifError(err);
https.request({
method: 'GET',
path: `/${counter++}`,
host: 'localhost',
port: this.address().port,
rejectUnauthorized: false,
highWaterMark: 128000,
}, loadCallback(128000)).on('error', common.mustNotCall()).end();
https.request({
method: 'GET',
path: `/${counter++}`,
host: 'localhost',
port: this.address().port,
rejectUnauthorized: false,
highWaterMark: 0,
}, loadCallback(0)).on('error', common.mustNotCall()).end();
https.request({
method: 'GET',
path: `/${counter++}`,
host: 'localhost',
port: this.address().port,
rejectUnauthorized: false,
highWaterMark: undefined,
}, loadCallback(process.platform === 'win32' ? 16 * 1024 : 64 * 1024)).on('error', common.mustNotCall()).end();
}));