From 9af04ad684a666888f76024876d7b74eee60d2f7 Mon Sep 17 00:00:00 2001 From: Matteo Collina Date: Fri, 18 Jan 2019 15:31:46 +0100 Subject: http2: improve compat performance This bunch of commits help me improve the performance of a http2 server by 8-10%. The benchmarks reports several 1-2% improvements in various areas. PR-URL: https://github.com/nodejs/node/pull/25567 Reviewed-By: Benedikt Meurer Reviewed-By: Anna Henningsen Reviewed-By: James M Snell --- benchmark/http2/compat.js | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 benchmark/http2/compat.js (limited to 'benchmark/http2') diff --git a/benchmark/http2/compat.js b/benchmark/http2/compat.js new file mode 100644 index 0000000000..5d06ccf317 --- /dev/null +++ b/benchmark/http2/compat.js @@ -0,0 +1,35 @@ +'use strict'; + +const common = require('../common.js'); +const path = require('path'); +const fs = require('fs'); +const file = path.join(path.resolve(__dirname, '../fixtures'), 'alice.html'); + +const bench = common.createBenchmark(main, { + requests: [100, 1000, 5000], + streams: [1, 10, 20, 40, 100, 200], + clients: [2], + benchmarker: ['h2load'] +}, { flags: ['--no-warnings'] }); + +function main({ requests, streams, clients }) { + const http2 = require('http2'); + const server = http2.createServer(); + server.on('request', (req, res) => { + const out = fs.createReadStream(file); + res.setHeader('content-type', 'text/html'); + out.pipe(res); + out.on('error', (err) => { + res.destroy(); + }); + }); + server.listen(common.PORT, () => { + bench.http({ + path: '/', + requests, + maxConcurrentStreams: streams, + clients, + threads: clients + }, () => { server.close(); }); + }); +} -- cgit v1.2.3