apple / swift-nio-http2

HTTP/2 support for SwiftNIO

Home Page:https://swiftpackageindex.com/apple/swift-nio-http2/main/documentation/niohttp2

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Integrate the multiplexer into the HTTP2Handler

Lukasa opened this issue · comments

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.

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

This was done without breaking API across a handful of PRs: #377, #379, #380, #381, #382, #383, #384, #386.