tags:

views:

88

answers:

2

Hi,

I have an application which was ported from Windows to Linux. Now the same code compiles on VS C++ and g++, but there is a difference in performance when it's running on Win and when it's running on Linux. The scope of this application is caching. It's a node between a server and a client, and it's caching client requests and server response in a list, so that any other client which makes requests that was already processed by the server, this node will response instead of forwarding it to server.

When this node runs on Windows, the client gets all it needs in about 7 seconds. But when same node is running on Linux (Ubuntu 9.04), the client starts up in 35 seconds. Every test is from scratch. I'm trying to understand why is this timing difference. A weird scenario is when the node is running on Linux but in a Virtual Machine, hosted by Win. In this case, load time is around 7 seconds, just like it was running Win natively. So, my impression is that there is a problem with networking.

This node is using UDP protocol for sending and receiving network data, and it's using boost::asio as implementation. I tried to change all supported socket flags, changed buffer size, but nothing.

Does someone know why is this happening, or any network settings related with UDP that might influence the performance?

Thanks.

A: 

These timing differences can depend on many factors, but the first one coming to mind is that you are using a modern Windows version. XP already had features to keep recently used applications in memory, but in Vista this was much better optimized. For each application you load, a special load file is created that is equal to how it looks in memory. Next time you load your application, it should go a lot faster.

I don't know about Linux, but it is very well possible that it needs to load your app completely each time. You can test the difference in performance between the two systems much better if you compare performance when running. Leave your application open (if it is possible with your design) and compare again.

These differences in how the system optimizes memory are backed up by your scenario using the VM approach.

Basically, if you rule out other running applications and if you run your application in high priority mode, the performance should be close to equal, but it depends on whether you use operating system specific code, how you access the file system, how you you use the UDP protocol etc etc.

Abel
Maybe I was a little bit confusing. When I say loading time, I'm refering to the time while OS is loading the binary into the memory. All processes are started, and I just hit "the start button".More exactly, the time between first request is send until the last reply was received. They are about 8000 requests...The client always runs on same machine with Win, only the node is moved on Linux or Windows...Thanks.
Pret
Unless there's contention for memory, the application should be cached in memory on linux as well.
Kjetil Jorgensen
so you time from the moment you hit the start button. Then deeper analysis is needed, esp. on how both systems allow concurrent or consecutive UDP requests. Wireshark (as suggested by another answer) is probably your friend. Be prepared to spend a lot of time finding this culprit. Also compare exact performance with fewer requests and compare performance if between each request is 10 seconds or so (count the times of the UDP requests, not the wait time).
Abel
+1  A: 

If you suspect a network problem take a network capture (Wireshark is great for this kind of problem) and look at the traffic.

Find out where the time is being spent, either based on the network capture or based on the output of a profiler. Once you know that you're half way to a solution.

Kristof Provost