HotSpot: A new breed of virtual machine

Sun's next-generation dynamic compiler generates bytecodes that scream

1 2 Page 2
Page 2 of 2

And, finally, HotSpot technology falls short in an artificial benchmark like the CaffeineMark. Because such benchmarks do not emulate real-world programs, it's possible to write a compiler that detects the nonsense cases (such as do-nothing loops) and optimizes them away. Such a compiler can produce extremely fast benchmark times that are not reflected in production programs. A compiler that doesn't optimize these weird cases may look bad by comparison, even if it's better in the real world. (Sun recently demonstrated this point by designing a compiler that specifically "optimized" these benchmarks down to a near-nothing program that ran in basically zero time. Although their attempt backfired in the public opinion polls, it made a strong statement that such benchmarks may not make very reliable measures of performance.)

As with any performance-enhancing technology, the bottom-line question is: How well does it work for your application? In the vast majority of normal applications, where garbage collection and thread synchronization occur and where real code repeats, the HotSpot approach provides a dramatic performance boost.

How HotSpot compares to native code

In this article, we've been comparing dynamic compilation to other ways of processing Java code. But we've always compared one form of Java to another. The skeptics in the audience are crying out, "Yeah, but how well does it do compared to my favorite compiler?" The answer is that it compares very favorably today, and it has an even more promising future. Sun has its sights set on achieving performance levels that rival that of an optimized C program. Given time, Sun is confident it can come close to that target.

At the moment, good JIT compilers meet or exceed the performance of static C++ compilers for object-oriented programs, as described in Performance tests show Java as fast as C++. And HotSpot is faster than a JIT. That's still not up to the performance of a compiled C program, but it's getting there.

Note: C++ can be used like Java to create an object-oriented program, or it can be used like C to create very fast, non-object-oriented code. Today, Java compares very favorably to C++ for an object-oriented program. But C++ can be optimized for performance with C-style coding in ways that Java doesn't allow. This can make the code harder to maintain, but very fast.

Finish line? The race has just begun!

HotSpot is the first working version of a dynamic compiler for the Java language. Correct operation has been verified. The goal now is progressive refinement and enhancement, until absolutely optimal performance is achieved. Sun believes that in the next several years it may even be able to approach the speeds of an optimized C program!

The outlook is exciting. The prospect of platform-independent code that outperforms even native optimizers holds out the possibility that, over the next few years, the Java language will become a realistic candidate for virtually every type of application. It's not just for applets anymore!

Eric Armstrong has been programming and writing professionally since before there were personal computers. He has firsthand knowledge of HotSpot based in part on his current work as a contractor at JavaSoft. His production experience includes artificial intelligence (AI) programs, system libraries, real-time programs, and business applications in a variety of languages. He is a regular contributor to JavaWorld, and the author of The JBuilder Bible, to be published by IDG Books this spring.

Learn more about this topic

  • For further information on thread synchronization, see:
  • To find how JITs stack up against C++, see Carmine Mangione's article, Performance tests show Java as fast as C++. http://www.javaworld.com/jw-02-1998/jw-02-jperf.html
  • For further information on the Symantec JIT that is now included with the Windows version of the Sun JDK, see http://www.symantec.com/jit/jit_readme.html
  • For further information on Sun's JIT for Solaris, see http://www.sun.com/solaris/jit/
  • For Sun's Java roadmap, including the release schedule for HotSpot, see http://www.sun.com/smi/Press/sunflash/9712/sunflash.971210.5.html
  • For A PC Week news article discussing HotSpot and Sun's plans to sell it as a commercial product, see http://www8.zdnet.com/pcweek/news/1215/15java.html
  • For the transcript of a JavaOne '97 conference presentation titled "High Performance JavaProgramming Tips, Techniques and Choices" by Peter Kessler and David Griswold, see http://sunsite.compapp.dcu.ie/IJUG/javaone/transcripts/perform.html

Related:
1 2 Page 2
Page 2 of 2