You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mina.apache.org by Julien Vermillard <jv...@archean.fr> on 2006/07/17 16:46:15 UTC

PDU performance stats

Hi all,

Actualy it's very easy to calculate bytes thoughput (read and write) by
looking in the IoSession objects and using the following methods :

 long getReadBytes() 
          Returns the total number of bytes which were read from this
session.

 long getWrittenBytes() 
          Returns the total number of bytes which were written to this
session.

But for PDU encoding/decoding performance there is nothing, actualy.

I would like to add the following methods : 
   long getReadPDU();
   long getWrittenPDU(); 

I'm thinking about adding them in mina.filter.codec.ProtocolCodecFilter.

The total count of encoded PDU will be done in ProtocolCodecFilter, but
for the count of decoded PDU I'm thinking about the interface
ProtocolDecoderOutput (implemented in SimpleProtocolDecoderOutput).

WDYT ?

Julien


Re: PDU performance stats

Posted by peter royal <pr...@apache.org>.
On Jul 20, 2006, at 7:35 AM, Julien Vermillard wrote:
> - in ProtocolCodecFilter, you are supposed (as far as I know, never
> tried elseway) to have a ProtocolCodecFilter per session, and it make
> much more sense to me and it's here where we will count
> protocolDecoderOutput writes and calls to the
> ProtocolEncoder.encode(...).

No, rather the opposite.. a single ProtocolCodecFilter will be shared  
between multiple sessions. You could still keep track of the state in  
session attributes though.

-pete


-- 
proyal@apache.org - http://fotap.org/~osi




Re: PDU performance stats

Posted by Julien Vermillard <jv...@archean.fr>.
Le mardi 18 juillet 2006 à 09:57 +0200, Emmanuel Lecharny a écrit :
> Julien Vermillard a écrit :
> 
> >Le lundi 17 juillet 2006 à 11:01 -0400, Alex Karasulu a écrit :
> >  
> >
> >>Julien Vermillard wrote:
> >>    
> >>
> >>>Hi all,
> >>>
> >>>Actualy it's very easy to calculate bytes thoughput (read and write) by
> >>>looking in the IoSession objects and using the following methods :
> >>>
> >>> long getReadBytes() 
> >>>          Returns the total number of bytes which were read from this
> >>>session.
> >>>
> >>> long getWrittenBytes() 
> >>>          Returns the total number of bytes which were written to this
> >>>session.
> >>>
> >>>But for PDU encoding/decoding performance there is nothing, actualy.
> >>>
> >>>I would like to add the following methods : 
> >>>   long getReadPDU();
> >>>   long getWrittenPDU(); 
> >>>
> >>>I'm thinking about adding them in mina.filter.codec.ProtocolCodecFilter.
> >>>
> >>>The total count of encoded PDU will be done in ProtocolCodecFilter, but
> >>>for the count of decoded PDU I'm thinking about the interface
> >>>ProtocolDecoderOutput (implemented in SimpleProtocolDecoderOutput).
> >>>      
> >>>
> >>Hmmm so mina can make use of the protocol codec to determine when it 
> >>should increment the PDU's read and written?
> >>
> >>Meaniing it can make the decoders and encoders tell it when the 
> >>demarcations between PDUs occurs?
> >>
> >>Alex
> >>
> >>    
> >>
> >
> >Decoders call "ProtocolDecoderOutput.write(Object pdu)" each time a PDU
> >is decoded so MINA can increment "PDU read count" each time this method
> >is called (for a session)
> >
> >encoders gets PDUs from ProtocolEncoder.encode(Object pdu) so MINA can
> >increment the "PDU write count" each time ProtocolDecoderFilter call
> >this method for a session.
> >
> >
> >  
> >
> Not sure this is easy to implement. Currently, we decode PDU "on the 
> fly", and it's done deep inside the Ldap decoder. This is the only place 
> where we "know" that a PDU has been completely decoded (because MINA 
> don't read the PDU length, it has no way to know if a PDU has been 
> totally read or not). When the PDU is decoded, we just call the callback 
> to handle the PDU.
> 
> Another tricky point - which is not handled currently -  is that we 
> would like to be able to write chunks of data, to avoid MINA to keep a 
> load of bytes.
> Fort instance, if we have a jpeg image to send, we will send it piece by 
> piece, so that we won't keep 1Mbyte in memory.
> 
> This makes it difficult for MINA to know when a PDU has been sent, 
> except if we extend MINA to add a PDUDecoded() method call to tell MINA 
> that a PDU has been fully decoded. Or something like that.
> 
> Emmanuel

Following this reflexion :

ProtocolCodecFilter need to store somewhere the amount of encoded and
decoded PDU per sessions, 3 ideas :
- in IoSession like "long getReadBytes()" and "long getWrittenBytes()"
but that won't make sense for ioSession without ProtocolCodecFilter 
- in IoSession attachements, but performance wise I don't think it's a
good idea to looks in attachement each time a PDU is encoded/decoded
- in ProtocolCodecFilter, you are supposed (as far as I know, never
tried elseway) to have a ProtocolCodecFilter per session, and it make
much more sense to me and it's here where we will count
protocolDecoderOutput writes and calls to the
ProtocolEncoder.encode(...).

I think the last idea is the good one, WDYT ? 

Well it won't make much sense the way ASN.1 codec is working, but you
can ignore the value and make your own PDU counting code if you need
no ?

Julien

Re: PDU performance stats

Posted by Julien Vermillard <jv...@archean.fr>.
Le mardi 18 juillet 2006 à 09:57 +0200, Emmanuel Lecharny a écrit :
> Julien Vermillard a écrit :
> 
> >Le lundi 17 juillet 2006 à 11:01 -0400, Alex Karasulu a écrit :
> >  
> >
> >>Julien Vermillard wrote:
> >>    
> >>
> >>>Hi all,
> >>>
> >>>Actualy it's very easy to calculate bytes thoughput (read and write) by
> >>>looking in the IoSession objects and using the following methods :
> >>>
> >>> long getReadBytes() 
> >>>          Returns the total number of bytes which were read from this
> >>>session.
> >>>
> >>> long getWrittenBytes() 
> >>>          Returns the total number of bytes which were written to this
> >>>session.
> >>>
> >>>But for PDU encoding/decoding performance there is nothing, actualy.
> >>>
> >>>I would like to add the following methods : 
> >>>   long getReadPDU();
> >>>   long getWrittenPDU(); 
> >>>
> >>>I'm thinking about adding them in mina.filter.codec.ProtocolCodecFilter.
> >>>
> >>>The total count of encoded PDU will be done in ProtocolCodecFilter, but
> >>>for the count of decoded PDU I'm thinking about the interface
> >>>ProtocolDecoderOutput (implemented in SimpleProtocolDecoderOutput).
> >>>      
> >>>
> >>Hmmm so mina can make use of the protocol codec to determine when it 
> >>should increment the PDU's read and written?
> >>
> >>Meaniing it can make the decoders and encoders tell it when the 
> >>demarcations between PDUs occurs?
> >>
> >>Alex
> >>
> >>    
> >>
> >
> >Decoders call "ProtocolDecoderOutput.write(Object pdu)" each time a PDU
> >is decoded so MINA can increment "PDU read count" each time this method
> >is called (for a session)
> >
> >encoders gets PDUs from ProtocolEncoder.encode(Object pdu) so MINA can
> >increment the "PDU write count" each time ProtocolDecoderFilter call
> >this method for a session.
> >
> >
> >  
> >
> Not sure this is easy to implement. Currently, we decode PDU "on the 
> fly", and it's done deep inside the Ldap decoder. This is the only place 
> where we "know" that a PDU has been completely decoded (because MINA 
> don't read the PDU length, it has no way to know if a PDU has been 
> totally read or not). When the PDU is decoded, we just call the callback 
> to handle the PDU.
> 
> Another tricky point - which is not handled currently -  is that we 
> would like to be able to write chunks of data, to avoid MINA to keep a 
> load of bytes.
> Fort instance, if we have a jpeg image to send, we will send it piece by 
> piece, so that we won't keep 1Mbyte in memory.
> 
> This makes it difficult for MINA to know when a PDU has been sent, 
> except if we extend MINA to add a PDUDecoded() method call to tell MINA 
> that a PDU has been fully decoded. Or something like that.
> 
> Emmanuel

As we chatted on IRC, the ASN.1 codec is special and in this case MINA
can't count PDU.

Re: PDU performance stats

Posted by Emmanuel Lecharny <el...@gmail.com>.
Julien Vermillard a écrit :

>Le lundi 17 juillet 2006 à 11:01 -0400, Alex Karasulu a écrit :
>  
>
>>Julien Vermillard wrote:
>>    
>>
>>>Hi all,
>>>
>>>Actualy it's very easy to calculate bytes thoughput (read and write) by
>>>looking in the IoSession objects and using the following methods :
>>>
>>> long getReadBytes() 
>>>          Returns the total number of bytes which were read from this
>>>session.
>>>
>>> long getWrittenBytes() 
>>>          Returns the total number of bytes which were written to this
>>>session.
>>>
>>>But for PDU encoding/decoding performance there is nothing, actualy.
>>>
>>>I would like to add the following methods : 
>>>   long getReadPDU();
>>>   long getWrittenPDU(); 
>>>
>>>I'm thinking about adding them in mina.filter.codec.ProtocolCodecFilter.
>>>
>>>The total count of encoded PDU will be done in ProtocolCodecFilter, but
>>>for the count of decoded PDU I'm thinking about the interface
>>>ProtocolDecoderOutput (implemented in SimpleProtocolDecoderOutput).
>>>      
>>>
>>Hmmm so mina can make use of the protocol codec to determine when it 
>>should increment the PDU's read and written?
>>
>>Meaniing it can make the decoders and encoders tell it when the 
>>demarcations between PDUs occurs?
>>
>>Alex
>>
>>    
>>
>
>Decoders call "ProtocolDecoderOutput.write(Object pdu)" each time a PDU
>is decoded so MINA can increment "PDU read count" each time this method
>is called (for a session)
>
>encoders gets PDUs from ProtocolEncoder.encode(Object pdu) so MINA can
>increment the "PDU write count" each time ProtocolDecoderFilter call
>this method for a session.
>
>
>  
>
Not sure this is easy to implement. Currently, we decode PDU "on the 
fly", and it's done deep inside the Ldap decoder. This is the only place 
where we "know" that a PDU has been completely decoded (because MINA 
don't read the PDU length, it has no way to know if a PDU has been 
totally read or not). When the PDU is decoded, we just call the callback 
to handle the PDU.

Another tricky point - which is not handled currently -  is that we 
would like to be able to write chunks of data, to avoid MINA to keep a 
load of bytes.
Fort instance, if we have a jpeg image to send, we will send it piece by 
piece, so that we won't keep 1Mbyte in memory.

This makes it difficult for MINA to know when a PDU has been sent, 
except if we extend MINA to add a PDUDecoded() method call to tell MINA 
that a PDU has been fully decoded. Or something like that.

Emmanuel

Re: PDU performance stats

Posted by Julien Vermillard <jv...@archean.fr>.
Le lundi 17 juillet 2006 à 11:01 -0400, Alex Karasulu a écrit :
> Julien Vermillard wrote:
> > Hi all,
> > 
> > Actualy it's very easy to calculate bytes thoughput (read and write) by
> > looking in the IoSession objects and using the following methods :
> > 
> >  long getReadBytes() 
> >           Returns the total number of bytes which were read from this
> > session.
> > 
> >  long getWrittenBytes() 
> >           Returns the total number of bytes which were written to this
> > session.
> > 
> > But for PDU encoding/decoding performance there is nothing, actualy.
> > 
> > I would like to add the following methods : 
> >    long getReadPDU();
> >    long getWrittenPDU(); 
> > 
> > I'm thinking about adding them in mina.filter.codec.ProtocolCodecFilter.
> > 
> > The total count of encoded PDU will be done in ProtocolCodecFilter, but
> > for the count of decoded PDU I'm thinking about the interface
> > ProtocolDecoderOutput (implemented in SimpleProtocolDecoderOutput).
> 
> Hmmm so mina can make use of the protocol codec to determine when it 
> should increment the PDU's read and written?
> 
> Meaniing it can make the decoders and encoders tell it when the 
> demarcations between PDUs occurs?
> 
> Alex
> 

Decoders call "ProtocolDecoderOutput.write(Object pdu)" each time a PDU
is decoded so MINA can increment "PDU read count" each time this method
is called (for a session)

encoders gets PDUs from ProtocolEncoder.encode(Object pdu) so MINA can
increment the "PDU write count" each time ProtocolDecoderFilter call
this method for a session.



Re: PDU performance stats

Posted by Alex Karasulu <ao...@bellsouth.net>.
Julien Vermillard wrote:
> Hi all,
> 
> Actualy it's very easy to calculate bytes thoughput (read and write) by
> looking in the IoSession objects and using the following methods :
> 
>  long getReadBytes() 
>           Returns the total number of bytes which were read from this
> session.
> 
>  long getWrittenBytes() 
>           Returns the total number of bytes which were written to this
> session.
> 
> But for PDU encoding/decoding performance there is nothing, actualy.
> 
> I would like to add the following methods : 
>    long getReadPDU();
>    long getWrittenPDU(); 
> 
> I'm thinking about adding them in mina.filter.codec.ProtocolCodecFilter.
> 
> The total count of encoded PDU will be done in ProtocolCodecFilter, but
> for the count of decoded PDU I'm thinking about the interface
> ProtocolDecoderOutput (implemented in SimpleProtocolDecoderOutput).

Hmmm so mina can make use of the protocol codec to determine when it 
should increment the PDU's read and written?

Meaniing it can make the decoders and encoders tell it when the 
demarcations between PDUs occurs?

Alex