-
Notifications
You must be signed in to change notification settings - Fork 30k
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: various performance improvements #10558
Changes from all commits
f53a6fb
ec8910b
c00e4ad
c77ed32
73d9445
176cdc2
b888bfe
a3539ae
03b9f6f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,8 +131,12 @@ function ClientRequest(options, cb) { | |
self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n', | ||
options.headers); | ||
} else if (self.getHeader('expect')) { | ||
if (self._header) { | ||
throw new Error('Can\'t render headers after they are sent to the ' + | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This additional throw probably makes this PR semver-major? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't, I just had to move the check from the old |
||
'client'); | ||
} | ||
self._storeHeader(self.method + ' ' + self.path + ' HTTP/1.1\r\n', | ||
self._renderHeaders()); | ||
self._headers); | ||
} | ||
|
||
this._ended = false; | ||
|
@@ -224,8 +228,11 @@ ClientRequest.prototype._finish = function _finish() { | |
}; | ||
|
||
ClientRequest.prototype._implicitHeader = function _implicitHeader() { | ||
if (this._header) { | ||
throw new Error('Can\'t render headers after they are sent to the client'); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As does this one There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It shouldn't, I just had to move the check from the old |
||
} | ||
this._storeHeader(this.method + ' ' + this.path + ' HTTP/1.1\r\n', | ||
this._renderHeaders()); | ||
this._headers); | ||
}; | ||
|
||
ClientRequest.prototype.abort = function abort() { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,8 @@ const debug = require('util').debuglog('http'); | |
exports.debug = debug; | ||
|
||
exports.CRLF = '\r\n'; | ||
exports.chunkExpression = /chunk/i; | ||
exports.continueExpression = /100-continue/i; | ||
exports.chunkExpression = /(?:^|\W)chunked(?:$|\W)/i; | ||
exports.continueExpression = /(?:^|\W)100-continue(?:$|\W)/i; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why those changes? are they faster, or safer? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's more explicit and therefore at least a little safer and it's consistent with the other regexps we use in _http_server.js when searching header values that can be comma-separated lists. I did not measure the performance of this particular change on its own. |
||
exports.methods = methods; | ||
|
||
const kOnHeaders = HTTPParser.kOnHeaders | 0; | ||
|
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.
Can these be
Map
s instead? Also,let
?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.
AFAIK
Map
is still slow and http benchmarks already take a very long time as it is.As far as converting to ES6 goes, that's for a separate PR I think. All I was doing in this part here was the changing style.
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.
That is why we have https://github.com/nodejs/node/blob/master/benchmark/es/map-bench.js - tl;dr, it's faster.
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.
Map
performance definitely appears to have improved significantly as of late.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.
Right, but I seem to recall some issue with that benchmark. I think there was discussion in some issue/PR awhile ago about it?