apple / swift-nio-http2

HTTP/2 support for SwiftNIO
https://swiftpackageindex.com/apple/swift-nio-http2/main/documentation/niohttp2
Apache License 2.0
462 stars 82 forks source link

Integrate the multiplexer into the HTTP2Handler #137

Closed Lukasa closed 1 year ago

Lukasa commented 5 years ago

In v2, we should bring the HTTP2StreamMultiplexer into the NIOHTTP2Handler and integrate them together, rather than having them be separate channel handlers.

While it's been a nice design idea to separate these out, the result of that change has been that we incur an expensive and very noisy interface between these two tightly-related classes. The NIOHTTP2Handler has to tell the HTTP2StreamMultiplexer some metadata on almost every frame (flow control changes, which affect the sending and receiving of DATA and WINDOW_UPDATE frames, and stream state changes, which affect HEADERS, RST_STREAM, and GOAWAY: basically all the frames, then). This metadata requires an extra pipeline walk to communicate, leading to a load of needless ARC traffic and extra cost.

Rather than incur that cost, we should smush these two together and take advantage of the fact that they are, in fact, tightly coupled. This should give us a nice performance win as well as a huge correctness boost.

Lukasa commented 5 years ago

To be clear, I think the interface to and public nature of HTTP2StreamMultiplexer should remain: it just shouldn't be a ChannelHandler any more.

glbrntt commented 1 year ago

This was done without breaking API across a handful of PRs: https://github.com/apple/swift-nio-http2/pull/377, https://github.com/apple/swift-nio-http2/pull/379, https://github.com/apple/swift-nio-http2/pull/380, https://github.com/apple/swift-nio-http2/pull/381, https://github.com/apple/swift-nio-http2/pull/382, https://github.com/apple/swift-nio-http2/pull/383, https://github.com/apple/swift-nio-http2/pull/384, https://github.com/apple/swift-nio-http2/pull/386.