Avoiding the Java Client VM

When Java applications perform poorly on Windows, Java developers blame Windows and Windows developers blame Java. But most likely, the actual cause is using the wrong virtual machine. Oracle ships two VMs for 32-bit platforms, called Client VM and Server VM, and Windows defaults to the slower one. My new article on Java Client VM Performance compares the two VMs, and shows how to use the faster one on 32-bit Windows.

This issue does not appear to be widely known, either among Windows users or among Java developers, probably because Java is little used today on 32-bit Windows systems. I got my first hint when I noticed that some small Java benchmark I’d written would run much faster on the 64-bit JRE for Windows than on the 32-bit JRE. At first I blamed the bitness difference itself, but then I realized that the 64-bit JRE was running a different VM version which was also present in the 32-bit JDK: the Server VM.

Switching the 32-bit test from Client to Server VM captured nearly the entire speedup from the 64-bit test, approximately a factor of two. That was already quite remarkable but then I discovered something else: the public 32-bit JRE on Windows – and only on Windows – does not include the superior Server VM! You have to either use the 64-bit JRE, or else copy the Server VM over from the 32-bit JDK’s private JRE.

And then I found a preview of an academic paper that compared Scala (running on the Oracle JVM) and F# performance on several systems, including 32-bit Windows XP. Sure enough, the results for Scala on 32-bit Windows were mysteriously inferior to Scala on 64-bit Linux – by the same factor of two I now had repeatedly observed. When I contacted the authors, they agreed that they must have unwittingly run the Windows test on the Client VM. The poor people had already written a page of baseless speculation concerning Windows XP’s memory subsystem in an attempt to explain their strange results…

So I decided that this issue was probably important enough that somebody should write something about it. The Java Client VM Performance page contains a detailed explanation of the situation, some benchmarks to show just how inferior the Client VM is, and advice on how to bundle the Server VM with the 32-bit JRE for Windows.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.