0

I am suspecting bad codec for the slow performance of my Netty 4.0.19 client server app. The simple message object consists of an integer id and two strings with their accompanying lengths. I use CharsetDecoder in ReplayingDecoder to get string from bytes:

msg.value = charsetDecoder.decode(in.readBytes(msg.valueLen).nioBuffer()).toString();
checkpoint(CDRMessageDecoderState.FIELD_MASK_METHOD);

In ByteToMessageDecoder I use fast Kryo library for serialization (can creating the indirect heap buffer here be avoided?):

protected void decode(ChannelHandlerContext ctx, ByteBuf buffer, List<Object> out) throws Exception 
{
    if (!buffer.isReadable())
        return;

    // read header
    if (contentSize == 0) {
        contentSize = buffer.readInt();
    }

    if (buffer.readableBytes() < contentSize) {
        return;
    }

    // read content
    byte [] buf = new byte[buffer.readableBytes()];
    buffer.readBytes(buf);
    Input in = new Input(buf);
    out.add(kryoCodec.readObject(in, CDRMessage.class));
    contentSize = 0;

}

Currently, ReplayingDecoder seems to somehow outperform ByteToMessageDecoder. Also, I have some simple backend logic running in DefaultEventExecutorGroup (so I don't think it blocks the event thread), which looks up HashMaps and writes the messages to the ChannelHandlerContext, with writeAndFlush. Thanx

  • What is the question ? – Norman Maurer Jul 27 '14 at 22:31
  • 1) What would be the fastest codec for messages containing two short strings (As the client spends 30% time on ByteBuf.write(..) encoding)? 2) What are the ChannelOption settings for fast transmission of such cca 30 byte long messages (the client blocks until certain messages are replied)? Thanks! – user3176934 Jul 28 '14 at 16:38

0 Answers0