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:
updated the avoidParserCoW() helper function to take into consideration throwing functions
used it in the switch cases over the parser state inside processNextState()
Result:
CoW will be avoided when changing the state of the HTTP2FrameDecoder while decoding, so we won't have unnecessary heap allocations.
Motivation:
CoWs appear when switching over the current state of the parser and holding it while also modifying it - inside
processNExtState()
. Followingappend(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:
avoidParserCoW()
helper function to take into consideration throwing functionsprocessNextState()
Result:
CoW will be avoided when changing the state of the HTTP2FrameDecoder while decoding, so we won't have unnecessary heap allocations.