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: simplify various RegExp and related checks #20131

Closed

Conversation

apapirovski
Copy link
Member

@apapirovski apapirovski commented Apr 18, 2018

This PR simplifies a number of header related checks in _http_outgoing.js:

  1. http: simplify isCookieField
    Handrolling and checking char by char is no longer faster than just using toLowerCase and strict comparison.
  2. http: use switch in matchHeader
    Using a switch improves clarity of the code but also performance for all but a few edge cases which remain on par with the old code.
  3. http: simplify connection: close search

I've confirmed there is no performance regression from these tests by creating small micro benchmarks with old and new versions of these functions. All the changes should actually improve performance. That said, that wasn't the main point of this PR — readability was.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • commit message follows commit guidelines

Handrolling and checking char by char is no longer faster than just
using toLowerCase and strict comparison.
Using a switch improves clarity of the code but also performance for
all but a few edge cases which remain on par with the old code.
@apapirovski apapirovski added http Issues or PRs related to the http subsystem. dont-land-on-v4.x labels Apr 18, 2018
@apapirovski
Copy link
Member Author

apapirovski commented Apr 18, 2018

CI: https://ci.nodejs.org/job/node-test-pull-request/14361/
CitGM: https://ci.nodejs.org/view/Node.js-citgm/job/citgm-smoker/1377/ (in case I missed some edge case but I don't think so)

ch = s.charCodeAt(5);
if (ch !== 101 && ch !== 69) return false;
return true;
return s.length === 6 && s.toLowerCase() === 'cookie';
Copy link
Member

Choose a reason for hiding this comment

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

this one change alone makes the whole PR worth it :-)

@mscdex
Copy link
Contributor

mscdex commented Apr 18, 2018

Can we also get CI benchmark results for this?

@apapirovski
Copy link
Member Author

@mscdex I didn't get any meaningful numbers from our benchmarks but perhaps the CI will. Here it is: https://ci.nodejs.org/view/Node.js%20benchmark/job/benchmark-node-micro-benchmarks/157/

@apapirovski
Copy link
Member Author

apapirovski commented Apr 20, 2018

Not much of value in the benchmarks. Maybe a slight improvement judging by the simple benchmark but very low confidence level for the most part. Definitely no regression.

Benchmark Results
                                                                                               confidence improvement accuracy (*)   (**)   (***)
 http/chunked.js c=100 len=1 n=16 benchmarker='wrk'                                                           -0.13 %       ±0.14% ±0.18%  ±0.23%
 http/chunked.js c=100 len=1 n=1 benchmarker='wrk'                                                            -0.05 %       ±0.12% ±0.16%  ±0.21%
 http/chunked.js c=100 len=1 n=4 benchmarker='wrk'                                                            -0.02 %       ±0.13% ±0.17%  ±0.22%
 http/chunked.js c=100 len=1 n=8 benchmarker='wrk'                                                             0.00 %       ±0.14% ±0.18%  ±0.24%
 http/chunked.js c=100 len=256 n=16 benchmarker='wrk'                                                         -0.01 %       ±0.13% ±0.17%  ±0.22%
 http/chunked.js c=100 len=256 n=1 benchmarker='wrk'                                                          -0.05 %       ±0.13% ±0.17%  ±0.22%
 http/chunked.js c=100 len=256 n=4 benchmarker='wrk'                                                           0.06 %       ±0.13% ±0.17%  ±0.21%
 http/chunked.js c=100 len=256 n=8 benchmarker='wrk'                                                           0.09 %       ±0.15% ±0.19%  ±0.25%
 http/chunked.js c=100 len=64 n=16 benchmarker='wrk'                                                    *      0.13 %       ±0.13% ±0.17%  ±0.22%
 http/chunked.js c=100 len=64 n=1 benchmarker='wrk'                                                           -0.04 %       ±0.13% ±0.17%  ±0.21%
 http/chunked.js c=100 len=64 n=4 benchmarker='wrk'                                                           -0.01 %       ±0.13% ±0.18%  ±0.23%
 http/chunked.js c=100 len=64 n=8 benchmarker='wrk'                                                           -0.03 %       ±0.14% ±0.19%  ±0.24%
 http/client-request-body.js method='end' len=1024 type='asc' dur=5                                     *     -4.67 %       ±4.39% ±5.79%  ±7.43%
 http/client-request-body.js method='end' len=1024 type='buf' dur=5                                           -0.06 %       ±3.93% ±5.18%  ±6.66%
 http/client-request-body.js method='end' len=1024 type='utf' dur=5                                            4.26 %       ±4.45% ±5.86%  ±7.53%
 http/client-request-body.js method='end' len=256 type='asc' dur=5                                             0.94 %       ±4.31% ±5.68%  ±7.29%
 http/client-request-body.js method='end' len=256 type='buf' dur=5                                             2.79 %       ±4.33% ±5.71%  ±7.34%
 http/client-request-body.js method='end' len=256 type='utf' dur=5                                             2.50 %       ±4.37% ±5.77%  ±7.41%
 http/client-request-body.js method='end' len=32 type='asc' dur=5                                             -0.69 %       ±4.33% ±5.70%  ±7.33%
 http/client-request-body.js method='end' len=32 type='buf' dur=5                                       *      4.77 %       ±3.98% ±5.25%  ±6.74%
 http/client-request-body.js method='end' len=32 type='utf' dur=5                                             -1.93 %       ±4.53% ±5.97%  ±7.67%
 http/client-request-body.js method='write' len=1024 type='asc' dur=5                                  **      7.51 %       ±4.51% ±5.95%  ±7.64%
 http/client-request-body.js method='write' len=1024 type='buf' dur=5                                          1.74 %       ±4.26% ±5.61%  ±7.21%
 http/client-request-body.js method='write' len=1024 type='utf' dur=5                                          0.24 %       ±4.46% ±5.88%  ±7.55%
 http/client-request-body.js method='write' len=256 type='asc' dur=5                                          -0.39 %       ±4.15% ±5.47%  ±7.03%
 http/client-request-body.js method='write' len=256 type='buf' dur=5                                           1.61 %       ±4.71% ±6.21%  ±7.98%
 http/client-request-body.js method='write' len=256 type='utf' dur=5                                    *      4.77 %       ±4.07% ±5.37%  ±6.89%
 http/client-request-body.js method='write' len=32 type='asc' dur=5                                            4.29 %       ±4.52% ±5.97%  ±7.66%
 http/client-request-body.js method='write' len=32 type='buf' dur=5                                            1.49 %       ±4.45% ±5.88%  ±7.55%
 http/client-request-body.js method='write' len=32 type='utf' dur=5                                            3.08 %       ±4.09% ±5.40%  ±6.93%
 http/cluster.js c=500 len=102400 type='buffer' benchmarker='wrk'                                              1.43 %       ±1.87% ±2.47%  ±3.17%
 http/cluster.js c=500 len=102400 type='bytes' benchmarker='wrk'                                       **      3.12 %       ±2.05% ±2.71%  ±3.48%
 http/cluster.js c=500 len=1024 type='buffer' benchmarker='wrk'                                                2.07 %       ±2.12% ±2.79%  ±3.58%
 http/cluster.js c=500 len=1024 type='bytes' benchmarker='wrk'                                                 1.64 %       ±2.20% ±2.90%  ±3.73%
 http/cluster.js c=500 len=4 type='buffer' benchmarker='wrk'                                            *      2.56 %       ±2.16% ±2.85%  ±3.66%
 http/cluster.js c=500 len=4 type='bytes' benchmarker='wrk'                                                    1.35 %       ±2.17% ±2.86%  ±3.67%
 http/cluster.js c=50 len=102400 type='buffer' benchmarker='wrk'                                       **      1.88 %       ±1.37% ±1.81%  ±2.32%
 http/cluster.js c=50 len=102400 type='bytes' benchmarker='wrk'                                                1.43 %       ±1.79% ±2.35%  ±3.02%
 http/cluster.js c=50 len=1024 type='buffer' benchmarker='wrk'                                                 1.02 %       ±1.62% ±2.13%  ±2.74%
 http/cluster.js c=50 len=1024 type='bytes' benchmarker='wrk'                                                  1.50 %       ±1.51% ±2.00%  ±2.57%
 http/cluster.js c=50 len=4 type='buffer' benchmarker='wrk'                                             *      1.74 %       ±1.52% ±2.01%  ±2.58%
 http/cluster.js c=50 len=4 type='bytes' benchmarker='wrk'                                                     0.67 %       ±1.66% ±2.19%  ±2.82%
 http/create-clientrequest.js n=1000000 len=1                                                                 -1.19 %       ±2.47% ±3.25%  ±4.18%
 http/create-clientrequest.js n=1000000 len=128                                                                0.74 %       ±1.94% ±2.56%  ±3.29%
 http/create-clientrequest.js n=1000000 len=16                                                                -1.25 %       ±2.33% ±3.07%  ±3.94%
 http/create-clientrequest.js n=1000000 len=32                                                                 0.42 %       ±2.71% ±3.57%  ±4.59%
 http/create-clientrequest.js n=1000000 len=64                                                                -0.11 %       ±2.64% ±3.48%  ±4.48%
 http/create-clientrequest.js n=1000000 len=8                                                                  0.18 %       ±2.64% ±3.49%  ±4.48%
 http/end-vs-write-end.js method='end' c=100 len=1048576 type='asc' benchmarker='wrk'                          0.06 %       ±1.31% ±1.73%  ±2.22%
 http/end-vs-write-end.js method='end' c=100 len=1048576 type='buf' benchmarker='wrk'                          3.36 %       ±4.26% ±5.61%  ±7.21%
 http/end-vs-write-end.js method='end' c=100 len=1048576 type='utf' benchmarker='wrk'                         -0.24 %       ±1.45% ±1.91%  ±2.46%
 http/end-vs-write-end.js method='end' c=100 len=131072 type='asc' benchmarker='wrk'                           0.76 %       ±1.84% ±2.43%  ±3.11%
 http/end-vs-write-end.js method='end' c=100 len=131072 type='buf' benchmarker='wrk'                          -1.46 %       ±2.61% ±3.44%  ±4.42%
 http/end-vs-write-end.js method='end' c=100 len=131072 type='utf' benchmarker='wrk'                          -0.27 %       ±1.25% ±1.65%  ±2.12%
 http/end-vs-write-end.js method='end' c=100 len=262144 type='asc' benchmarker='wrk'                           0.35 %       ±1.47% ±1.94%  ±2.49%
 http/end-vs-write-end.js method='end' c=100 len=262144 type='buf' benchmarker='wrk'                          -1.44 %       ±3.84% ±5.06%  ±6.50%
 http/end-vs-write-end.js method='end' c=100 len=262144 type='utf' benchmarker='wrk'                          -1.02 %       ±1.45% ±1.91%  ±2.45%
 http/end-vs-write-end.js method='end' c=100 len=65536 type='asc' benchmarker='wrk'                           -1.35 %       ±2.74% ±3.61%  ±4.64%
 http/end-vs-write-end.js method='end' c=100 len=65536 type='buf' benchmarker='wrk'                            0.66 %       ±3.35% ±4.42%  ±5.67%
 http/end-vs-write-end.js method='end' c=100 len=65536 type='utf' benchmarker='wrk'                           -0.04 %       ±2.34% ±3.09%  ±3.97%
 http/end-vs-write-end.js method='write' c=100 len=1048576 type='asc' benchmarker='wrk'                        2.34 %       ±2.90% ±3.83%  ±4.92%
 http/end-vs-write-end.js method='write' c=100 len=1048576 type='buf' benchmarker='wrk'                        2.76 %       ±4.07% ±5.37%  ±6.89%
 http/end-vs-write-end.js method='write' c=100 len=1048576 type='utf' benchmarker='wrk'                       -1.42 %       ±2.31% ±3.04%  ±3.91%
 http/end-vs-write-end.js method='write' c=100 len=131072 type='asc' benchmarker='wrk'                        -0.50 %       ±1.93% ±2.55%  ±3.27%
 http/end-vs-write-end.js method='write' c=100 len=131072 type='buf' benchmarker='wrk'                 **     -3.43 %       ±2.51% ±3.31%  ±4.25%
 http/end-vs-write-end.js method='write' c=100 len=131072 type='utf' benchmarker='wrk'                         0.36 %       ±1.52% ±2.00%  ±2.57%
 http/end-vs-write-end.js method='write' c=100 len=262144 type='asc' benchmarker='wrk'                         0.93 %       ±2.25% ±2.97%  ±3.81%
 http/end-vs-write-end.js method='write' c=100 len=262144 type='buf' benchmarker='wrk'                         1.36 %       ±4.31% ±5.68%  ±7.30%
 http/end-vs-write-end.js method='write' c=100 len=262144 type='utf' benchmarker='wrk'                         0.28 %       ±1.53% ±2.01%  ±2.59%
 http/end-vs-write-end.js method='write' c=100 len=65536 type='asc' benchmarker='wrk'                          0.46 %       ±1.87% ±2.47%  ±3.17%
 http/end-vs-write-end.js method='write' c=100 len=65536 type='buf' benchmarker='wrk'                         -0.37 %       ±3.42% ±4.51%  ±5.80%
 http/end-vs-write-end.js method='write' c=100 len=65536 type='utf' benchmarker='wrk'                         -0.30 %       ±1.72% ±2.27%  ±2.92%
 http/http_server_for_chunky_client.js type='send' n=2000 len=1                                               -0.05 %       ±5.26% ±6.94%  ±8.92%
 http/http_server_for_chunky_client.js type='send' n=2000 len=128                                              0.65 %       ±5.24% ±6.92%  ±8.88%
 http/http_server_for_chunky_client.js type='send' n=2000 len=16                                               2.72 %       ±6.39% ±8.42% ±10.82%
 http/http_server_for_chunky_client.js type='send' n=2000 len=32                                              -0.21 %       ±5.65% ±7.45%  ±9.57%
 http/http_server_for_chunky_client.js type='send' n=2000 len=4                                                0.54 %       ±6.17% ±8.14% ±10.45%
 http/http_server_for_chunky_client.js type='send' n=2000 len=64                                               1.60 %       ±5.19% ±6.85%  ±8.79%
 http/http_server_for_chunky_client.js type='send' n=2000 len=8                                         *     -6.87 %       ±5.90% ±7.78%  ±9.99%
 http/http_server_for_chunky_client.js type='send' n=500 len=1                                                 0.72 %       ±3.38% ±4.46%  ±5.72%
 http/http_server_for_chunky_client.js type='send' n=500 len=128                                               0.53 %       ±3.42% ±4.51%  ±5.79%
 http/http_server_for_chunky_client.js type='send' n=500 len=16                                               -0.59 %       ±4.21% ±5.56%  ±7.14%
 http/http_server_for_chunky_client.js type='send' n=500 len=32                                               -0.90 %       ±4.46% ±5.88%  ±7.56%
 http/http_server_for_chunky_client.js type='send' n=500 len=4                                                -1.19 %       ±4.14% ±5.46%  ±7.02%
 http/http_server_for_chunky_client.js type='send' n=500 len=64                                                3.58 %       ±3.96% ±5.23%  ±6.71%
 http/http_server_for_chunky_client.js type='send' n=500 len=8                                                -2.43 %       ±4.36% ±5.75%  ±7.39%
 http/http_server_for_chunky_client.js type='send' n=50 len=1                                                 -3.03 %       ±3.12% ±4.12%  ±5.29%
 http/http_server_for_chunky_client.js type='send' n=50 len=128                                               -2.79 %       ±2.87% ±3.78%  ±4.86%
 http/http_server_for_chunky_client.js type='send' n=50 len=16                                                -1.39 %       ±3.70% ±4.89%  ±6.28%
 http/http_server_for_chunky_client.js type='send' n=50 len=32                                                 0.09 %       ±3.55% ±4.68%  ±6.01%
 http/http_server_for_chunky_client.js type='send' n=50 len=4                                                  0.74 %       ±3.60% ±4.74%  ±6.09%
 http/http_server_for_chunky_client.js type='send' n=50 len=64                                                -1.32 %       ±2.90% ±3.82%  ±4.91%
 http/http_server_for_chunky_client.js type='send' n=50 len=8                                                  0.02 %       ±3.36% ±4.44%  ±5.70%
 http/http_server_for_chunky_client.js type='send' n=5 len=1                                                  -1.35 %       ±3.21% ±4.24%  ±5.44%
 http/http_server_for_chunky_client.js type='send' n=5 len=128                                                 2.47 %       ±4.26% ±5.61%  ±7.21%
 http/http_server_for_chunky_client.js type='send' n=5 len=16                                                 -4.14 %       ±5.14% ±6.78%  ±8.71%
 http/http_server_for_chunky_client.js type='send' n=5 len=32                                                 -2.56 %       ±5.00% ±6.59%  ±8.46%
 http/http_server_for_chunky_client.js type='send' n=5 len=4                                                   0.36 %       ±5.04% ±6.65%  ±8.54%
 http/http_server_for_chunky_client.js type='send' n=5 len=64                                                  0.54 %       ±4.41% ±5.81%  ±7.47%
 http/http_server_for_chunky_client.js type='send' n=5 len=8                                                  -2.85 %       ±4.92% ±6.48%  ±8.33%
 http/set_header.js n=1000000 value='Connection'                                                              -0.17 %       ±2.26% ±2.98%  ±3.83%
 http/set_header.js n=1000000 value='Content-Length'                                                           0.21 %       ±1.57% ±2.07%  ±2.66%
 http/set_header.js n=1000000 value='Content-Type'                                                             1.27 %       ±1.61% ±2.12%  ±2.72%
 http/set_header.js n=1000000 value='Set-Cookie'                                                              -0.82 %       ±2.52% ±3.32%  ±4.27%
 http/set_header.js n=1000000 value='Transfer-Encoding'                                                 *      3.18 %       ±2.96% ±3.91%  ±5.03%
 http/set_header.js n=1000000 value='Vary'                                                                     1.52 %       ±2.71% ±3.57%  ±4.59%
 http/set_header.js n=1000000 value='X-Powered-By'                                                             0.59 %       ±1.96% ±2.58%  ±3.31%
 http/set-header.js res='normal' benchmarker='wrk'                                                     **      2.76 %       ±1.97% ±2.60%  ±3.34%
 http/set-header.js res='setHeader' benchmarker='wrk'                                                          1.44 %       ±1.75% ±2.31%  ±2.97%
 http/set-header.js res='setHeaderWH' benchmarker='wrk'                                                        1.66 %       ±1.79% ±2.36%  ±3.04%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=102400 type='buffer' benchmarker='wrk'                         2.47 %       ±3.65% ±4.82%  ±6.19%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=102400 type='bytes' benchmarker='wrk'                         -0.58 %       ±1.72% ±2.27%  ±2.91%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=1024 type='buffer' benchmarker='wrk'                           0.79 %       ±2.03% ±2.68%  ±3.44%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=1024 type='bytes' benchmarker='wrk'                            0.75 %       ±1.72% ±2.26%  ±2.91%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=4 type='buffer' benchmarker='wrk'                              0.10 %       ±1.97% ±2.59%  ±3.33%
 http/simple.js chunkedEnc=0 c=500 chunks=1 len=4 type='bytes' benchmarker='wrk'                               1.77 %       ±1.86% ±2.45%  ±3.15%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=102400 type='buffer' benchmarker='wrk'                        -0.95 %       ±3.24% ±4.27%  ±5.49%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=102400 type='bytes' benchmarker='wrk'                          1.09 %       ±1.49% ±1.97%  ±2.53%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=1024 type='buffer' benchmarker='wrk'                          -0.11 %       ±2.01% ±2.65%  ±3.41%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=1024 type='bytes' benchmarker='wrk'                            0.75 %       ±2.21% ±2.91%  ±3.74%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=4 type='buffer' benchmarker='wrk'                              0.68 %       ±2.28% ±3.01%  ±3.87%
 http/simple.js chunkedEnc=0 c=500 chunks=4 len=4 type='bytes' benchmarker='wrk'                              -0.23 %       ±1.96% ±2.58%  ±3.31%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=102400 type='buffer' benchmarker='wrk'                   *      3.12 %       ±2.85% ±3.77%  ±4.84%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=102400 type='bytes' benchmarker='wrk'                          -1.06 %       ±1.93% ±2.55%  ±3.28%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=1024 type='buffer' benchmarker='wrk'                            0.49 %       ±1.90% ±2.50%  ±3.21%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=1024 type='bytes' benchmarker='wrk'                             1.60 %       ±1.80% ±2.38%  ±3.06%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=4 type='buffer' benchmarker='wrk'                        *      2.36 %       ±1.80% ±2.38%  ±3.05%
 http/simple.js chunkedEnc=0 c=50 chunks=1 len=4 type='bytes' benchmarker='wrk'                        **      3.10 %       ±2.04% ±2.69%  ±3.45%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=102400 type='buffer' benchmarker='wrk'                          0.13 %       ±3.01% ±3.97%  ±5.10%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=102400 type='bytes' benchmarker='wrk'                           0.49 %       ±1.41% ±1.86%  ±2.38%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=1024 type='buffer' benchmarker='wrk'                            0.84 %       ±1.98% ±2.61%  ±3.35%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=1024 type='bytes' benchmarker='wrk'                      *      1.78 %       ±1.74% ±2.29%  ±2.94%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=4 type='buffer' benchmarker='wrk'                               1.79 %       ±1.85% ±2.44%  ±3.13%
 http/simple.js chunkedEnc=0 c=50 chunks=4 len=4 type='bytes' benchmarker='wrk'                               -0.10 %       ±1.75% ±2.31%  ±2.96%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=102400 type='buffer' benchmarker='wrk'                         0.75 %       ±3.40% ±4.48%  ±5.75%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=102400 type='bytes' benchmarker='wrk'                         -0.38 %       ±1.39% ±1.83%  ±2.35%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=1024 type='buffer' benchmarker='wrk'                           0.94 %       ±1.98% ±2.61%  ±3.35%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=1024 type='bytes' benchmarker='wrk'                            1.85 %       ±2.36% ±3.12%  ±4.00%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=4 type='buffer' benchmarker='wrk'                              0.32 %       ±1.73% ±2.29%  ±2.94%
 http/simple.js chunkedEnc=1 c=500 chunks=1 len=4 type='bytes' benchmarker='wrk'                               1.69 %       ±2.11% ±2.79%  ±3.58%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=102400 type='buffer' benchmarker='wrk'                        -0.70 %       ±2.79% ±3.69%  ±4.73%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=102400 type='bytes' benchmarker='wrk'                          0.58 %       ±1.41% ±1.86%  ±2.39%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=1024 type='buffer' benchmarker='wrk'                           1.38 %       ±2.24% ±2.96%  ±3.80%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=1024 type='bytes' benchmarker='wrk'                            0.77 %       ±2.50% ±3.30%  ±4.24%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=4 type='buffer' benchmarker='wrk'                              0.57 %       ±2.55% ±3.37%  ±4.33%
 http/simple.js chunkedEnc=1 c=500 chunks=4 len=4 type='bytes' benchmarker='wrk'                               0.87 %       ±2.55% ±3.36%  ±4.31%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=102400 type='buffer' benchmarker='wrk'                          0.01 %       ±3.04% ±4.01%  ±5.15%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=102400 type='bytes' benchmarker='wrk'                           1.02 %       ±1.78% ±2.35%  ±3.02%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=1024 type='buffer' benchmarker='wrk'                           -0.53 %       ±1.70% ±2.24%  ±2.87%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=1024 type='bytes' benchmarker='wrk'                             0.28 %       ±1.79% ±2.36%  ±3.03%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=4 type='buffer' benchmarker='wrk'                               0.45 %       ±1.70% ±2.25%  ±2.88%
 http/simple.js chunkedEnc=1 c=50 chunks=1 len=4 type='bytes' benchmarker='wrk'                                0.84 %       ±1.77% ±2.33%  ±3.00%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=102400 type='buffer' benchmarker='wrk'                         -0.13 %       ±2.85% ±3.76%  ±4.83%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=102400 type='bytes' benchmarker='wrk'                           0.11 %       ±1.33% ±1.75%  ±2.25%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=1024 type='buffer' benchmarker='wrk'                            1.27 %       ±1.69% ±2.23%  ±2.86%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=1024 type='bytes' benchmarker='wrk'                             1.32 %       ±1.76% ±2.32%  ±2.98%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=4 type='buffer' benchmarker='wrk'                       **      2.39 %       ±1.54% ±2.03%  ±2.61%
 http/simple.js chunkedEnc=1 c=50 chunks=4 len=4 type='bytes' benchmarker='wrk'                                1.48 %       ±1.49% ±1.96%  ±2.52%
 http/upgrade.js n=1000                                                                                        0.08 %       ±2.66% ±3.51%  ±4.51%
 http/upgrade.js n=5                                                                                           1.13 %       ±2.07% ±2.74%  ±3.51%

@BridgeAR BridgeAR added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label Apr 22, 2018
apapirovski added a commit that referenced this pull request Apr 22, 2018
Handrolling and checking char by char is no longer faster than just
using toLowerCase and strict comparison.

PR-URL: #20131
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
apapirovski added a commit that referenced this pull request Apr 22, 2018
Using a switch improves clarity of the code but also performance for
all but a few edge cases which remain on par with the old code.

PR-URL: #20131
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
apapirovski added a commit that referenced this pull request Apr 22, 2018
Remove upgrade from the regular expression as it is no longer used
and switch to using `.test()` instead of `.match()` as the value
matched is irrelevant.

PR-URL: #20131
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
@apapirovski
Copy link
Member Author

Landed in db0174b, 54caeae and e5f5320

@apapirovski apapirovski deleted the patch-http-simplify-checks branch April 22, 2018 05:54
jasnell pushed a commit that referenced this pull request Apr 23, 2018
Handrolling and checking char by char is no longer faster than just
using toLowerCase and strict comparison.

PR-URL: #20131
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
jasnell pushed a commit that referenced this pull request Apr 23, 2018
Using a switch improves clarity of the code but also performance for
all but a few edge cases which remain on par with the old code.

PR-URL: #20131
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
jasnell pushed a commit that referenced this pull request Apr 23, 2018
Remove upgrade from the regular expression as it is no longer used
and switch to using `.test()` instead of `.match()` as the value
matched is irrelevant.

PR-URL: #20131
Reviewed-By: Richard Lau <riclau@uk.ibm.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Yuta Hiroto <hello@hiroppy.me>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. http Issues or PRs related to the http subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

9 participants