This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Murach's Python Programming and have Michael Urban and Joel Murach on-line!
See this thread for details.
Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Measuring the performance of Networking code  RSS feed

 
Dayo Manas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To take a simple example, how exactly am I supposed to know if read(buf,i,len) is more efficient than read() ? or how do I know the performance difference between setting sendBufferSize 8k and 32k? etc

1)
I am aware of Java profilers ( http://java-source.net/open-source/profilers), but most of them measure stuff like CPU, memory, heap, etc - I cant seem to find any profiler that measures Networking code. I've looked at one called JAMon, but have no idea how to use it for my purpose. Should I be looking at OS/System level tools? If so, which ones?

2)
For my purpose I am mainly interested in latency. I am writing a SOCKS server which is currently encapsulating multiplayer game data. Currently I pay an apprx 100 latency overhead - I dont understand why.. considering both the SOCKS client (my game) and SOCKS server are localhost. And I dont think merely reading a few bytes of SOCKS header information can potentially cause such an overhead.

3)
Let's say I make certain changes to my networking code which results in a slightly faster HTTP download - however can I assume that this will also mean lower latency while gaming? Game traffic is extremely sporadic, unlike a HTTP download which is a continuous stream of bytes.

I dont want to make the cardinal sin of blindly optimizing because "people say so". I want to measure the performance and see it with my own eyes.

Appreciate the assistance.
 
rajesh bala
Ranch Hand
Posts: 66
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Generally java profilers are not great tools for network monitoring or profiling.

It would be helpful if you could post which OS are you using, JVM version and so on.

If I am in your situation, I would do the following.

1. Figure out how much of data transfer is happening using opensource traffic analyzers.
2. Find out whether OS is handling the packets properly. Generally programmers write code thinking that JVM would internally handle it at best. However, JVM intern would contact OS for sending and receiving.
3. So I would check if the MTU (Message transfer unit) is set properly in OS, proper tcp tuning in OS and try disabling nagle's algorithm.



~Rajesh.B
 
Dayo Manas
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am on Windows with JDK6.

1. Figure out how much of data transfer is happening using opensource traffic analyzers.

I am using Ethereal, but am not sure what is the significance of measuring the data transfered - I am looking for latency, not bandwith consumption.

2. Find out whether OS is handling the packets properly. Generally programmers write code thinking that JVM would internally handle it at best. However, JVM intern would contact OS for sending and receiving.

Yes, I am aware that the packets are handled by the OS. The question, is there any way to "ask" the OS to give me latency details? Something tells me that there is some linux utility that could probably do the trick.


3. So I would check if the MTU (Message transfer unit) is set properly in OS, proper tcp tuning in OS and try disabling nagle's algorithm.

MTU is fine. TcpNoDelay is irrelevant for my purpose at the moment. I think you may have slightly misunderstood me; I am not trying to improve my latency, I am trying to measure it.


~Rajesh.B[/QB]
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is what I would do if this was my problem:

1. Network monitoring - you say
I am looking for latency, not bandwith consumption.

but the rate of packet collision is a critical part of latency, isn't it? For comparison testing of methods you would want to be sure network conditions are the same.

2. I would do the obvious timestamp monitoring using the System.currentTimeMillis() at various places - rather than just averaging I would collect a histogram of the measured delays. Be sure to catch the extreme delays too. When I did this with my online exams I found a remarkable spread. Any sort of premature averaging is going to conceal interesting data.

Bill
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!