Java Urban Performance Legends

There's a great thread on Slashdot titled Java Urban Performance Legends. It's mostly thrashing out urban performance legends in garbage collection, but you can find them all over the place. Modern Java VMs really are quite fast, often beating C and C++ in all sorts of benchmarks. Another common urban performance legend is that "Java must be slow because there's no way to turn off subscript checking": this one is completely false because all modern JVMs have optimizers that do a great job of eliminating subscript checking.

There was a funny incident at a recent developer event where some folks had a booth where they where demo-ing a high end industrial strength C compiler and had a benchmark that they had transliterated into Java. They were comparing their compiler to GCC and Java. GCC was running at about 2/3 the performance of this high end compiler; the Java version was running at about 2/3 the performance of the GCC version. Folks were gathered around the booth and someone noticed that the script they were using to run the Java version didn't have optimisation turned on. A few seconds with vi to add the "-server" switch and Java's performance jumped up to match the fancy C compiler. This got the pro-GCC crowd all excited, so a bunch of them started fiddling with its command line switches. They got a bit of improvement, but not much (the original selection had been pretty good).

The one place where Java does have a legitimate remaining performance issue is startup time. But these days it's down small enough to where anything that runs more than a few seconds has a hard time noticing it. Most startup time in modern Java apps goes to the app itself, not the VM.

October 9, 2005