-
Notifications
You must be signed in to change notification settings - Fork 79
http2: additional refinement of stream/session #138
Conversation
95d458b
to
96afff0
Compare
@mcollina ... ok, take a look. I think most of the comments are addressed with the exception of the error code for an invalid / destroyed stream. |
Note that the |
@mcollina ... following the rebase off master the other day, it looks like we now have some fairly significant issues on the internals due to the changes in async_wrap that landed as part of async_hooks. We're getting some check asserts that are caused by the stack not properly unwinding as expected. This is most likely caused by insufficient |
@mcollina ... just fyi... I'm going through the internals on the native side and after going through things for #143, I've decided that it needs a fairly significant internal refactor. I'm going to be working on that next. Hopefully it shouldn't take too long. Basically, what I need to refactor is the part that buffers callbacks on nghttp2 receives frames. Right now, that buffering is (a) inefficient, (b) largely unnecessary, and (c) causes issues when a stream is destroyed on the same tick as other callbacks (buffered data chunks end up being dropped on the floor). It's a fairly significant internal refactoring but it should not have any impact on the JS level API. I will do the refactoring as part of this PR |
@jasnell Not sure if it's entirely related but some async_wrap/TLS issues were fixed in the node repo since the rebase here in the http2 fork last week. Maybe do another rebase? E.g. NPM doesn't work using the fork but this PR landed 3 days ago and fixed it. nodejs/node#13092 |
That could certainly be part of it, but there are a number of other weaknesses internally and improvements that can be made. Expect a fairly sizeable pr ;) |
So... these are the constraints that we need to work within. Like I said, I would love someone to take a look and improve this part. |
@jasnell I will be traveling for the next two weeks, so I cannot really help. I think opening up a separate issue with that content (after you land this) will help. |
@jasnell Are you proposing that the logic in I'd be interested in helping out with this. |
@jasnell Just want to throw an idea out here: Move the validation logic out of FWIW I'm measuring ~40-50% rps drop from core to compat with a minimalist |
@sebdeckers the one key constraint is that even the minimal core API needs to be completely compliant to the spec. I don't want to sacrifice any spec compliance for performance. We did that with the http/1 implementation and it has come back to bite us numerous times. |
ebee5a1
to
9430a78
Compare
@mcollina @nodejs/http2 ... all, this PR is updated with a fairly sizable and important refactoring of the http2 internals. I have eliminated the caching of the callbacks, improved the lifecycle state of stream and session, and fixed a range of bugs in the process. The data bug #143 should be fixed by this. @mcollina ... we should check the performance impact of this change. |
@jasnell Great work! 🤠 Just a quick obersvation. I did a Client:
Server (this continues as long as the client is connected though idle):
It completely floods the terminal in less than a second. Is this expected? Edit: The bug does seem to be fixed, thank you! 👏 |
Yeah, likely better not to print those debug statements then |
@jasnell Any specific goals for these perf benchmarks? Which metrics, protocol features, client/server setups, stream:session ratios, request/response types, etc. @mcollina Is anyone planning to port autocannon to http2? I've been using ngload which is great for basic, http1-like, load tests. However it lacks proper PUSH_PROMISE support. |
@sebdeckers ... specific goals right now are only to have a good idea of where we are at currently. I have had in my list for some time the need to set up proper benchmarks for http2 like we have with http in core. The http benchmarks require external tools to be installed, and the same would be true in this case. What I imagine, at first, is that we would initially just use nghttp2's own h2load benchmarking tool |
After we release this, I would get it added. More likely, it would be a new tool as autocannon is really tied to HTTP/1.1 |
@mcollina ... let me know if the refactor looks good to you. I'll be running a bunch of benchmarks this week but I'd like to get this landed. |
LGTM |
Following rebase, test file is no longer needed also: TEMPORARY... allow the test-async-wrap-getasyncid to pass by skipping the http2 specific bits
The WriteWrap impl details changed slightly. Fixup the cleanup logic for SessionSendBuffer class in node_http2.h accordingly.
* tighten up the Http2Stream/Http2Session lifecycle, destroy, and error handling. Some simplification, and more new tests * Eliminate queuing of internal callbacks. Queuing these to fire on the next event loop tick was throwing off timing. Now the js callbacks are called directly as they happen. This will require a bit more finesse on the javascript side (to ensure appropiate timing of destroy/shutdown actions) but that is handled from within the core api impl so users should not be affected. * fix debug output with nghttp2
Using `./configure --debug-http2` will enable verbose debug statements from node.js, Using `./configure --debug-nghttp2` will enable verbose debug statements from nghttp2. The two can be used together
ba4d445
to
d6d0dff
Compare
Rebased and updated. Landing! |
* tighten up the Http2Stream/Http2Session lifecycle, destroy, and error handling. Some simplification, and more new tests * Eliminate queuing of internal callbacks. Queuing these to fire on the next event loop tick was throwing off timing. Now the js callbacks are called directly as they happen. This will require a bit more finesse on the javascript side (to ensure appropiate timing of destroy/shutdown actions) but that is handled from within the core api impl so users should not be affected. * fix debug output with nghttp2 PR-URL: #138 Reviewed-By: Matteo Collina <[email protected]>
Using `./configure --debug-http2` will enable verbose debug statements from node.js, Using `./configure --debug-nghttp2` will enable verbose debug statements from nghttp2. The two can be used together PR-URL: #138 Reviewed-By: Matteo Collina <[email protected]>
Landed! |
* tighten up the Http2Stream/Http2Session lifecycle, destroy, and error handling. Some simplification, and more new tests * Eliminate queuing of internal callbacks. Queuing these to fire on the next event loop tick was throwing off timing. Now the js callbacks are called directly as they happen. This will require a bit more finesse on the javascript side (to ensure appropiate timing of destroy/shutdown actions) but that is handled from within the core api impl so users should not be affected. * fix debug output with nghttp2 PR-URL: nodejs#138 Reviewed-By: Matteo Collina <[email protected]>
Using `./configure --debug-http2` will enable verbose debug statements from node.js, Using `./configure --debug-nghttp2` will enable verbose debug statements from nghttp2. The two can be used together PR-URL: nodejs#138 Reviewed-By: Matteo Collina <[email protected]>
* tighten up the Http2Stream/Http2Session lifecycle, destroy, and error handling. Some simplification, and more new tests * Eliminate queuing of internal callbacks. Queuing these to fire on the next event loop tick was throwing off timing. Now the js callbacks are called directly as they happen. This will require a bit more finesse on the javascript side (to ensure appropiate timing of destroy/shutdown actions) but that is handled from within the core api impl so users should not be affected. * fix debug output with nghttp2 PR-URL: nodejs#138 Reviewed-By: Matteo Collina <[email protected]>
Using `./configure --debug-http2` will enable verbose debug statements from node.js, Using `./configure --debug-nghttp2` will enable verbose debug statements from nghttp2. The two can be used together PR-URL: nodejs#138 Reviewed-By: Matteo Collina <[email protected]>
* tighten up the Http2Stream/Http2Session lifecycle, destroy, and error handling. Some simplification, and more new tests * Eliminate queuing of internal callbacks. Queuing these to fire on the next event loop tick was throwing off timing. Now the js callbacks are called directly as they happen. This will require a bit more finesse on the javascript side (to ensure appropiate timing of destroy/shutdown actions) but that is handled from within the core api impl so users should not be affected. * fix debug output with nghttp2 PR-URL: nodejs#138 Reviewed-By: Matteo Collina <[email protected]>
Using `./configure --debug-http2` will enable verbose debug statements from node.js, Using `./configure --debug-nghttp2` will enable verbose debug statements from nghttp2. The two can be used together PR-URL: nodejs#138 Reviewed-By: Matteo Collina <[email protected]>
tightening up the Http2Stream/Http2Session lifecycle, destroy, and
error handling. Some simplification, and more new tests
Checklist
make -j4 test
(UNIX), orvcbuild test
(Windows) passesAffected core subsystem(s)
http2