[Spread-users] Java API Performance

John Schultz jschultz at spreadconcepts.com
Wed Apr 23 14:36:17 EDT 2008


Sounds like a good idea to include in the code to me.

---
John Schultz
Spread Concepts
Phn: 443 838 2200

On Wed, 23 Apr 2008, Mike Perik wrote:

> Found something, I set TcpNoDelay to 'true' on the socket in the SpreadConnection class and my times dropped to ~1ms
>
> Any thoughts on this?
>
> Thanks,
> Mike
>
>
> --- On Wed, 4/23/08, Mike Perik <michaelperik at yahoo.com> wrote:
>
>> From: Mike Perik <michaelperik at yahoo.com>
>> Subject: Re: [Spread-users] Java API Performance
>> To: spread-users at lists.spread.org
>> Date: Wednesday, April 23, 2008, 9:48 AM
>> Anyone have any idea where this latency is coming from? It
>> makes the use of the Java API useless.
>>
>> Is there anything I can do to see when the Spread daemon
>> gets the message?  I've added milliseconds to the
>> logging done by the daemon but I'm finding it difficult
>> to track the receipt and sending of the application
>> messages.
>>
>> Has anyone done a JNI version of the C API?
>>
>> Thanks,
>> Mike
>>
>>
>> --- On Mon, 4/21/08, Mike Perik
>> <michaelperik at yahoo.com> wrote:
>>
>>> From: Mike Perik <michaelperik at yahoo.com>
>>> Subject: Re: [Spread-users] Java API Performance
>>> To: spread-users at lists.spread.org
>>> Date: Monday, April 21, 2008, 3:52 PM
>>> I run a second instance of the process that only
>> receives
>>> and it has the same latency issue.  The sender
>> doesn't
>>> have to listen but I am doing it to check the latency
>> there
>>> as well.
>>>
>>> I've removed the sender doing a receive and the
>> latency
>>> dropped to approx 1 ms.
>>>
>>> Why would the latency increase when I attempt to
>> receive?
>>> If I don't do a receive (I also don't join the
>>> group the message is sent to) and just blast the
>> messages
>>> out the latency is high also.   If I sleep or 1 ms
>> after
>>> doing the send the latency drops down to ~1 ms again.
>>>
>>> I also did a test where I sent the first 2500 messages
>>> without joining the "LATENCY" group and the
>> times
>>> were ~1 ms.  On the 2500th message I had the sender
>> joining
>>> the "LATENCY" group and the latency number
>> jumped
>>> from between 2ms - 41 ms. Seems to increment by 2 ms
>> per
>>> order.
>>>
>>> Recver Latency: 2
>>> Recver Latency: 41
>>> Recver Latency: 39
>>> Recver Latency: 37
>>> Recver Latency: 35
>>> Recver Latency: 33
>>> Recver Latency: 31
>>> Recver Latency: 29
>>> Recver Latency: 27
>>> Recver Latency: 25
>>> Recver Latency: 23
>>> Recver Latency: 21
>>> Recver Latency: 19
>>> Recver Latency: 17
>>> Recver Latency: 16
>>> Recver Latency: 14
>>> Recver Latency: 12
>>> Recver Latency: 10
>>> Recver Latency: 8
>>> Recver Latency: 6
>>> Recver Latency: 4
>>> Recver Latency: 2
>>> Recver Latency: 41
>>> Recver Latency: 39
>>> Recver Latency: 37
>>> Recver Latency: 35
>>> Recver Latency: 33
>>> Recver Latency: 31
>>> Recver Latency: 29
>>> Recver Latency: 27
>>> Recver Latency: 25
>>> Recver Latency: 24
>>> Recver Latency: 22
>>> Recver Latency: 20
>>> Recver Latency: 18
>>> Recver Latency: 16
>>> Recver Latency: 14
>>> Recver Latency: 12
>>> Recver Latency: 10
>>> Recver Latency: 8
>>> Recver Latency: 6
>>> Recver Latency: 4
>>> Recver Latency: 2
>>> Recver Latency: 41
>>> Recver Latency: 39
>>> Recver Latency: 37
>>>
>>> Any ideas on how I can be a subscriber and a publisher
>> on
>>> the same group without incurring this huge time
>> penalty?
>>>
>>> Am I doing something wrong here?
>>>
>>> Mike
>>>
>>>
>>> --- On Mon, 4/21/08, John Keating
>>> <jkeating at ca.afilias.info> wrote:
>>>
>>>> From: John Keating
>> <jkeating at ca.afilias.info>
>>>> Subject: Re: [Spread-users] Java API Performance
>>>> To: michaelperik at yahoo.com
>>>> Cc: spread-users at lists.spread.org
>>>> Date: Monday, April 21, 2008, 2:51 PM
>>>> When you're the sender, you're also
>> calling
>>>> receiveMessage()...should you?
>>>>
>>>> Mike Perik wrote:
>>>>> Has anyone done any basic performance tests
>> with
>>> the
>>>> Java API?
>>>>> I'm seeing what I would consider lengthy
>>> sending
>>>> times.
>>>>>
>>>>> My test involves a process sending 5000
>> messages.
>>>  The
>>>> message is the current time with the granularity
>> to
>>>> milliseconds.  The sending process sends a
>> message and
>>> then
>>>> receives the message.  When it receives the
>> message is
>>> takes
>>>> time it received it and subtracts the sending
>> time.
>>> I'm
>>>> seeing a round trip time of 39-41 milliseconds.
>> I did
>>> the
>>>> same test in C and the round trip time is more
>> like 1
>>> ms.
>>>>>
>>>>> Maybe I'm doing something incorrectly,
>> if so
>>>> I'm not sure what it is and would be
>> interested in
>>> any
>>>> help you can give me.
>>>>>
>>>>> Below is the code I'm using.
>>>>>
>>>>> Thank you for your help,
>>>>> Mike
>>>>>
>>>>>
>>>>> import spread.*;
>>>>> import java.net.*;
>>>>>
>>>>> public class spreadlatency
>>>>> {
>>>>>     SpreadConnection _sc;
>>>>>     boolean _sender = false;
>>>>>     MessageFactory _mf;
>>>>>     static public void main(String args[])
>> throws
>>>> Exception
>>>>>     {
>>>>>         SpreadConnection sc = new
>>> SpreadConnection();
>>>>>         spreadlatency sl = new
>> spreadlatency(sc,
>>>> args.length == 0 ? true : false);
>>>>>
>> sc.connect(InetAddress.getLocalHost(),
>>> 4803,
>>>> null, false, false);
>>>>>         sl.run();
>>>>>     }
>>>>>
>>>>>     public spreadlatency(SpreadConnection
>> sc,
>>> boolean
>>>> sender) throws Exception
>>>>>     {
>>>>>         _sc = sc;
>>>>>         _sender = sender;
>>>>>     }
>>>>>
>>>>>     public void run()
>>>>>     {
>>>>>         SpreadGroup sg = new SpreadGroup();
>>>>>         try {
>>>>>             sg.join(_sc,
>> "LATENCY");
>>>>>         }
>>>>>         catch (Exception ex)
>>>>>         {
>>>>>             ex.printStackTrace();
>>>>>         }
>>>>>         if (_sender == true)
>>>>>         {
>>>>>             SpreadMessage sm = new
>>> SpreadMessage();
>>>>>             short y = 1000;
>>>>>             sm.setType(y);
>>>>>
>> sm.addGroup("LATENCY");
>>>>>             int x = 0;
>>>>>             while (x++ < 5000)
>>>>>             {
>>>>>                 //                String st
>> =
>>>> "";
>>>>>                 long t =
>>> System.currentTimeMillis();
>>>>>                 //                st += t;
>>>>>                 //
>>>> sm.setData(st.getBytes());
>>>>>                 try {
>>>>>                     sm.setObject(new
>> Long(t));
>>>>>                     _sc.multicast(sm);
>>>>>                     receiveMessage();
>>>>>                 }
>>>>>                 catch (Exception ex)
>>>>>                 {
>>>>>                     ex.printStackTrace();
>>>>>                 }
>>>>>
>>>>>             }
>>>>>         }
>>>>>         else
>>>>>         {
>>>>>             int x = 0;
>>>>>             while (x++ < 5000)
>>>>>             {
>>>>>                 receiveMessage();
>>>>>             }
>>>>>         }
>>>>>     }
>>>>>
>>>>>     void receiveMessage()
>>>>>     {
>>>>>         try {
>>>>>             SpreadMessage sm =
>> _sc.receive();
>>>>>             short type = sm.getType();
>>>>>             if (type == 1000)
>>>>>             {
>>>>>                 //                String s =
>> new
>>>> String(sm.getData());
>>>>>                 //                Long l =
>>>> Long.valueOf(s);
>>>>>                 Long l =
>> (Long)sm.getObject();
>>>>>                 if (_sender == true)
>>>>>                 {
>>>>>
>>> System.out.println("Sender
>>>> Latency: " + (System.currentTimeMillis() -
>>>> l.longValue()));
>>>>>                 }
>>>>>                 else
>>>>>                 {
>>>>>
>>> System.out.println("Recver
>>>> Latency: " + (System.currentTimeMillis() -
>>>> l.longValue()));
>>>>>                 }
>>>>>             }
>>>>>         }
>>>>>         catch (Exception ex)
>>>>>         {
>>>>>             ex.printStackTrace();
>>>>>         }
>>>>>     }
>>>>> }
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>>
>>>>
>>>
>> ____________________________________________________________________________________
>>>>> Be a better friend, newshound, and
>>>>> know-it-all with Yahoo! Mobile.  Try it now.
>>
>>>>
>>>
>> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>>>>>
>>>>>
>> _______________________________________________
>>>>> Spread-users mailing list
>>>>> Spread-users at lists.spread.org
>>>>>
>>> http://lists.spread.org/mailman/listinfo/spread-users
>>>>>
>>>
>>>
>>>
>>>
>> ____________________________________________________________________________________
>>> Be a better friend, newshound, and
>>> know-it-all with Yahoo! Mobile.  Try it now.
>>>
>> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>>>
>>> _______________________________________________
>>> Spread-users mailing list
>>> Spread-users at lists.spread.org
>>> http://lists.spread.org/mailman/listinfo/spread-users
>>
>>
>>
>> ____________________________________________________________________________________
>> Be a better friend, newshound, and
>> know-it-all with Yahoo! Mobile.  Try it now.
>> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>>
>> _______________________________________________
>> Spread-users mailing list
>> Spread-users at lists.spread.org
>> http://lists.spread.org/mailman/listinfo/spread-users
>
>
>      ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile.  Try it now.  http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> _______________________________________________
> Spread-users mailing list
> Spread-users at lists.spread.org
> http://lists.spread.org/mailman/listinfo/spread-users
>




More information about the Spread-users mailing list