Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

http: reduce multiple output arrays into one #26004

Closed
wants to merge 2 commits into from

Conversation

starkwang
Copy link
Contributor

@starkwang starkwang commented Feb 8, 2019

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.

Here is the benchmark for client request:

 http/create-clientrequest.js e=1 arg='options' url='idn'                           ***      2.72 %      ±0.93% ±1.23% ±1.61%
 http/create-clientrequest.js e=1 arg='options' url='long'                          ***      1.91 %      ±1.07% ±1.42% ±1.85%
 http/create-clientrequest.js e=1 arg='options' url='wpt'                           ***      2.61 %      ±1.33% ±1.77% ±2.30%
 http/create-clientrequest.js e=1 arg='string' url='idn'                              *      0.79 %      ±0.69% ±0.92% ±1.20%
 http/create-clientrequest.js e=1 arg='string' url='long'                                    0.54 %      ±0.69% ±0.92% ±1.21%
 http/create-clientrequest.js e=1 arg='string' url='wpt'                              *      0.83 %      ±0.79% ±1.05% ±1.37%
 http/create-clientrequest.js e=1 arg='URL' url='idn'                                        0.72 %      ±0.77% ±1.02% ±1.33%
 http/create-clientrequest.js e=1 arg='URL' url='long'                              ***      1.36 %      ±0.62% ±0.82% ±1.07%
 http/create-clientrequest.js e=1 arg='URL' url='wpt'                                 *      1.18 %      ±0.99% ±1.32% ±1.72%
Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

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.
@nodejs-github-bot nodejs-github-bot added the http Issues or PRs related to the http subsystem. label Feb 8, 2019
@starkwang
Copy link
Contributor Author

Copy link
Member

@bnoordhuis bnoordhuis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@mscdex
Copy link
Contributor

mscdex commented Feb 8, 2019

I think that's the wrong benchmark to be checking. create-clientrequest just measures creating ClientRequest objects. You will need to run benchmarks that actually send/receive requests/responses to measure the effects of the bulk of the code changes here.

@starkwang
Copy link
Contributor Author

I think that's the wrong benchmark to be checking. create-clientrequest just measures creating ClientRequest objects. You will need to run benchmarks that actually send/receive requests/responses.

@mscdex I'm now running the whole benchmarks for http module. I'll paste the result after it finishes.

@starkwang
Copy link
Contributor Author

Here is the whole benchmark result. It seems no difference after change (except create-clientrequest):

                                                                                               confidence improvement accuracy (*)    (**)   (***)
 http/bench-parser.js n=100000 len=16                                                                          0.22 %      ±0.57% ±0.76% ±1.00%
 http/bench-parser.js n=100000 len=32                                                                          0.08 %      ±0.27% ±0.36% ±0.47%
 http/bench-parser.js n=100000 len=4                                                                          -0.08 %      ±0.43% ±0.57% ±0.74%
 http/bench-parser.js n=100000 len=8                                                                   **      0.61 %      ±0.38% ±0.50% ±0.65%
 http/check_invalid_header_char.js n=1000000 input=''                                                   *     -0.69 %      ±0.58% ±0.78% ±1.02%
 http/check_invalid_header_char.js n=1000000 input='\177'                                                      0.45 %      ±0.64% ±0.85% ±1.11%
 http/check_invalid_header_char.js n=1000000 input='\\t\\t\\t\\t\\t\\t\\t\\t\\t\\tFoo bar baz'                -0.36 %      ±0.49% ±0.65% ±0.85%
 http/check_invalid_header_char.js n=1000000 input='1'                                                        -0.02 %      ±0.90% ±1.20% ±1.56%
 http/check_invalid_header_char.js n=1000000 input='20091'                                                     0.35 %      ±0.59% ±0.79% ±1.03%
 http/check_invalid_header_char.js n=1000000 input='中文呢'                                             *      0.59 %      ±0.59% ±0.78% ±1.01%
 http/check_invalid_header_char.js n=1000000 input='close'                                                     0.51 %      ±0.90% ±1.20% ±1.57%
 http/check_invalid_header_char.js n=1000000 input='en-US'                                                    -0.09 %      ±0.79% ±1.05% ±1.38%
 http/check_invalid_header_char.js n=1000000 input='foo\\nbar'                                                 0.15 %      ±0.64% ±0.85% ±1.10%
 http/check_invalid_header_char.js n=1000000 input='group_acmeair'                                      *     -0.41 %      ±0.37% ±0.49% ±0.64%
 http/check_invalid_header_char.js n=1000000 input='gzip'                                                      0.25 %      ±0.79% ±1.06% ±1.38%
 http/check_invalid_header_char.js n=1000000 input='keep-alive'                                                0.23 %      ±0.56% ±0.74% ±0.97%
 http/check_invalid_header_char.js n=1000000 input='LONG_AND_INVALID'                                         -0.11 %      ±0.37% ±0.49% ±0.64%
 http/check_invalid_header_char.js n=1000000 input='private'                                                  -0.08 %      ±0.68% ±0.91% ±1.18%
 http/check_invalid_header_char.js n=1000000 input='SAMEORIGIN'                                               -0.31 %      ±0.73% ±0.98% ±1.28%
 http/check_invalid_header_char.js n=1000000 input='Sat, 07 May 2016 16:54:48 GMT'                            -0.28 %      ±0.43% ±0.57% ±0.74%
 http/check_invalid_header_char.js n=1000000 input='text/html; charset=utf-8'                                 -0.05 %      ±0.44% ±0.58% ±0.75%
 http/check_invalid_header_char.js n=1000000 input='text/plain'                                        **     -0.89 %      ±0.56% ±0.75% ±0.97%
 http/check_is_http_token.js n=1000000 key=':'                                                                -0.10 %      ±0.64% ±0.85% ±1.11%
 http/check_is_http_token.js n=1000000 key=':alternate-protocol'                                              -0.24 %      ±0.62% ±0.83% ±1.09%
 http/check_is_http_token.js n=1000000 key='((((())))'                                                        -0.41 %      ±0.70% ±0.94% ±1.22%
 http/check_is_http_token.js n=1000000 key='@@'                                                                0.25 %      ±0.45% ±0.59% ±0.77%
 http/check_is_http_token.js n=1000000 key='中文呢'                                                            0.25 %      ±0.59% ±0.78% ±1.02%
 http/check_is_http_token.js n=1000000 key='Accept-Ranges'                                                     0.35 %      ±0.76% ±1.01% ±1.32%
 http/check_is_http_token.js n=1000000 key='alt-svc'                                                          -0.19 %      ±0.91% ±1.21% ±1.57%
 http/check_is_http_token.js n=1000000 key='alternate-protocol:'                                              -0.10 %      ±0.34% ±0.45% ±0.59%
 http/check_is_http_token.js n=1000000 key='alternate-protocol'                                               -0.46 %      ±0.95% ±1.27% ±1.65%
 http/check_is_http_token.js n=1000000 key='Cache-Control'                                                     0.22 %      ±0.81% ±1.08% ±1.41%
 http/check_is_http_token.js n=1000000 key='Connection'                                                        0.20 %      ±0.75% ±1.00% ±1.31%
 http/check_is_http_token.js n=1000000 key='Content-Encoding'                                                  0.16 %      ±0.82% ±1.09% ±1.41%
 http/check_is_http_token.js n=1000000 key='content-length'                                                    0.40 %      ±0.87% ±1.16% ±1.51%
 http/check_is_http_token.js n=1000000 key='Content-Location'                                                 -0.28 %      ±0.93% ±1.24% ±1.61%
 http/check_is_http_token.js n=1000000 key='content-type'                                                     -0.07 %      ±0.81% ±1.08% ±1.40%
 http/check_is_http_token.js n=1000000 key='Content-Type'                                                     -0.40 %      ±0.76% ±1.01% ±1.31%
 http/check_is_http_token.js n=1000000 key='date'                                                             -0.58 %      ±0.79% ±1.05% ±1.37%
 http/check_is_http_token.js n=1000000 key='ETag'                                                             -0.25 %      ±0.85% ±1.12% ±1.46%
 http/check_is_http_token.js n=1000000 key='Expires'                                                           0.32 %      ±1.15% ±1.54% ±2.01%
 http/check_is_http_token.js n=1000000 key='Keep-Alive'                                                       -0.18 %      ±0.83% ±1.11% ±1.44%
 http/check_is_http_token.js n=1000000 key='Last-Modified'                                                    -0.48 %      ±0.79% ±1.05% ±1.37%
 http/check_is_http_token.js n=1000000 key='location'                                                          0.09 %      ±0.92% ±1.23% ±1.60%
 http/check_is_http_token.js n=1000000 key='server'                                                            0.05 %      ±0.74% ±0.98% ±1.28%
 http/check_is_http_token.js n=1000000 key='Server'                                                            0.34 %      ±0.67% ±0.90% ±1.17%
 http/check_is_http_token.js n=1000000 key='status'                                                            0.01 %      ±0.88% ±1.17% ±1.52%
 http/check_is_http_token.js n=1000000 key='TCN'                                                              -0.38 %      ±0.77% ±1.03% ±1.34%
 http/check_is_http_token.js n=1000000 key='Transfer-Encoding'                                                 1.00 %      ±1.00% ±1.33% ±1.74%
 http/check_is_http_token.js n=1000000 key='Vary'                                                              0.48 %      ±1.16% ±1.54% ±2.02%
 http/check_is_http_token.js n=1000000 key='version'                                                          -0.44 %      ±0.78% ±1.04% ±1.35%
 http/check_is_http_token.js n=1000000 key='x-frame-options'                                                   0.14 %      ±0.99% ±1.32% ±1.72%
 http/check_is_http_token.js n=1000000 key='x-xss-protection'                                                 -0.00 %      ±0.92% ±1.22% ±1.59%
 http/chunked.js c=100 len=1 n=1 benchmarker='autocannon'                                                      0.50 %      ±1.28% ±1.71% ±2.24%
 http/chunked.js c=100 len=1 n=16 benchmarker='autocannon'                                                     1.01 %      ±2.12% ±2.82% ±3.68%
 http/chunked.js c=100 len=1 n=4 benchmarker='autocannon'                                                      0.97 %      ±2.99% ±3.98% ±5.18%
 http/chunked.js c=100 len=1 n=8 benchmarker='autocannon'                                                      1.02 %      ±1.95% ±2.59% ±3.38%
 http/chunked.js c=100 len=256 n=1 benchmarker='autocannon'                                                    0.72 %      ±1.07% ±1.42% ±1.85%
 http/chunked.js c=100 len=256 n=16 benchmarker='autocannon'                                                   0.31 %      ±1.62% ±2.16% ±2.81%
 http/chunked.js c=100 len=256 n=4 benchmarker='autocannon'                                                    0.12 %      ±4.56% ±6.06% ±7.89%
 http/chunked.js c=100 len=256 n=8 benchmarker='autocannon'                                                   -0.62 %      ±1.63% ±2.17% ±2.83%
 http/chunked.js c=100 len=64 n=1 benchmarker='autocannon'                                                     0.33 %      ±1.10% ±1.46% ±1.91%
 http/chunked.js c=100 len=64 n=16 benchmarker='autocannon'                                                    0.77 %      ±1.56% ±2.08% ±2.71%
 http/chunked.js c=100 len=64 n=4 benchmarker='autocannon'                                                     1.50 %      ±4.25% ±5.65% ±7.36%
 http/chunked.js c=100 len=64 n=8 benchmarker='autocannon'                                                     0.81 %      ±1.55% ±2.07% ±2.70%
 http/client-request-body.js method='end' len=1024 type='asc' dur=5                                           -0.03 %      ±0.52% ±0.69% ±0.90%
 http/client-request-body.js method='end' len=1024 type='buf' dur=5                                            0.11 %      ±0.79% ±1.05% ±1.37%
 http/client-request-body.js method='end' len=1024 type='utf' dur=5                                            0.09 %      ±0.74% ±0.99% ±1.29%
 http/client-request-body.js method='end' len=256 type='asc' dur=5                                            -0.29 %      ±0.90% ±1.20% ±1.58%
 http/client-request-body.js method='end' len=256 type='buf' dur=5                                            -0.04 %      ±0.65% ±0.86% ±1.13%
 http/client-request-body.js method='end' len=256 type='utf' dur=5                                             0.49 %      ±0.80% ±1.06% ±1.38%
 http/client-request-body.js method='end' len=32 type='asc' dur=5                                       *      0.83 %      ±0.71% ±0.95% ±1.24%
 http/client-request-body.js method='end' len=32 type='buf' dur=5                                              0.23 %      ±0.65% ±0.86% ±1.12%
 http/client-request-body.js method='end' len=32 type='utf' dur=5                                             -0.21 %      ±0.61% ±0.82% ±1.07%
 http/client-request-body.js method='write' len=1024 type='asc' dur=5                                          0.50 %      ±0.58% ±0.78% ±1.01%
 http/client-request-body.js method='write' len=1024 type='buf' dur=5                                         -0.18 %      ±0.80% ±1.07% ±1.39%
 http/client-request-body.js method='write' len=1024 type='utf' dur=5                                          0.16 %      ±0.63% ±0.84% ±1.09%
 http/client-request-body.js method='write' len=256 type='asc' dur=5                                           0.02 %      ±0.72% ±0.96% ±1.24%
 http/client-request-body.js method='write' len=256 type='buf' dur=5                                           0.49 %      ±0.55% ±0.73% ±0.95%
 http/client-request-body.js method='write' len=256 type='utf' dur=5                                           0.43 %      ±0.56% ±0.75% ±0.97%
 http/client-request-body.js method='write' len=32 type='asc' dur=5                                           -0.09 %      ±0.62% ±0.82% ±1.07%
 http/client-request-body.js method='write' len=32 type='buf' dur=5                                           -0.43 %      ±0.59% ±0.79% ±1.02%
 http/client-request-body.js method='write' len=32 type='utf' dur=5                                           -0.24 %      ±0.54% ±0.71% ±0.93%
 http/cluster.js c=50 len=1024 type='buffer' benchmarker='autocannon'                                   *      3.31 %      ±2.84% ±3.78% ±4.92%
 http/cluster.js c=50 len=1024 type='bytes' benchmarker='autocannon'                                          -0.96 %      ±2.45% ±3.26% ±4.26%
 http/cluster.js c=50 len=102400 type='buffer' benchmarker='autocannon'                                       -0.15 %      ±1.44% ±1.92% ±2.50%
 http/cluster.js c=50 len=102400 type='bytes' benchmarker='autocannon'                                        -0.24 %      ±2.40% ±3.19% ±4.15%
 http/cluster.js c=50 len=4 type='buffer' benchmarker='autocannon'                                            -1.98 %      ±2.42% ±3.23% ±4.21%
 http/cluster.js c=50 len=4 type='bytes' benchmarker='autocannon'                                             -1.29 %      ±2.73% ±3.63% ±4.74%
 http/cluster.js c=500 len=1024 type='buffer' benchmarker='autocannon'                                         1.19 %      ±2.87% ±3.82% ±4.97%
 http/cluster.js c=500 len=1024 type='bytes' benchmarker='autocannon'                                   *     -3.14 %      ±2.86% ±3.81% ±4.97%
 http/cluster.js c=500 len=102400 type='buffer' benchmarker='autocannon'                                       0.58 %      ±1.81% ±2.41% ±3.14%
 http/cluster.js c=500 len=102400 type='bytes' benchmarker='autocannon'                                       -2.01 %      ±2.01% ±2.68% ±3.50%
 http/cluster.js c=500 len=4 type='buffer' benchmarker='autocannon'                                            1.73 %      ±2.30% ±3.06% ±3.99%
 http/cluster.js c=500 len=4 type='bytes' benchmarker='autocannon'                                            -0.18 %      ±2.09% ±2.79% ±3.63%
 http/create-clientrequest.js e=1 arg='options' url='idn'                                             ***      2.72 %      ±0.93% ±1.23% ±1.61%
 http/create-clientrequest.js e=1 arg='options' url='long'                                            ***      1.91 %      ±1.07% ±1.42% ±1.85%
 http/create-clientrequest.js e=1 arg='options' url='wpt'                                             ***      2.61 %      ±1.33% ±1.77% ±2.30%
 http/create-clientrequest.js e=1 arg='string' url='idn'                                                *      0.79 %      ±0.69% ±0.92% ±1.20%
 http/create-clientrequest.js e=1 arg='string' url='long'                                                      0.54 %      ±0.69% ±0.92% ±1.21%
 http/create-clientrequest.js e=1 arg='string' url='wpt'                                                *      0.83 %      ±0.79% ±1.05% ±1.37%
 http/create-clientrequest.js e=1 arg='URL' url='idn'                                                          0.72 %      ±0.77% ±1.02% ±1.33%
 http/create-clientrequest.js e=1 arg='URL' url='long'                                                ***      1.36 %      ±0.62% ±0.82% ±1.07%
 http/create-clientrequest.js e=1 arg='URL' url='wpt'                                                   *      1.18 %      ±0.99% ±1.32% ±1.72%
 http/end-vs-write-end.js method='end' c=100 len=1048576 type='asc' benchmarker='autocannon'                  -0.16 %      ±1.25% ±1.66% ±2.16%
 http/end-vs-write-end.js method='end' c=100 len=1048576 type='buf' benchmarker='autocannon'                   0.29 %      ±1.49% ±1.98% ±2.58%
 http/end-vs-write-end.js method='end' c=100 len=1048576 type='utf' benchmarker='autocannon'                  -0.24 %      ±0.74% ±0.98% ±1.28%
 http/end-vs-write-end.js method='end' c=100 len=131072 type='asc' benchmarker='autocannon'             *      0.18 %      ±0.14% ±0.19% ±0.25%
 http/end-vs-write-end.js method='end' c=100 len=131072 type='buf' benchmarker='autocannon'                   -0.62 %      ±0.73% ±0.98% ±1.27%
 http/end-vs-write-end.js method='end' c=100 len=131072 type='utf' benchmarker='autocannon'                    0.06 %      ±0.21% ±0.29% ±0.38%
 http/end-vs-write-end.js method='end' c=100 len=262144 type='asc' benchmarker='autocannon'                    0.14 %      ±0.19% ±0.25% ±0.32%
 http/end-vs-write-end.js method='end' c=100 len=262144 type='buf' benchmarker='autocannon'                    0.10 %      ±1.32% ±1.76% ±2.29%
 http/end-vs-write-end.js method='end' c=100 len=262144 type='utf' benchmarker='autocannon'                   -0.34 %      ±0.55% ±0.74% ±0.97%
 http/end-vs-write-end.js method='end' c=100 len=65536 type='asc' benchmarker='autocannon'              *      0.31 %      ±0.23% ±0.31% ±0.41%
 http/end-vs-write-end.js method='end' c=100 len=65536 type='buf' benchmarker='autocannon'                     0.30 %      ±0.59% ±0.78% ±1.02%
 http/end-vs-write-end.js method='end' c=100 len=65536 type='utf' benchmarker='autocannon'                     0.13 %      ±0.35% ±0.47% ±0.61%
 http/end-vs-write-end.js method='write' c=100 len=1048576 type='asc' benchmarker='autocannon'                 0.06 %      ±2.25% ±2.99% ±3.89%
 http/end-vs-write-end.js method='write' c=100 len=1048576 type='buf' benchmarker='autocannon'                -0.41 %      ±1.21% ±1.61% ±2.10%
 http/end-vs-write-end.js method='write' c=100 len=1048576 type='utf' benchmarker='autocannon'                 0.03 %      ±1.06% ±1.41% ±1.83%
 http/end-vs-write-end.js method='write' c=100 len=131072 type='asc' benchmarker='autocannon'                  0.01 %      ±0.15% ±0.20% ±0.26%
 http/end-vs-write-end.js method='write' c=100 len=131072 type='buf' benchmarker='autocannon'                 -0.04 %      ±0.55% ±0.73% ±0.95%
 http/end-vs-write-end.js method='write' c=100 len=131072 type='utf' benchmarker='autocannon'                 -0.09 %      ±0.19% ±0.26% ±0.33%
 http/end-vs-write-end.js method='write' c=100 len=262144 type='asc' benchmarker='autocannon'                 -0.06 %      ±0.20% ±0.26% ±0.34%
 http/end-vs-write-end.js method='write' c=100 len=262144 type='buf' benchmarker='autocannon'                  0.11 %      ±0.86% ±1.15% ±1.50%
 http/end-vs-write-end.js method='write' c=100 len=262144 type='utf' benchmarker='autocannon'                 -0.11 %      ±0.20% ±0.26% ±0.34%
 http/end-vs-write-end.js method='write' c=100 len=65536 type='asc' benchmarker='autocannon'                  -0.06 %      ±0.23% ±0.30% ±0.40%
 http/end-vs-write-end.js method='write' c=100 len=65536 type='buf' benchmarker='autocannon'                  -0.11 %      ±0.49% ±0.66% ±0.85%
 http/end-vs-write-end.js method='write' c=100 len=65536 type='utf' benchmarker='autocannon'                  -0.40 %      ±0.59% ±0.79% ±1.04%
 http/headers.js n=10 duplicates=1 benchmarker='autocannon'                                                    0.15 %      ±0.54% ±0.72% ±0.94%
 http/headers.js n=10 duplicates=100 benchmarker='autocannon'                                                 -0.60 %      ±0.84% ±1.12% ±1.46%
 http/headers.js n=1000 duplicates=1 benchmarker='autocannon'                                                  0.07 %      ±0.34% ±0.46% ±0.59%
 http/headers.js n=1000 duplicates=100 benchmarker='autocannon'                                                0.42 %      ±0.64% ±0.86% ±1.13%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=1024 type='buffer' benchmarker='autocannon'                     0.79 %      ±2.05% ±2.73% ±3.55%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=1024 type='bytes' benchmarker='autocannon'                      0.37 %      ±2.55% ±3.40% ±4.42%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=102400 type='buffer' benchmarker='autocannon'                  -0.10 %      ±1.15% ±1.53% ±2.00%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=102400 type='bytes' benchmarker='autocannon'                    0.07 %      ±0.44% ±0.58% ±0.76%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=4 type='buffer' benchmarker='autocannon'                 *      1.02 %      ±0.87% ±1.15% ±1.50%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=4 type='bytes' benchmarker='autocannon'                         0.77 %      ±1.28% ±1.71% ±2.23%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=1024 type='buffer' benchmarker='autocannon'                     1.01 %      ±2.13% ±2.84% ±3.70%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=1024 type='bytes' benchmarker='autocannon'                     -0.22 %      ±1.80% ±2.40% ±3.12%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=102400 type='buffer' benchmarker='autocannon'                  -0.00 %      ±1.38% ±1.84% ±2.39%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=102400 type='bytes' benchmarker='autocannon'                   -0.03 %      ±0.38% ±0.50% ±0.66%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=4 type='buffer' benchmarker='autocannon'                        0.68 %      ±0.99% ±1.31% ±1.71%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=4 type='bytes' benchmarker='autocannon'                        -0.52 %      ±0.85% ±1.14% ±1.48%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=1024 type='buffer' benchmarker='autocannon'                    0.86 %      ±2.00% ±2.67% ±3.47%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=1024 type='bytes' benchmarker='autocannon'                     1.37 %      ±1.86% ±2.48% ±3.23%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=102400 type='buffer' benchmarker='autocannon'                 -0.26 %      ±0.96% ±1.28% ±1.67%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=102400 type='bytes' benchmarker='autocannon'                  -0.05 %      ±0.68% ±0.90% ±1.18%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=4 type='buffer' benchmarker='autocannon'                       0.54 %      ±1.00% ±1.33% ±1.74%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=4 type='bytes' benchmarker='autocannon'                        0.38 %      ±0.99% ±1.32% ±1.72%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=1024 type='buffer' benchmarker='autocannon'                    0.20 %      ±1.96% ±2.61% ±3.40%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=1024 type='bytes' benchmarker='autocannon'                    -0.63 %      ±2.05% ±2.73% ±3.55%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=102400 type='buffer' benchmarker='autocannon'                  0.56 %      ±1.00% ±1.33% ±1.73%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=102400 type='bytes' benchmarker='autocannon'                   1.02 %      ±1.25% ±1.68% ±2.23%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=4 type='buffer' benchmarker='autocannon'                       0.04 %      ±1.34% ±1.79% ±2.34%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=4 type='bytes' benchmarker='autocannon'                        0.08 %      ±1.12% ±1.49% ±1.94%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=1024 type='buffer' benchmarker='autocannon'                    -0.09 %      ±2.12% ±2.82% ±3.67%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=1024 type='bytes' benchmarker='autocannon'                      0.67 %      ±1.99% ±2.64% ±3.44%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=102400 type='buffer' benchmarker='autocannon'                  -0.12 %      ±1.39% ±1.85% ±2.41%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=102400 type='bytes' benchmarker='autocannon'                    0.09 %      ±0.38% ±0.50% ±0.66%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=4 type='buffer' benchmarker='autocannon'                        0.11 %      ±1.07% ±1.42% ±1.85%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=4 type='bytes' benchmarker='autocannon'                        -0.58 %      ±0.98% ±1.31% ±1.71%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=1024 type='buffer' benchmarker='autocannon'                    -0.15 %      ±1.88% ±2.51% ±3.27%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=1024 type='bytes' benchmarker='autocannon'                     -0.25 %      ±1.94% ±2.59% ±3.37%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=102400 type='buffer' benchmarker='autocannon'                  -0.49 %      ±1.30% ±1.73% ±2.25%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=102400 type='bytes' benchmarker='autocannon'                   -0.22 %      ±0.57% ±0.77% ±1.00%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=4 type='buffer' benchmarker='autocannon'                        0.49 %      ±1.39% ±1.85% ±2.40%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=4 type='bytes' benchmarker='autocannon'                        -0.30 %      ±0.96% ±1.28% ±1.67%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=1024 type='buffer' benchmarker='autocannon'                    1.16 %      ±1.64% ±2.18% ±2.84%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=1024 type='bytes' benchmarker='autocannon'                     0.95 %      ±1.74% ±2.32% ±3.02%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=102400 type='buffer' benchmarker='autocannon'           *      1.27 %      ±1.02% ±1.36% ±1.78%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=102400 type='bytes' benchmarker='autocannon'                   0.21 %      ±0.78% ±1.04% ±1.36%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=4 type='buffer' benchmarker='autocannon'                       0.80 %      ±0.94% ±1.25% ±1.64%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=4 type='bytes' benchmarker='autocannon'                        0.16 %      ±0.72% ±0.96% ±1.25%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=1024 type='buffer' benchmarker='autocannon'                   -0.51 %      ±1.97% ±2.62% ±3.41%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=1024 type='bytes' benchmarker='autocannon'                     1.74 %      ±2.03% ±2.70% ±3.52%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=102400 type='buffer' benchmarker='autocannon'                  0.42 %      ±0.89% ±1.18% ±1.54%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=102400 type='bytes' benchmarker='autocannon'                   0.32 %      ±0.58% ±0.78% ±1.02%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=4 type='buffer' benchmarker='autocannon'                      -0.30 %      ±1.40% ±1.87% ±2.46%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=4 type='bytes' benchmarker='autocannon'                       -0.33 %      ±0.70% ±0.94% ±1.22%

Be aware that when doing many comparisons the risk of a false-positive
result increases. In this case there are 180 comparisons, you can thus
expect the following amount of false-positive results:
  9.00 false positives, when considering a   5% risk acceptance (*, **, ***),
  1.80 false positives, when considering a   1% risk acceptance (**, ***),
  0.18 false positives, when considering a 0.1% risk acceptance (***)

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++) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
for (var i = 0; i < outputData.length; i++) {
for (var i = 0; i < outputLength; i++) {

@starkwang
Copy link
Contributor Author

@starkwang
Copy link
Contributor Author

Landed in 0b58545

@starkwang starkwang closed this Feb 11, 2019
starkwang added a commit that referenced this pull request Feb 11, 2019
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>
targos pushed a commit that referenced this pull request Feb 11, 2019
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>
@targos targos mentioned this pull request Feb 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants