http2: improve perf of passing headers to C++
By passing a single string rather than many small ones and a single block allocation for passing headers, save expensive interactions with JS values and memory allocations.
$ ./node benchmark/compare.js --new ./node --old ./node-master --runs 10 --filter headers http2 | Rscript benchmark/compare.R
[00:01:43|% 100| 1/1 files | 20/20 runs | 2/2 configs]: Done
improvement confidence p.value
http2/headers.js nheaders=1000 n=1000 13.45 % *** 5.548478e-12
http2/headers.js nheaders=100 n=1000 5.11 % *** 4.354236e-07
(Note: The benchmark has a lot of overhead since it does full request/response cycles. I don’t see any way around that right now, but the actual improvement of the changed code should be significantly higher than what’s displayed here.)
This is blocked by #14688 because the implementation for trailers isn’t changed here, but in that PR the two are unified so we won’t have to bother about that after that lands.
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes (after #14688) -
tests and/or benchmarks are included -
commit message follows commit guidelines
Affected core subsystem(s)
http2
/cc @nodejs/http2