mirror of
https://github.com/apple/swift-nio-http2
synced 2026-11-23 04:34:24 +00:00
Motivation: The `HTTP2StreamChannel` keeps track of how many bytes have been written and how many are buffered for use in evaluating the 'writability' of the stream channel. Bytes are considered 'written' or at least no longer buffered when the write is completed (successfully or errored). In order to make the determination of when writes are complete across channel handlers we attach a promise to all writes and deduct adjust the byte counts on completion. Creating and attaching these promises requires costly allocations. Modifications: We can remove the need to create these promises for the new inline stream multiplexer because the multiplexer and man HTTP2 channel operations are now all within the `HTTP2ChannelHandler`. This change calls the `writabilityManager` directly when writes are completed. Result: * Fewer allocations are required for HTTP2 writes. * Writes are considered 'complete' when they leave the `HTTP2ChannelHandler`