question about performance of FrameDecoder and ChannelBuffer

Trustin Lee tlee at redhat.com
Fri Nov 21 02:20:17 EST 2008


Hi Jan,

Thanks for sharing your experience.  I don't see any flaw in your
explanation!  :)

Cheers,
Trustin

On Fri, Nov 21, 2008 at 03:38:02PM +0900, jdv145 wrote:
> 
> Hi,
> 
> I just started using netty myself so i can't really be sure about the
> performance and stuff.. but i used a 0 byte delimited frames because that is
> easy to decode and easy to fnd the beginning of the next frame if something
> goes wrong. As long as you are not sending any binary data (which can
> contain 0 bytes) its a pretty good method i think because it is easy, robust
> and you can't do much wrong with it. 
> 
> But im a bit of a noob here (although my netty-server works no less then
> perfect) so im sure someone more knowledgable will answer your question with
> some more details :). 
> 
> regards,
> jan
>  
> 
> christian wrote:
>> 
>> 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
> 
 
-- 
Trustin Lee, Principal Software Engineer, JBoss, a division of Red Hat
--
what we call human nature is actually human habit
--
http://gleamynode.net/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: not available
Url : http://lists.jboss.org/pipermail/netty-users/attachments/20081121/595ab5c2/attachment.bin 


More information about the netty-users mailing list