apple / swift-nio-http2

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

Avoid CoW while processing the next state when HTTP2FrameDecoder decodes #438

Closed stefanadranca closed 6 months ago

stefanadranca commented 7 months ago

Motivation:

CoWs appear when switching over the current state of the parser and holding it while also modifying it - inside processNExtState(). Following append(bytes: ByteBuffer)'s pattern, we should use a function that sets the state to an intermediary one with no associated data, before making the transformations.

Modifications:

Result:

CoW will be avoided when changing the state of the HTTP2FrameDecoder while decoding, so we won't have unnecessary heap allocations.

glbrntt commented 7 months ago

@swift-server-bot add to allowlist