question about performance of FrameDecoder and ChannelBuffer

Christian Migowski chrismfwrd at gmail.com
Thu Nov 20 04:38:35 EST 2008


Hi,

I want to implement a protocol decoder with Netty for a protocol that
hasn't fixed length nor fixed delimiter delimited messages (until I
look at it that is: XML fragments).
I think I am going to use the FrameDecoder for this, what do you think
is the most efficient approach with Netty:
- in the decode(...) method, should I:

(a) read all readableBytes() from the ChannelBuffer, try to find the message
disadvantage: I may (quite certainly) read much more than one message
from the Buffer, but for the sake of simple processing I want to
decode only one message at a time; i.e. I read messages multiple times
from the ChannelBuffer until they are "first"

(b) read a certain amount of bytes (I can make a guess how long an
average message is), see if there is a complete message in it, if read
in the next call twice as much and so on
disadvantage: I may have useless calls to decode(...) and everything
in it if the fixed buffer size is too small for a message.

What do you think will be more performant with Netty's FrameDecoder
and ChannelBuffer?
Btw, why are the method names for the readIndex and writeIndex in
ChannelBuffer not named get..()/set...() ?


thanks in advance,
best regards,
christian



More information about the netty-users mailing list