Issue Details (XML | Word | Printable)

Key: DIR-108
Type: Improvement Improvement
Status: Closed Closed
Resolution: Fixed
Priority: Minor Minor
Assignee: Unassigned
Reporter: Emmanuel Lecharny
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Directory

Server PDU are splitted in small chunks

Created: 08/Mar/05 05:36 AM   Updated: 31/Aug/05 03:18 PM
Component/s: None
Affects Version/s: None
Fix Version/s: None

Time Tracking:
Not Specified

File Attachments:
  Size
File Licensed for inclusion in ASF works mina.diff 2005-03-09 08:16 AM Emmanuel Lecharny 1 kB
Image Attachments:

1. Chunked.png
(46 kB)

2. Unchunked.png
(46 kB)

Resolution Date: 31/Aug/05 03:18 PM


 Description  « Hide
PDU that are created by ApacheDS server are sent back in small chunk. A lot of IP packets are necessary to reconstruct the LDAP message : typically, each TLV is sent as a TCP packet.



 All   Comments   Work Log   Change History   Subversion Commits      Sort Order: Ascending order - Click to sort in descending order
Repository Revision Date User Message
ASF #156494 Tue Mar 08 04:14:41 UTC 2005 trustin Added ProtocolEncoderOutput.mergeAll() to let users control how MINA generates network packets. This will help to resolve DIR-108.
Files Changed
MODIFY /incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/ProtocolEncoderOutput.java
MODIFY /incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java
MODIFY /incubator/directory/network/mina/trunk/src/java/org/apache/mina/util/Queue.java

Trustin Lee added a comment - 08/Mar/05 12:48 PM
This issue has been resolved in APSEDA, but MINA doesn't merge fragments of bytebuffers now. It would be nice if MINA can handle this. I can add ProtocolDecoderOutput.mergeAll() method to let ProtocolDecoders can merge fragmented ByteBuffers into a single ByteBuffer. I'll also have to modify MINA's Asn1Encoder.

But I'm afraid that Asn1Encoder would not be able to work against UDP because there is a possibility that one message can generate two or more packets and modified version will merge them into one packet. It would be the best if ASN1 codec modify its interface to provide a method that is directly mapped to ProtocolDecoderOutput.mergeAll().

WDYT, Alex?

Emmanuel Lecharny added a comment - 08/Mar/05 04:12 PM
I've checked the way those PDU are created, and I think that the best place to merge the chunks could be in the encoder. Actually, every Tuple generates a ByteBuffer and push it on a stack, which is sent by MINA. An encoder that merge all those little chunks could help to improve this behavior.

Of course, for very large PDU like Search results, we will have to deal with the memory footprint in the same way we should do it for the decoding process.

Alex Karasulu added a comment - 08/Mar/05 11:46 PM
I agree Trustin re: changes to encoder. This is something we should factor into a redesign making sure the encoder decoder line up with MINA for maximum performance gains.

Repository Revision Date User Message
ASF #156608 Wed Mar 09 04:19:46 UTC 2005 trustin Fixed: Asn1CodecEncoder doesn't merge when ASN1 codec generates a collection of ByteBuffers. (DIR-108)
Fixed: IoAdpater's default ProtocolEncoderOutput.mergeAll() doesn't check the number of the cumulated bytebuffers
Files Changed
MODIFY /incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/codec/Asn1CodecEncoder.java
MODIFY /incubator/directory/network/mina/trunk/src/java/org/apache/mina/protocol/io/IoAdapter.java

Emmanuel Lecharny added a comment - 09/Mar/05 08:16 AM
A workaround that merge the chunks. It seems to work, I still have to evaluate the performance impact of this modification.

I repeat : it's nothing else but a workaround. It's ugly...

+1 for a modification at the decoder level, but it will be a lot of work ...

Emmanuel Lecharny made changes - 09/Mar/05 08:16 AM
Field Original Value New Value
Attachment mina.diff [ 19174 ]
Alex Karasulu added a comment - 09/Mar/05 08:36 AM
Look why don't we just rewrite this thing top to bottom with this consideration in mind. Let's hand write the LDAP codec with all the optimizations making sure its as fast as lightning and fits into MINA like a hand in a glove.
 

David Boreham added a comment - 09/Mar/05 08:47 AM
I've written and re-written this code in
other products. Some random thoughts:

Encode the bits in-place. That is, where
you have an entry for a search result
in your hand, go call whatever code generates the BER, right there. Accumulate the BER bits in a buffer, do not attempt
to send immediately, unless the buffer overflows. Do not store some intermediate symbolic representation of the data : just make the BER. This is safe to do because you are always generating BER left to right,
and have no need to retrace your steps.

Flush the buffer (only) every time you send a
response PDU (search result done in the
case of a search). This ensures that you
coalesce a search entry PDU with the search result done PDU into one TCP segment.
Doing this can deliver a significant
performance benefit.

In some client/server scenarios you will
find it beneficial to disable nagle on the
TCP session.

Don't worry about UDP : nobody uses it.



Emmanuel Lecharny added a comment - 09/Mar/05 09:11 AM
I've done some tests based on the 0.9 Apache DS and the same version with the patch I've attached in a previous comment. Here are both screenshot of the same JMeter run : the un-chunked version has a 5 x times better througput than the original version (only one thread requestiong 1000 times the same thing...).

I agree with Alex and David. Rewritting the whole codec will certainly improve performance a lot. Let's do it, and do it now ! I think that the encoding part is the most important one as it's the one that send search results.

Emmanuel Lecharny made changes - 09/Mar/05 09:11 AM
Attachment Unchunked.png [ 19177 ]
Attachment Chunked.png [ 19176 ]
Trustin Lee added a comment - 09/Mar/05 10:31 AM
Hi,

I looked at the patch, and now I realized ApacheDS LDAP encoder generates arrays of ByteBuffers. If it is always like that, we would be able to set up a rule that an array of ByteBuffers are to be merged. So I think merging that patch seems to be OK at all. WDYT?

Trustin Lee added a comment - 09/Mar/05 01:23 PM
I fixed MINA Asn1Encoder using new mergeAll() method in ProtocolEncoderOutput.

Here's the change I've made:

http://svn.apache.org/viewcvs?view=rev&rev=156608

I think it is less efficient in performance than the patch, but it effectively removed duplication of code.

Emmanuel Lecharny added a comment - 31/Aug/05 03:18 PM
The mergeAll has been implemented by Trustin months ago ...

Emmanuel Lecharny made changes - 31/Aug/05 03:18 PM
Status Open [ 1 ] Closed [ 6 ]
Resolution Fixed [ 1 ]