mina-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Andrew Trieger <atrie...@trieger.org>
Subject unexplained pause after about 32k sent back
Date Mon, 07 Apr 2008 02:39:05 GMT
I have a client/server system, one mina app is the client, one the  
I'm using my own decoders and encoders to send byte arrays over the  
wire instead of using serialization.
Its almost exactly like the example of the image server:

I have the server hardcoded to send back a byte array of a known  
size, the same one, over and over, its 68 bytes.
The client makes a Request object, its encoder writes out to the  
wire, the decoder on the server side decodes that, services it in a  
handler, makes a Response object, which is then encoded for the wire,  
the client reads that in using its decoder and its done.

The problem is, after exactly 482 request/responses, each which occur  
in basically .2ms each on my local machine as expected, all of a  
sudden the client waits for nearly 180ms but without cpu being  
consumed very much, as if one or other sides are in sleeps.  482*68  
is almost exactly 32k.

If I shrink the # of bytes sent over, it runs fast more times, but  
always until the total # of bytes sent back adds up to 32k.

The request is a 1byte command and the response is the byte array of  
a string.

After a slow response, there are 3 more slow responses and then it  
works fast again... until the 32k mark is hit again, and then a few  
slow ones.  it continues like that  482 fast back and forths, then 3  
or 4 slow ones of about 200ms each, then 482 fast ones, etc.

Its all over the same socket.

I cant find in the mina code any 32k settings.

I thought perhaps it was related to a buffer being autoexpand or  
autoshrunk but I havent been able to research that theory.

The most perplexing thing is that the cpu during the slow ones is  
nearly idle, there's no disk activity, so its as if its network  
blocking.  When running the whole thing, it does not run full cpu  
like it should, it uses a an average of about 15% only.

One thing I am doing that I'm not sure is allowed is using TWO  
IoBuffers to write out to the stream during encoding, like this:

         IoBuffer sizeBuf = IoBuffer.allocate(4, false);

         IoBuffer dataBuf = IoBuffer.wrap(b);

this constitutes the entire response from the server. it writes 4  
bytes and then it writes the contents of a byte buffer b.
It works, I read 4 bytes on the client and then i read the byte[].

I don't think its java 1.6 specific or mac specific (on an intel mac,  
10.4.x, jdk 1.6) because I get the same behavior from a redhat linux  
box I tried this on, both still talking to each other through the  
localhost interface.

Does *anyone* have *any* ideas ??


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message