-
-
Notifications
You must be signed in to change notification settings - Fork 32.2k
http: improve performance by removing async_hooks #57746
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
Conversation
Review requested:
|
Pending positive benchmarks, I’m in favor of this change as the http parser does not have inherent asynchronous behavior and it’s all sync. |
df87762
to
a7399d4
Compare
HTTP parser instances are reused between HTTP requests (there is a pool of them). in contrast to parser HTTP requests are async and each HTTP request holds a parser. There are some tests deleted in this PR which verify that each HTTP request is seen as an unique async resource. AsyncLocalStore is/was built on top of async hooks (get current resource), as a result test coverage for ALS is quite limited because of this.. Therefore I fear that this is quite breaking for ALS users. I recommend to add tests similar to the deleted ones but using AsyncLocalStore API to ensure nothing is broken because of this removal. |
src/node_http_parser.cc
Outdated
v8::TryCatch try_catch(env()->isolate()); | ||
USE(cb.As<Function>()->Call(env()->context(), object(), 1, &ret)); | ||
|
||
if (try_catch.HasCaught()) { |
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 don't think we need this. We just shouldn't throw if the previous js callback throws, but we shouldn't stop the flow when an error is thrown on the user handler.
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #57746 +/- ##
==========================================
+ Coverage 90.22% 90.24% +0.01%
==========================================
Files 630 630
Lines 185055 186045 +990
Branches 36216 36455 +239
==========================================
+ Hits 166975 167905 +930
+ Misses 11042 10995 -47
- Partials 7038 7145 +107
🚀 New features to boost your workflow:
|
lib/_http_server.js
Outdated
@@ -687,7 +687,6 @@ function connectionListenerInternal(server, socket) { | |||
// https://github.com/nodejs/node/pull/21313 | |||
parser.initialize( | |||
HTTPParser.REQUEST, | |||
new HTTPServerAsyncResource('HTTPINCOMINGMESSAGE', socket), |
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.
The HTTPServerAsyncResource
class can now be removed I believe.
Sorry everyone, looks like the lack of sleep as a new parent caused me to not even notice that I pushed this from my main fork branch. I'll close this PR and reopen it on a proper branch, with a link to the discussions here. |
Pending benchmarks, but this should improve http request performance.
Github search results for HTTPIncomingMessage and HTTPClientRequest