http: improve outgoing string write performance
These changes could be semver-major-y. One behavioral change introduced by this commit is that when writing a string that is the first chunk, it is no longer guaranteed to be sent immediately with the header. This is why the two tests had to be modified. It should be noted that this behavioral change actually brings it in line with what happens when writing a first Buffer
chunk, so there would be consistency after this change. However I'm not sure if there is anyone that may be relying on the old string writing behavior...
One other possibly noticeable change is that chunk
/data
in end()
is no longer validated if the outgoing message is already finished.
Anyway, here are some results:
improvement confidence p.value
http/simple.js res="normal" c=50 chunks=0 len=1024 type="buffer" benchmarker="wrk" -1.46 % 3.762163e-01
http/simple.js res="normal" c=50 chunks=0 len=1024 type="bytes" benchmarker="wrk" -0.51 % 7.115831e-01
http/simple.js res="normal" c=50 chunks=0 len=102400 type="buffer" benchmarker="wrk" -1.34 % 4.010301e-01
http/simple.js res="normal" c=50 chunks=0 len=102400 type="bytes" benchmarker="wrk" 0.59 % 1.274991e-01
http/simple.js res="normal" c=50 chunks=0 len=4 type="buffer" benchmarker="wrk" -0.40 % 8.526384e-01
http/simple.js res="normal" c=50 chunks=0 len=4 type="bytes" benchmarker="wrk" 0.37 % 8.122313e-01
http/simple.js res="normal" c=50 chunks=1 len=1024 type="buffer" benchmarker="wrk" -0.94 % 3.148300e-01
http/simple.js res="normal" c=50 chunks=1 len=1024 type="bytes" benchmarker="wrk" -0.05 % 9.575339e-01
http/simple.js res="normal" c=50 chunks=1 len=102400 type="buffer" benchmarker="wrk" 0.58 % 8.019575e-01
http/simple.js res="normal" c=50 chunks=1 len=102400 type="bytes" benchmarker="wrk" 319.43 % *** 1.099052e-27
http/simple.js res="normal" c=50 chunks=1 len=4 type="buffer" benchmarker="wrk" 0.23 % 8.886316e-01
http/simple.js res="normal" c=50 chunks=1 len=4 type="bytes" benchmarker="wrk" -3.08 % 1.276294e-01
http/simple.js res="normal" c=50 chunks=4 len=1024 type="buffer" benchmarker="wrk" 2.05 % 1.916095e-01
http/simple.js res="normal" c=50 chunks=4 len=1024 type="bytes" benchmarker="wrk" 1376.72 % *** 5.568434e-35
http/simple.js res="normal" c=50 chunks=4 len=102400 type="buffer" benchmarker="wrk" -1.57 % 5.306198e-01
http/simple.js res="normal" c=50 chunks=4 len=102400 type="bytes" benchmarker="wrk" 3.76 % 5.205095e-02
http/simple.js res="normal" c=50 chunks=4 len=4 type="buffer" benchmarker="wrk" -2.78 % 1.683912e-01
http/simple.js res="normal" c=50 chunks=4 len=4 type="bytes" benchmarker="wrk" 1409.81 % *** 3.412588e-30
CI: https://ci.nodejs.org/job/node-test-pull-request/8060/ CITGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/789/
Checklist
-
make -j4 test
(UNIX), orvcbuild test
(Windows) passes -
commit message follows commit guidelines
Affected core subsystem(s)
- http