I make a benchmark comparing C++ vs Java networking performance, having a single client which sends packets contionously to the server. The C++ and Java servers behaves the same, however the C++ client has much better (*2.5) throughput than Java. I tried to improve the Java (unsuccessfully!) by the following: - use combinations of socket options - set client thread priority higher - use vm flags: -client, -Xnoclassgc (no GC !!!) - set net. card configuration I noticed that while C++ uses 50% of the bandwidth, Java uses only 20% - and the graph is very stable! What else can I do to improve Java? Thanks in Advance!
- Posted by: Amir Yiron
- Posted on: January 05 2010 07:58 EST
I forgot to mention...
Dear Amir, I would run your Java client in a profiler and see where it spends most of its time. Then optimize that. GC is not likely to be a problem for simple applications. In fact, you did yourself a disservice by using the -client flag. Use -server (always use -server) I did some benchmarking http://java-monitor.com/forum/showthread.php?t=552 -Xnoclassgc does not disable the GC, so don't bother. You cannot disable the GC. Kees Jan
Profiling my client shows a very strange results: after 7 min the following values grow twice: heap size, heap used, loaded classes. After 7 more min. heap size/used decreases, but still remain larger than in the beginning. After more 15 min, the network bandwidth grows from 20% to 55%, and sending rate grows from 17 Mbps to 54 Mbps !!!! ANY EXPLANATIONS ???