Faster VMs
VM runtimes and Java compilers vary enormously over time and across vendors. More and more optimizations are finding their way into both VMs and compilers. Many possible compiler optimizations are considered in later sections of this chapter. In this section I focus on VM optimizations.
VM Speed Variations
Different VMs have different running characteristics. Some VMs are
intended purely for development and are highly suboptimal in terms of
performance. These VMs may have huge inefficiencies, even in such
basic operations as casting between different numeric types. One
development VM I used had this behavior; it provided the foundation
of an excellent development environment (actually my preferred
environment), but was all but useless for performance testing, as any
data type manipulation other than with int
s or
boolean
s produced highly varying and misleading
times.
It is important to run any tests involving timing or profiling in the same VM you plan to run the application. You should test your application in the current “standard” VMs if your target environment is not fully defined.
There is, of course, nothing much you can do about speeding up any one VM (short of upgrading the CPUs). But you should be aware of the different VMs available, whether or not you control the deployment environment of your application. If you control the target environment, you can choose your VM appropriately. If you do not control the environment on which your application runs, remember ...
Get Java Performance Tuning now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.