Monday, August 08, 2005

Java on Solaris and Windows II

I really need to get to the bottom of the Benchmark in my previous post, so I have been doing a little more experimentation. As Anthony Vito pointed out, JDK1.5 optimizes the empty loops (and the simple calcs) out, so to test basic operations I need a little more work going one. I also checked the performance with the "-server" settings in JDK 1.4.2 and found almost the same optimization as JDK 1.5 (is -server the default now? can't find this). Reading the HotSpot VM FAQ verifies I should be using -server (doh! should have remembered this) for performance.

So my new test incorporates a more complex basic operation (find the 20000th prime number), a more complex FP operation (calculate PI to 7 decimal places), a large array test and CRC calculation. Although these are not exactly the operations my real application will be doing, they are some of the areas I need to test performance.

The tests are now:
  1. Finding the 20000th Prime Number (I haven't tried to be clever here, its doesn't use any of the advanced math algorithms)
  2. Calculating pi to 7 places (not too clever here either, but it works)
  3. Writing a 50MB file
  4. Reading the 50MB file using
  5. Reading the 50MB file using ByteBuffer
  6. Creating 50 million item random byte array
  7. Perform 64 bit CRC on the array ten times
Note, the addition of the 50M array means you need to use (at least) -Xmx128m -Xms128m in the command line. I ran this on the same Windows Laptop and Solaris Server as the previous tests in both "-client" and "-server" mode.

Windows - Server Windows - Client Solaris - Server Solaris - Client
20000th Prime 4201 12053 8722 24688
PI 7 Dec Places 2931 4901 2936 4217
Write 50MB File 6561 5882 1137 1899
FIS.Read 50MB File 1661 1852 6535 7026
Buffer.Read 50MB 480 490 1338 1425
50M Byte Array 4621 7602 12970 23306
10x50M 64b CRC 5111 8872 6969 24244

In "-server" mode the floating point test is almost identical, but basic ops (prime test) still differs by a factor of two. The memory (large array) operation is also slower on Solaris.

I'm still looking for feedback on this. Most important to me is how to speed up the basic operations (CPU intensive stuff) and improve file reading on Solaris. What I really need to test next is a C program that does the same. I want to determine if the problem is with the operating system, or the Java layer. Of course it could be with the chipset, as Anthony pointed out, but other than buy a Solaris on Intel system, I'm not sure how I can verify that (unless someone out there has one and doesn't mind running the test). I really want to use Java for this, but if C proves to perform many times better, I may be forced to reconsider.

You can download the new BenchMark java file from here.

Technorati Tags: , , , , ,


Post a Comment

<< Home