Sun boosts Java performance

Project Speedway employs JIT compiler, JVM with multithreading to enhance Java in Solaris 2.6

San Francisco (July 1, 1997) -- Beta testers of Solaris 2.6 are pretty much unanimous on one thing: Java runs a whole lot better on the new OS than it did in previous incarnations. Sun says that this improved performance is the result of a number of in-house initiatives aimed at making Java on Solaris as fast as C on Intel.

According to SunSoft, there are two reasons why Java now runs faster on Solaris. First, Solaris 2.6 comes with a just-in-time (JIT) compiler, which compiles Java bytecode into native code dynamically. Virtual machines without JIT compilers interpret rather than compile bytecode. A JIT compiler, says Sun, usually (but not always) makes things faster.

The second and more interesting change to the Solaris Java virtual machine is that it is now written as a multithreaded program. This means, according to Sun's Joe Keller, that you can now take advantage of multithreading with your own Java applications in much the same way that C applications take advantage of standard multithreading calls to Solaris. With the new Solaris Java virtual machine (JVM) threaded calls are "mapped directly to the Solaris thread create [thr_create]," he says, "so that is now a thread going in the Solaris space."

Keller, who is director of marketing for SunSoft developer products, says that previous implementations of the JVM "built a threads package in the virtual machine -- but it wasn't connected to the operating system's version of the VM." On Solaris this threads package is called "green threads."

In fact, a native threads version of SunSoft's JVM has been available for a few months for download with the just-in-time compiler, but users reported that it would often cause segment violation crashes with Solaris 2.5.1. One SunWorld reader called the Solaris JDK (Java Developers Kit) "sooo buggy my brain hurts."

Users report that many of the problems have been eliminated in Solaris 2.6. "We can't have Solaris 2.6 come out fast enough for our customers," says John Neffenger, whose software company, Volano LLC, makes server-side Java software. "The beauty of Solaris 2.6 is that we'll get a good, stable, and fast Java virtual machine that supports native threads and has a JIT compiler right in the operating system. Neffenger says he has been running his company's Java-based VolanoChat server using native threads on Solaris 2.6 without any of the familiar 2.5.1 problems.

According to a SunSoft spokesperson, "There are no stability concerns with either native or green threads -- both are rock solid and run fast." However, he admitted that Sun was keeping green threads alive for pre-Solaris 2.6 users, saying "we will be removing the green threads option as more and more of our customers move to Web-enhanced Solaris [Sun parlance for Solaris 2.6 and above]."

The native threads option is good news for Bob Hagmann, a senior scientist with Mountain View, CA's Vitria Technology. Green threads, he says, "are really fake threads. You can't really use them on a multiprocessor effectively." Hagmann continues, "If you have a multiprocessor, then you can get all the processors working on your process concurrently."

Still, Microsoft's NT virtual machine has always had native thread support, and it's been an embarrassment to Sun that the company that created Java has been behind Microsoft with both performance numbers and native thread support. Last week, Sun released CaffeineMark 2.5 numbers showing Solaris trouncing Microsoft NT (9,029 to 5,661 on a 200-MHz Pentium Pro). Microsoft pointed out that Sun's numbers were generated with the not-yet-available Solaris 2.6 operating system and responded this week by providing SunWorld with CaffeineMark 2.5 numbers for its own not-yet-available Internet Explorer 4.0 virtual machine on a 266-MHz Pentium Pro. It scored 156,785, according to Microsoft.

At least we're all comparing apples to oranges.

Volano's president, Mark Elderkin, says his company has been benchmarking the latest generation of both NT and Solaris virtual machines on Volano's own multithreaded Java application. He thinks that "once Microsoft works out some of their stability problems, [the JVM for SDK 2.0] has the potential to be the fastest Java virtual machine for our application. The preliminary tests that we have conducted show that it is extremely fast, but it does not have the stability of Sun's Java virtual machine." Elderkin hastens to point out that Microsoft's virtual machine, while less stable, is not yet a released product.

The issue for Sun is not really whose virtual machine is fastest. For Java to be successful, all virtual machines must be fast. According to Ron Rappaport, an analyst with Zona Research, the issue is whether or not Java is fast enough for the enterprise. "The industry is not one hundred percent comfortable with the level of Java performance today," he says. Improving Java's performance is "a very, very necessary part of their strategy at this point, and they seem to be taking the necessary steps to achieve that end."

Project Speedway and Hot Spot One of those steps is Project Speedway. Project Speedway is actually a series of projects SunSoft has launched to speed up its own implementations of the Java virtual machine on products like Solaris and Java WorkShop. Sun's Keller says that the development of the JIT and native thread support for the Solaris virtual machine are both part of the project, as is Sun's JIT Validation Test Suite.

Speedway is expected to some day deliver a "lightning-fast" version of the "javac" Java compiler, capable of compiling one million lines of code per minute as well as server-side Java compilers that compile bytecode to machine code, not unlike Asymetrix's SuperCede software.

Keller says that his group will also develop implementations of the next-generation virtual machine, code-named Hot Spot, currently under development at JavaSoft. This next-generation compiler uses system information gathered at runtime to improve performance of the Java virtual machine.

"When you compile a program with C, you compile it and then, days later, it gets executed," explains JavaSoft VP (and Java inventor) James Gosling. But you cannot know things like exactly what chip you are compiling for or what the data-type looks like, or even user habits like "how often this guy turns left versus turns right." But Hot Spot will. And Gosling hopes that this dynamic optimization will let Java run even faster than C code in some cases.

Project Speedway, too, will take advantage of the dynamic optimization capabilities of Java. Keller says the SunSoft JIT can already do things like skip programming loops that do no work. He adds that his team is working on ways of optimizing Java in both multiprocessor and uniprocessor environments. For example, if multiprocessor code "runs in a single-threaded-only model then you've got a bunch of code in there... that's not necessary," he says. The Speedway team is looking at ways of eliminating that code from the compilation process.

So does that mean that there will be two virtual machines -- one for multiprocessor Solaris and one for uniprocessor? "We won't know until we finish the project," Keller says.

Incidentally, Sun's virtual machine isn't the only one out there. Guava, from Australia's Softway, claims to be up to 50 times faster than Sun's virtual machine. And it should be. It costs about ,000 U.S. A freeware JVM called Kaffe is also available (see resources below). Sun's green thread and native thread Java virtual machines are available for free on Sun's Web site and will be included in Solaris 2.6. Early access Hot Spot code will be available this fall.

Learn more about this topic

Related: