Newsletter sign-up
View all newsletters

Sign up for our Enterprise Java Newsletter

Enterprise Java

HotSpot: A new breed of virtual machine

Sun's next-generation dynamic compiler generates bytecodes that <em>scream</em>

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone

Starting line: Warming up the engines

Lord knows, interpreters are slow. Pre-compiling Java source code into portable bytecodes saves the time needed for translating syntax, but interpreting bytecodes in the Java virtual machine (JVM) is still exceedingly slow compared to the native code produced by a compiler. Thus, Java performance is generally deemed acceptable for small applets but not for any sizable application.

A just-in-time compiler (JIT) runs many times faster than an interpreter. It makes a drastic, noticeable difference when you're running even an interactive application. Although a JIT falls short of compiled-code speeds, it greatly extends Java's applicability. But a reasonably-performing application is still compute-limited. As long as the app mostly interacts with the user or does I/O, it's fine. But if it starts doing a lot of graphic processing or extensive computing, performance rapidly drops to unacceptable levels.

Sun's new HotSpot technology, due to ship this summer (with a developer release due sooner), is a dynamic compiler -- a compiler built into the virtual machine that promises to run as fast or faster than compiled code in the majority of applications. HotSpot promises to extend Java's applicability into a wide variety of areas, from servers to mainstream desktop applications -- without sacrificing portability. Sun's Java roadmap indicates a HotSpot JVM developer's release was scheduled to be available early in the first quarter of this year; a deployable HotSpot JVM implementation is scheduled to ship this summer.

This article explores the inner workings of Sun's dynamic compiler, HotSpot, and details the kinds of applications in which HotSpot is -- and is not -- more effective than the fastest JIT. (For more information on compilers and interpreters, see the sidebar How compilers and interpreters work. To find out how a JIT improves performance, see the sidebar How a JIT works.)

They're off!: Burning rubber with dynamic compilation

HotSpot is a dynamic compiler. It combines the best features of a JIT compiler and an interpreter, combining the two in a single package. That two-in-one combination provides a number of important benefits for code performance, as you will shortly see.

For all of its apparent newness, the concept of dynamic compilation is based on research done over the past 10 years at Stanford University and the University of California, Santa Barbara (UCSB). So the technology is actually fairly stable, but it's HotSpot that has propelled dynamic compilation into the limelight. And, in addition to dynamic compilation, there are two other major time-sinks that HotSpot addresses: garbage collection and synchronization.

The cost of computing: garbage collection and synchronization

Unfortunately, in the majority of applications, optimizing Java code is not all there is to improving performance. Some of the same features that help Java developers increase productivity and write more versatile, bug-free applications also consume mass quantities of runtime compute cycles. The major cycle-stealing features are garbage collection and threads. As the pie chart below shows, together these two features take up about 40 percent of the average application's run time.

  • Digg
  • Reddit
  • SlashDot
  • Stumble
  • del.icio.us
  • Technorati
  • dzone
Comment
Login
Forgot your account info?
Add comment
Anonymous comments subject to approval. Register here for member benefits.
Have a JavaWorld account? Log in here. Register now for a free account.
Resources
  • For further information on HotSpot and architecting your applications for maximum performance, see http://java.sun.com/javaone/sessions/slides/TT06/title.htm
  • See the results of the JavaWorld poll "What do you think of Sun's possible decision to sell its HotSpot high-speed compiler separately (instead of including it in the next version of the JDK)?" http://nigeria.wpi.com/cgi-bin/gwpoll/gwpoll/past.html
  • For further information on generational garbage collection, see
  • http://www.dcs.gla.ac.uk/~sansom/1993_gen-gc-for-haskell.html
  • http://csgrad.cs.vt.edu/~groener/courses/briefing.shtml
  • 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