http: reduce multiple output arrays into one#26004
http: reduce multiple output arrays into one#26004starkwang wants to merge 2 commits intonodejs:masterfrom
Conversation
Now we are using `output`, `outputEncodings` and `outputCallbacks` to hold pending data. Reducing them into one array `outputData` can slightly improve performance and reduce some redundant codes.
bnoordhuis
left a comment
There was a problem hiding this comment.
LGTM. You might get even better performance if you push the data, encoding and callback properties as elements instead of wrapped in an object.
I stress the 'might' because it's not a dead certainty but I'm fairly certain it will. One performance pitfall to be aware of: destructuring assignment from an array (vis-a-vis an object) is quite slow in V8 right now.
|
I think that's the wrong benchmark to be checking. |
@mscdex I'm now running the whole benchmarks for http module. I'll paste the result after it finishes. |
|
Here is the whole benchmark result. It seems no difference after change (except Details |
lib/_http_outgoing.js
Outdated
| socket.cork(); | ||
| for (var i = 0; i < outputLength; i++) { | ||
| ret = socket.write(output[i], outputEncodings[i], outputCallbacks[i]); | ||
| for (var i = 0; i < outputData.length; i++) { |
There was a problem hiding this comment.
| for (var i = 0; i < outputData.length; i++) { | |
| for (var i = 0; i < outputLength; i++) { |
|
CI before landing: https://ci.nodejs.org/job/node-test-pull-request/20710/ |
|
Landed in 0b58545 |
Now we are using `output`, `outputEncodings` and `outputCallbacks` to hold pending data. Reducing them into one array `outputData` can slightly improve performance and reduce some redundant codes. PR-URL: #26004 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Now we are using `output`, `outputEncodings` and `outputCallbacks` to hold pending data. Reducing them into one array `outputData` can slightly improve performance and reduce some redundant codes. PR-URL: #26004 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Now we are using
output,outputEncodingsandoutputCallbacksto hold pending data. Reducing them into one arrayoutputDatacan slightly improve performance and reduce some redundant codes.Here is the benchmark for client request:
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passes