ee7027288e
Motivation: ByteToMessageDecoder's default MERGE_CUMULATOR will allocate a new buffer and copy if the refCnt() of the cumulation is > 1. However this is overly conservative because we maybe able to avoid allocate/copy if the current cumulation can accommodate the input buffer without a reallocation. Also when the reallocation and copy does occur the new buffer is sized just large enough to accommodate the current the current amount of data. If some data remains in the cumulation after decode this will require a new allocation/copy when more data arrives. Modifications: - Use maxFastWritableBytes to avoid allocation/copy if the current buffer can accommodate the input data without a reallocation operation. - Use ByteBufAllocator#calculateNewCapacity(..) to get the size of the buffer when a reallocation/copy operation is necessary. Result: ByteToMessageDecoder MERGE_CUMULATOR won't allocate/copy if the cumulation buffer can accommodate data without a reallocation, and when a reallocation occurs we are more likely to leave additional space for future data in an effort to reduce overall reallocations. |
||
---|---|---|
.. | ||
src | ||
pom.xml |