15
J2SE 5.0 Performance White Paper Java™ Platform Performance Engineering Sun Microsystems, Inc. Table of Contents 1 Introduction 2 New Features and Performance Enhancements 2.1 Ergonomics in the 5.0 Java Virtual Machine 2.2 High Precision Timing 2.3 StringBuilder Class 2.4 Java 2D Technology Improvements 2.5 Image I/O Improvements 2.6 Thread Priority on the Solaris Platform 2.7 Class Data Sharing 2.8 Monitoring and Management for the Java Platform 2.9 Optimizations for x86 / x64 2.10 HotSpot™ Reliability 2.11 Concurrent Low Pause Garbage Collector Improvements 3 New Platform Support 3.1 Hardware 3.1.1 AMD Opteron 3.2 Operating Environments 3.2.1 Solaris 10 3.2.2 Sun Java Desktop System, Release 2 3.2.3 Windows Server 2003 3.2.4 Red Hat Enterprise Linux AS 3.0 3.2.5 SuSE Linux Enterprise Server 9 4 Going Further 4.1 Java Performance Portal 4.1.1 Ergonomics in the 5.0 Java Virtual Machine 4.1.2 Tuning Garbage Collection with the 5.0 Java Virtual Machine 4.1.3 jvmstat 3.0 4.2 J2SE 5.0 Documentation 4.3 Performance Articles 4.3.1 Using JConsole to Monitor Applications 4.3.2 The JVMPI Transition to JVMTI 4.4 Benchmark Disclosures

Java Standard Edition 5 Performance

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Java Standard Edition 5 Performance

J2SE 5.0 Performance White Paper

Java™ Platform Performance Engineering

Sun Microsystems, Inc.

Table of Contents

1 Introduction

2 New Features and Performance Enhancements

2.1 Ergonomics in the 5.0 Java Virtual Machine

2.2 High Precision Timing

2.3 StringBuilder Class

2.4 Java 2D Technology Improvements

2.5 Image I/O Improvements

2.6 Thread Priority on the Solaris Platform

2.7 Class Data Sharing

2.8 Monitoring and Management for the Java Platform

2.9 Optimizations for x86 / x64

2.10 HotSpot™ Reliability

2.11 Concurrent Low Pause Garbage Collector Improvements

3 New Platform Support

3.1 Hardware

3.1.1 AMD Opteron

3.2 Operating Environments

3.2.1 Solaris 10

3.2.2 Sun Java Desktop System, Release 2

3.2.3 Windows Server 2003

3.2.4 Red Hat Enterprise Linux AS 3.0

3.2.5 SuSE Linux Enterprise Server 9

4 Going Further

4.1 Java Performance Portal

4.1.1 Ergonomics in the 5.0 Java Virtual Machine

4.1.2 Tuning Garbage Collection with the 5.0 Java Virtual Machine

4.1.3 jvmstat 3.0

4.2 J2SE 5.0 Documentation

4.3 Performance Articles

4.3.1 Using JConsole to Monitor Applications

4.3.2 The JVMPI Transition to JVMTI

4.4 Benchmark Disclosures

Page 2: Java Standard Edition 5 Performance

4.4.1 SPECjbb 2000

4.4.2 VolanoMark™ 2.5

1 Introduction

While J2SE 5.0 has added many new features Sun Microsystems has also been working to

continue to improve scalability and performance, with a new emphasis on startup time and

memory footprint.

This guide gives an overview of the performance and scalability improvements made in the

J2SE 5.0 release along with various benchmarks to demonstrate the impact of these

improvements.

2 New Features and Performance

Enhancements

J2SE 5.0 includes a number of new features and enhancements to improve performance in

many areas of the platform. Improvements to new language features include: additions to the

virtual machine, enhancements to the base and integration libraries, the user interface,

deployment, tools and architectures, and OS & hardware platforms. Enhancements to

program execution speed include: Garbage collection ergonomics, StringBuilder class, Java

2D technology enhancements, and performance and memory usage improvements to image

I/O.

2.1 Ergonomics in the 5.0 Java Virtual Machine

Getting the best performance out of the JVM has often required detailed hand tuning of

command line options. Yet many users never set command line options for performance. In

order to give the best possible performance in a variety of situations Sun Microsystems has

improved the performance of the JVM even when no command line options are used.

In J2SE 5.0 the default selection for the garbage collector, heap size, and runtime compiler

are now chosen automatically. These new selections better match the needs of different types

of applications while requiring less command line tuning.

In addition a different way of tuning the heap has been added for the throughput garbage

Page 3: Java Standard Edition 5 Performance

collector. This new tuning allows the user to specify performance and memory utilization

criteria to dynamically tune the sizes of the heap. This "self tuning" behavior is referred to in

this document as "ergonomics". For more on ergonomics please see the Ergonomics in the

5.0 Java Virtual Machine document.

The performance improvements from ergonomics are significant. Here we compare

SPECjbb2000 performance between J2SE 1.4.2 and J2SE 5.0. This test was conducted on a

Sun Fire V40z with 4 x 2.4 GHz AMD Opteron CPU's and 8 GB RAM running Solaris 10:

In each case we ran the benchmark without any performance arguments (except that -

Xmx512m was required for proper benchmark execution with J2SE 1.4.2).

Please see the SPECjbb 2000 Benchmark Disclosure

We also compared VolanoMark™ 2.5 performance between J2SE 1.4.2 and J2SE 5.0. This

test was conducted on

a Sun Fire V40z with 4 x 2.4 GHz AMD Opteron CPU's and 8 GB RAM running Solaris 10:

Page 4: Java Standard Edition 5 Performance

In each case we ran the benchmark in loopback mode without any performance arguments.

The result shown is based upon relative throughput (messages per second with 400 loopback

connections)

The full java version for J2SE 1.4.2 is: java version "1.4.2_06"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)

Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

The full java version for J2SE 5.0 is: java version "1.5.0_01"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)

Java HotSpot(TM) Server VM (build 1.5.0_01-b08, mixed mode)

Please see the VolanoMark™ 2.5 Benchmark Disclosure

2.2 High Precision Timing

The method System.nanoTime() has been added, providing access to a nanosecond-

granularity time source for relative time measurements. The actual precision of the time

values returned by System.nanoTime() is platform-dependent.

2.3 StringBuilder Class

Page 5: Java Standard Edition 5 Performance

This class provides an API compatible with StringBuffer, but with no guarantee of

synchronization. This class is designed for use as a drop-in replacement for StringBuffer in

places where the string buffer was being used by a single thread (as is generally the case).

Where possible, it is recommended that this class be used in preference to StringBuffer as it

will be faster under most implementations. See the API documentation on StringBuilder for

more information.

2.4 Java 2D Technology Improvements

Added 2D features include expanded Linux and Solaris printer support, new methods for

creating fonts from files and streams, and new methods related to VolatileImages and

hardware acceleration of images. A number of internal changes to text rendering code greatly

improve its robustness, performance, and scalability. Other performance work includes

hardware-accelerated rendering using OpenGL (disabled by default). See the Java 2D

documentation for more information.

2.5 Image I/O Improvements

J2SE 5.0 improves image processing performance and adds readers and writers for new file

formats to the Image I/O system. For more information see the Image I/O documentation.

2.6 Thread Priority on the Solaris Platform

JRE 5.0 updates the priority mapping such that Java threads at NORM_PRIORITY can now

compete as expected with native threads. An excellent reference for these topics is Chapter 9,

"Threads," in Joshua Bloch's book Effective Java Programming Language Guide. See also the

Thread Priority on the Solaris Platform document.

2.7 Class Data Sharing

The class data sharing feature is aimed at reducing application startup time and footprint. The

installation process loads a set of classes from the system jar file into a private, internal

representation, then dumps that representation to a "shared archive" file. During subsequent

JVM invocations, the shared archive is memory-mapped in, saving the cost of loading those

classes and allowing much of the JVM's metadata for these classes to be shared among

multiple JVM processes. For more information see the Class Data Sharing documentation.

Java Virtual Machine performance improvements in J2SE 5.0, including Class Data Sharing,

have contributed to improved startup and footprint performance. Here we compare startup

performance between J2SE 1.4.2 and J2SE 5.0. This test was conducted on a Pentium 4 2.8

Page 6: Java Standard Edition 5 Performance

GHz system with 1 GB memory. The benchmark measures the time necessary to initialize the

NetBeans IDE version 3.5.1:

The startup comparison above shows relative performance (bigger is better): for Windows XP

J2SE 5.0 starts 8% faster,

and on the Sun Java Desktop System J2SE 5.0 starts 22% faster than J2SE 1.4.2, respectively.

Below we compare memory footprint required between J2SE 1.4.2 and J2SE 5.0 for starting

up a rich client Swing-based application:

Page 7: Java Standard Edition 5 Performance

The footprint comparison above shows relative performance (smaller is better). Measuring the

real memory impact of a Java application is often quite difficult. Perhaps the first hurdle in

understanding footprint is that conventional system utilities, such as Task Manager on

Windows, only tell part of the footprint story. Memory reported depends on whether

application data and programs are read as conventional files or memory mapped files. In other

words often the true memory footprint of an application includes all the files that have been

brought into the operating system's file system memory cache... Often memory pages that are

shared by other processes or in the file system cache are not reported by conventional tools.

Getting consistent footprint measurements is further complicated by accurately measuring the

same moment in an application's lifetime. Clearly the longer an application operates the more

likely it is to perform classloading, compilation or other activities that affect footprint. The

fantastic news for users of J2SE 5.0 is that despite adding massive new functionality Java

Engineering has actually pared down core JVM memory usage and leveraged Class Data

Sharing to make the actual memory impact on your system lower than with J2SE 1.4.2!

The systems used for this benchmark included:

Windows XP Professional, Version 2002, Service Pack 1

running on a 930 Mhz Pentium III system with 384MB of RAM

Red Hat Linux 3.0 Advanced Server

running on a 1.4 GHz system with 512 MB of RAM

Solaris 9 running on a SunBlade 2000, 900 Mhz UltraSPARC IV machine with 1GB

Page 8: Java Standard Edition 5 Performance

of RAM

2.8 Monitoring and Management for the Java Platform

This release of J2SE offers significant enhancements for monitoring and management for the

Java platform using JMX and SNMP. Please see the Monitoring and Management for the Java

Platform document for details.

2.9 Optimizations for x86 / x64

Many changes were made in J2SE 5.0 to take advantage of the performance features in

modern x86 and x64 CPUs. A good example of this are the optimizations made to

System.arraycopy(). In J2SE 1.4.2 System.arraycopy() was implemented using

memmove() which performed well on Solaris, but was found to be a performance bottleneck

on Linux. In J2SE 5.0, calls to memmove() were replaced with highly optimized x86 and x64

instructions tailored for running Java on these modern processors.

Here we compare array copy performance between J2SE 1.4.2 and J2SE 5.0. This test was

conducted on

a Sun Fire V40z with 4 x 2.4 GHz AMD Opteron CPU's and 8 GB RAM running Solaris 10:

Page 9: Java Standard Edition 5 Performance

The benchmark shown above involves copying large amounts of data in several threads, with

heavy use of System.arraycopy(). The test was conducted using highly tuned parameters

for J2SE 1.4.2 and the exact same parameters for J2SE 5.0 as to eliminate any advantage

J2SE 5.0 would gain from ergonomics. Here we are highlighting the array copy optimization

on x86 platforms while holding the hardware constant.

2.10 HotSpot™ Reliability

The Java™ HotSpot™ virtual machine for J2SE 5.0 benefits from improved reliability. But

how is reliability related to performance, you ask?

Because the performance of a JVM that's down is zero!

During the development cycle for J2SE 5.0 a series of release controls were put in place that

have resulted in much better product reliability.

The J2SE 5.0 release of the HotSpot™ virtual machine includes 8000 bug fixes.

Page 10: Java Standard Edition 5 Performance

2.11 Concurrent Low Pause Garbage Collector Improvements

As mentioned above Java™ HotSpot™ Ergonomics includes the choice of the garbage

collection algorithm. In certain situations described in the Tuning Garbage Collection with the

5.0 Java Virtual Machine document concurrent low pause collector may be a better choice for

the application at hand.

The Concurrent Low Pause Garbage Collector, also known as CMS, has had several

improvements for J2SE 5.0. Garbage collection pauses are shorter because of better use of

parallelism during collection periods during which application threads are stopped. The

pauses are also more uniform due to deliberately spacing pauses such that there is less impact

on collection latency as seen by application threads. And the heap is better utilized due to

improved promotion failure handling which postpones the need to start collections.

These improvements explain the dramatic performance gains in this CMS Server Benchmark

(a multi-threaded, memory intensive application). This test was conducted on dual CPU Xeon

3 GHz systems with 4 GB of memory:

J2SE 5.0 ergonomics also includes better handling of thread local allocation buffers (TLABs).

Page 11: Java Standard Edition 5 Performance

Adaptive resizing of TLABs reduces young generation fragmentation and wasted space thus

reducing the number of collections. While these TLAB improvements are not specific to

CMS we see here that they produce a dramatic improvement in the thread intensive

VolanoMark™ benchmark:

The result above was conducted on a 4 CPU Ultra 80 running Solaris 9 and comparing

throughput with 400 loopback connections. In each CMS result above we ran the benchmarks

the following options:

-server -Xmx512m -XX:+UseConcMarkSweepGC

The full java version for J2SE 1.4.2 is: java version "1.4.2_06"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.2_06-b03)

Java HotSpot(TM) Client VM (build 1.4.2_06-b03, mixed mode)

The full java version for J2SE 5.0 is: java version "1.5.0"

Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0-b64)

Java HotSpot(TM) Server VM (build 1.5.0-b64, mixed mode)

Page 12: Java Standard Edition 5 Performance

Please see the VolanoMark™ 2.5 Benchmark Disclosure

3 New Platform Support

The cross-platform capabilities of Java have expanded in J2SE to cover additional hardware

and software platforms.

Please see the Supported System Configurations chart for full details.

3.1 Hardware

As a result of the Sun-AMD Alliance J2SE hardware platform coverage has expanded to

include performance enhancements for AMD Opteron.

3.1.1 AMD Opteron

The AMD Opteron is now supported for J2SE 5.0 with the following operating environments:

Solaris x86 (32-bit), Windows Server 2003 (32 and 64-bit) and Linux (32 and 64-bit).

Sun offers several products based on the AMD Opteron:

Sun Java Workstation W1100z

Sun Java Workstation W2100z

Sun Fire V20z Server

Sun Fire V40z Server

Compute Grid Rack System

3.2 Operating Environments

3.2.1 Solaris 10

Sun is proud to support J2SE 5.0 on Solaris 10 the leading UNIX in the world and sets the

standard for the next generation of operating systems with major breakthroughs in features,

functionality, and performance. Solaris 10 provides a world-class operating system from the

Page 13: Java Standard Edition 5 Performance

enterprise to the desktop and everything in between.

J2SE 5.0 update 2 now offers 64-bit support for Solaris x86 on AMD Opteron. Java

engineering has worked overtime to insure that the stack of J2SE 5.0 on Solaris x86 on AMD

Opteron delivers the best possible performance.

3.2.2 Sun Java Desktop System, Release 2

J2SE 5.0 is now supported on Sun Java Desktop System, Release 2.

Sun Java Desktop System, Release 2 delivers the best of open source software with the

technical innovation of Sun to offer an affordable, comprehensive, fully integrated desktop

client environment with administration and developer tools and an enterprise-ready support

offering that lowers business costs, reduces complexities of desktop management, and

provides a secure computing environment.

3.2.3 Windows Server 2003

J2SE 5.0 is supported on Windows Server 2003 Web Edition, Standard Edition, Enterprise

Edition and DataCenter Edition in addition to Windows XP Home and Professional, 2000

Professional, 98 2nd Edition and ME.

3.2.4 Red Hat Enterprise Linux AS 3.0

J2SE 5.0 is supported on Red Hat Enterprise Linux AS 3.0 and also Red Hat Enterprise Linux

AS 2.1, ES 2.1, WS 2.1 and Red Hat 9.0.

3.2.5 SuSE Linux Enterprise Server 9

J2SE 5.0 is supported on SuSE Linux Enterprise Server 9 in addition to SuSE Linux

Enterprise Server 8 and SuSE 8.2 and 9.

4 Going Further

4.1 Java Performance Portal

For the latest in Java Performance best practices, documentation, tools, FAQs, code samples,

White Papers and other Java performance news check out

Page 14: Java Standard Edition 5 Performance

the Java Performance Portal ( http://java.sun.com/performance/ ).

Three especially relevant performance links for J2SE 5.0 are given here:

4.1.1 Ergonomics in the 5.0 Java Virtual Machine

The Ergonomics in the 5.0 Java Virtual Machine (

http://java.sun.com/docs/hotspot/gc5.0/ergo5.html ) document provides an overview of the

new self tuning features of J2SE 5.0.

4.1.2 Tuning Garbage Collection with the 5.0 Java Virtual Machine

The Tuning Garbage Collection with the 5.0 Java Virtual Machine (

http://java.sun.com/docs/hotspot/gc5.0/gc_tuning_5.html ) document expands on GC

concepts for J2SE 5.0 that were introduced in the Tuning Garbage Collection with the 1.4.2

Java Virtual Machine ( http://java.sun.com/docs/hotspot/gc1.4.2/ ) document.

4.1.3 jvmstat 3.0

The jvmstat 3.0 ( http://java.sun.com/performance/jvmstat/ ) home page documents the

lightweight performance monitoring capabilities that are built into J2SE 5.0 and explains how

to use these tools to monitor not only 5.0 HotSpot Java Virtual Machines but also HotSpot

1.4.1 and 1.4.2 JVM's.

4.2 J2SE 5.0 Documentation

Be sure to check out the wealth of J2SE 5.0 Documentation (

http://java.sun.com/j2se/1.5.0/docs/ ) including the

New Features and Enhancements ( http://java.sun.com/j2se/1.5.0/docs/relnotes/features.html )

and the

J2SE 5.0 Overview ( http://java.sun.com/j2se/1.5.0/docs/guide/index.html ).

4.3 Performance Articles

4.3.1 Using JConsole to Monitor Applications

Check out the article on Using JConsole to Monitor Applications (

http://java.sun.com/developer/technicalArticles/J2SE/jconsole.html ) to learn how to use this

Page 15: Java Standard Edition 5 Performance

GUI tool to find out how your Java application is performing.

4.3.2 The JVMPI Transition to JVMTI

Check out the article on The JVMPI Transition to JVMTI (

http://java.sun.com/developer/technicalArticles/Programming/jvmpitransition/ ) to learn more

about how these important interfaces, which are often used for performance analysis, have

changed.

4.4 Benchmark Disclosure

4.4.1 SPECjbb 2000

SPECjbb2000 is benchmark from the Standard Performance Evaluation Corporation (SPEC).

The performance referenced is based on Sun internal software testing conforming to the

testing methodologies listed above.

For the latest SPECjbb2000 results visit http://www.spec.org/osg/jbb2000.

4.4.2 VolanoMark™ 2.5

VolanoMark™ version 2.5 is a benchmark from Volano LLC ( http://www.volano.com/ ).