-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
Add HTTP/2 implementation of HTTPChannel. #8194
Comments
Having uploaded the first draft patch, I'll put this out for early review. |
Turns out I totally forgot to add HTTP/2 into this patch! The second draft patch contains the actual HTTP/2 work. |
I guess that with latest changes in [#8191](#8191) this needs to be updated. Also, maybe is a good idea to rewrite this based on latest changes from #8191 to validate if they make sense. |
Space is watched - how's the re-work going? |
Currently going for 100% test coverage. At 92% at the moment, so expect something this week, basically. |
Ok, for the sake of early review, I've uploaded the draft patch containing some HTTP/2 tests. Here are some notes about this patch. Firstly, I believe it's basically entirely feature complete for the basic use-case: that is, when combined with a slightly updated patch for #8188, we can happily serve HTTP/2, at least when running Secondly, it does not currently have complete coverage. Essentially all of the missing coverage comes down to the functionality around IPushProducer in the H2Connection object. The reason I haven't tested this is that I'm not sure whether the H2Connection should test, at the time Thirdly, some portions of the code are quite unpleasant. In particular, Fourthly, the tests are crazy complex. This is admittedly because most of the tests have to exercise weird code paths, but it's also partly because of the way Of course, any other feedback would be welcomed as well! |
As requested by hawkowl, I've updated the patch in #8188 so that it should apply cleanly alongside this patch. With both patches applied, To test this live, take your copy of Twisted and apply the latest patches on this issue and #8188. You can then, for example, serve your Twisted source tree by running |
(In [47207]) Branching to h2channel-8194. |
(In [47209]) Branching to h2channel-8194-2. |
Hi Lukasa, thanks for the continued work on this wonderful feature! Just a few notes for this early-review:
Overall, I like this. I think it's a sufficiently large batch of functionality that we will really only know how it works once it's in the field, so I am considering that a slightly-more-polished version of this would be able to land, gated behind a But, for the meantime: please fix the tests, and the things I mentioned above, and then please resubmit. |
Ok, so I've addressed 1, 2, 4, 5, and 6 (at least, I believe I have) and uploaded a new draft patch that addresses those problems. That's ready for review. On the topic of the 12.04 builder, the problem is this:
That is, the I'm not sure exactly what you'd like to do about that. Suggestions? |
(In [47211]) Branching to h2channel-8194-3. |
Per an informal chat with hawkowl, I've uploaded a new patch that raises a UserWarning on Python 2.7.3 and older and then refuses to import HTTP/2 support. That should resolve the problem by degrading gracefully on crappy old versions of Python. |
The last two patches fix up a couple of minor issues, including a stupid tuple comparison and a unicode/bytes problem. |
(In [47213]) Branching to h2channel-8194-4. |
Patch 11 should resolve some more of our Python 3 test problems (hopefully all of them). |
(In [47215]) Branching to h2channel-8194-5. |
Uploaded a new file that fixes another failing test. |
(In [47217]) Branching to h2channel-8194-6. |
Hi Lukasa, thanks again for your continued work on this branch! The tests all pass now which makes me happy :)
Thanks again. Please fix these issues and resubmit! |
Ok, so! We've merged some of the important issues, so I'm providing a new version of this with the feedback from above applied. Per the other tickets I'm no longer using patches but instead am maintaining a branch on GitHub, which can be found here. I've updated the branch to handle the feedback from hawkie. This is now good for review. I think we're going to be short on coverage, but I'd like to confirm that everything is still working and get a coverage report from the builders before I chase coverage again. |
Pulled in Lukasa's branch, sending to the builders... |
As mentioned at pycon:
Please fix these up and throw more code at me :) |
Ok, hawkie, I believe I've done this. One note on the coverage: I haven't covered the 2.7.3 and earlier import rejection because I can't think of a good way to do it. Let me know if we need to chase it. |
Hi Cory, thanks for this.
Otherwise, I think we're getting close here. Please fix these up and resubmit. |
Oh, also Python 3 is broken. :P |
Ok, I've fixed all that up and pushed to my branch. Unfortunately, hawkie, I've had to force push to my branch, in part because I wanted to rebase on top of trunk to take account of your intersphinx changes and to make the final merge easier. This, in turn, means you'll need to pull to a new branch. |
Hi Cory, thanks again. Unfortunately a few tests fail:
Please fix these up, then I think we could just land this... |
There's also a few new pydoctor errors: https://buildbot.twistedmatrix.com/builders/documentation/builds/195/steps/api-documentation/logs/new%20pydoctor%20errors |
Ok, I've updated my branch to address those problems. Let's go again! |
Fixed up the test failure on my branch... waiting for the builders. |
This is part of a series of patches adding support for HTTP/2 to twisted.web: see #7460 for more.
This patch contains the meat of the HTTP/2 support, introducing two new classes:
H2Connection
andH2Stream
. These classes together implement the same support asHTTPChannel
. The reason for the two-class approach is explained somewhat in code comments, but I'll explain it again here.With
HTTPChannel
it is capable of implementing bothIConsumer
andIProducer
directly because there is a strictly one-to-one correlation between a request/response pair and a transport. While a single transport may carry many requests/responses over time, at any one time there is only one outstanding.This is not true with HTTP/2: at any one time there may be as many as 2 billion request/response pairs outstanding (though generally this is limited to more like 100, for obvious reasons!). For this reason, it's not possible to naively implement both
IProducer
andIConsumer
on one class.Instead, we have one object implementing
IPushProducer
directly and pushing data to the TCP connection (H2Connection
), while implementingIProtocol
to receive data from the TCP connection. Another object (H2Stream
) implementsIPushProducer
the other way, pushing data to theIRequest
.H2Stream
also implementsIConsumer
andITransport
, consuming the response body from theIRequest
, allowing the HTTP/2 flow control signalling to propagate out to theIRequest
objects. Between theH2Stream
andH2Connection
objects there is an interface that looks very similar toIProducer
/IConsumer
, but with the addition of stream IDs that allow for there to be manyIRequest
objects for one underlying TCP stream.Essentially, for each m HTTP/2 connections, each with n requests/responses active at any one time, we have: m TCP streams, m H2Connections, m x n H2Streams, and m x n IRequest objects.
The patch I'm about to upload implements this functionality and has been live tested. By itself it doesn't do anything: it needs the other patches to be properly integrated into twisted.web. However, it should be possible for us to unit test this patch, and I'll aim to do that. Before I get to that though, I did want some Twisted contributors to cast an eye over it and see if they're happy with the general shape and direction of the patch.
Attachments:
Searchable metadata
The text was updated successfully, but these errors were encountered: