-
Notifications
You must be signed in to change notification settings - Fork 29.6k
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: improve performance for incoming headers #26041
Conversation
lib/_http_incoming.js
Outdated
@@ -137,130 +137,101 @@ function _addHeaderLines(headers, n) { | |||
|
|||
// 'array' header list is taken from: | |||
// https://mxr.mozilla.org/mozilla/source/netwerk/protocol/http/src/nsHttpHeaderArray.cpp |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this comment might be outdated now? The link is dead at any rate.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This link is redirected to here. But I think it might not be a good way to keep an unstable url in comment. Should I remove it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd be okay with removing it.
if (lowercased) { | ||
return '\u0000' + field; | ||
} else { | ||
return matchKnownFields(field.toLowerCase(), true); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It might be slightly faster to use iteration than recursion. it might also be a wash, however. :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've run the benchmark of iteration and found there was no difference between them.
lib/_http_incoming.js
Outdated
return 'expires'; | ||
case 'Set-Cookie': | ||
case 'set-cookie': | ||
if (field === 'If-Match' || field === 'if-Match') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't this supposed to be if-match
instead of if-Match
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I'll change it.
CI before landing: https://ci.nodejs.org/job/node-test-pull-request/20749/ |
Landed in da0dc51 |
PR-URL: nodejs#26041 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
PR-URL: #26041 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
This improves the performance of
matchKnownFields
. This function is heavily used when parsing incoming http headers.Here is the benchmark result:
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passes