Details
Description
CharSequenceEncoder uses CharBuffer.wrap and charset.encode to encode String data to its binary representation. There can be two optimizations made here:
1. CharSequenceEncoder uses typically UTF-8 encoding and Java's UTF-8 encoder requires significant computing time. It would make sense to detect this case and whether netty is on the class path to use netty's optimized UTF-8 encoding via ByteBufUtil.writeUtf8(…)
2. Encoding creates a new unpooled ByteBuffer when calling Charset.encode. Netty's ByteBufUtil.encodeString() can encode a String to a pooled buffer that reduces GC pressure.
See also attached profiling snapshot.