The platform independence of Java applications lets developers capitalize on the “write once, run anywhere” paradigm. Moreover, the popularity of the Java programming language has motivated platform providers to compete in producing the best performance for Java benchmark tests, particularly on the server side. As a result, enterprises have many choices when deploying high-performance application servers in a Java environment, the major consideration being level of performance for dollar spent.
Java developers have a similarly broad number of choices when deciding on a platform on which to develop their applications and stage their deployments. When evaluating a Java development system, developers typically consider at least the following points:
The choice of the best Java development platform is complicated by the fact that developers of Java programming tools, like other Java developers, typically do their best to design tools that run equally well on any platform. Other than the raw horsepower of a platform's underlying hardware, then, are all Java development environments created equal? Not by a long shot. This article does not attempt a head-to-head comparison among operating systems, but instead examines the ways the Solaris OS integrates its native capabilities with the JVM and Java development tools. Unless otherwise indicated, references in this article to the Solaris OS refer to the Solaris 10 Operating System.
Contents
Before delving into tools and technologies, consider two basic advantages of the Solaris OS. First, the Solaris OS is the tier 1 Java development platform. Sun Microsystems develops much of the HotSpot JVM and the Java SE JDK on the Solaris OS first. Likewise, the Solaris OS is a key performance optimization platform for Java technology. Second, the Solaris OS is unique in that support for the Java platform is included with a Solaris support contract. Sun Java Desktop System, Release 3 and Java 2 Platform, Standard Edition 5 are integrated and supported under a Solaris Service Plan (with certain component exceptions). No other operating system provides similar Java support. The Solaris Operating System's SunOS core provides UNIX shell commands and tools developers have become accustomed to, and complies with the Open Group’s Unix 98 specifications (also known as SUS version 2). The Solaris 10 OS adds a GUI windowing system, web browser, and other tools to the SunOS core. The SunOS core, currently derived from the AT&T SVR4.0 flavor of UNIX software, ships with hundreds of utilities and user-level programs that provide backwards compatibility for legacy applications and scripts dating from SunOS 4.x, a BSD flavor. As a mature and stable operating system, the Solaris OS has much to recommend it.
The widespread use and stability of the Solaris OS argues for its use as a deployment platform for enterprise and web-based applications. From a Java developer's perspective, it is more important to consider how well its native features support development in general, and how well its available development tools measure up, both in quantity and quality. These tools (preferably free and standards-based) include IDEs, diagnostic and debugging tools, compilers, and the JVM. The NetBeans IDE started as a Charles University student project in Prague in 1996. Sun Microsystems purchased the technology in 1999 and converted it to open source in 2000. Although it has been ported to all major platforms, the Solaris OS is still the tier 1 platform for the latest NetBeans releases. The NetBeans IDE can be downloaded for free from Sun Microsystems. The NetBeans IDE supports development of Java desktop, enterprise and web applications — including Java SE, Enterprise JavaBeans (EJB) technology, and Java ME mobile applications. The IDE uses the open source tool Ant to automate its project build processes. It also incorporates version control and refactoring. All the functions of the NetBeans IDE are provided by modules, which allow the IDE to be extended. New features, such as support for other programming languages, can be added by installing additional modules. With the Visual Web Pack module, the NetBeans IDE provides drag-and-drop GUI building capabilities for web applications. The NetBeans Enterprise Pack supports development of Java EE applications and includes SOA visual design tools, XML schema tools, web services orchestration for BPEL, and UML modeling. Most importantly, the Java EE compliant code produced using the NetBeans IDE (and its derivatives Sun Java Studio Creator IDE and Sun Java Studio Enterprise) allows your application to move from one compliant server to another safely, regardless of server manufacturer and without licensing fees.
Other IDEs
Several additional IDEs have been developed for the Solaris OS as well as other platforms. Those based on the NetBeans IDE include Sun Java Studio Creator and Sun Java Studio Enterprise. These and other development tools can be downloaded for free from Sun Microsystems. Other open source and third-party IDEs are also available, including the Eclipse IDE for the Solaris OS on x86 platforms. DTrace is a dynamic tracing facility that is built into the Solaris OS. It can be used to examine the behavior both of user programs and of the operating system itself. DTrace enables you to explore your system to understand how it works, track down performance problems across many layers of software, and locate the source of errors. Debugging a production application with crash dumps and memory snapshots is simply not practical. With DTrace, you can probe the system to provide answers to such questions as “Where did the signal to kill my process come from?” and “Why has a particular thread been preempted?” The Solaris 10 OS is instrumented with more than 30,000 access points that can be probed by DTrace, and you can add additional probes as needed. Using DTrace, you can collect data from specific points in the operating system to see how your application is behaving as it interacts with the Solaris OS. DTrace was designed to be able to debug live development or production systems, providing a system overview that is impossible to see with other tools. Java SE6, released in December 2006, contains built-in DTrace probes that you can easily use to collect detailed information about a running Java application. Because DTrace is part of the OpenSolaris community, it will inevitably be ported to other operating systems. But, as with other tools that originated with Sun Microsystems, it is likely that the latest DTrace features will be tested and will appear first on the Solaris OS.
DTrace Probes and Providers
A DTrace probe is an instrumentation point in the Solaris OS — a location in the system that you can examine to get system details. Four attributes of a probe form a quadruple that identifies the probe uniquely:
This naming convention provides human readability for the probes. The wildcard characters “
The As another example, consider the following quadruple:
This quadruple matches the
How DTrace Works
The D program source is represented in the figure by
DTrace providers in the kernel are awakened by probe descriptions in the program kernel module and provide callbacks into the program when a probe is fired. The callbacks cause the action statements in the program to be executed. Typically, these action statements collect, prune, and report data. A provider has been developed for Java code. The provider allows DTrace to collect intelligent information about Java applications. For example, you can find when the garbage collector runs, and collect information on method calls.
Programming with the D Language
DTrace programs are typically quite simple. Probe descriptions enable and monitor a probe, and action statements following the probe descriptions describe what to do when a probe fires. D Language programs have the following structure:
The first line identifies the file as a D language script.
This line is not necessary if the script is executed with
the
The second line in the script identifies the probe (or set of probes). The third line is an optional predicate, demarcated by slash characters. The action statements that follow are executed only when the predicate evaluates as true. The predicate section acts as a filter by letting you set conditions to determine when the action statements execute. You can set conditions based on many criteria, such as the name of an executable. The action statements let you report or collect information on some state of the system. Some probes provide generic information, others provide information that is quite specific.
A Trivial Example D Program
A special probe named
Example D Programs
In the following program, probes are enabled every time a system call is
executed (
The action statement causes the
JDK 6.0 has two DTrace providers built in that provide information about
the JVM:
Consider the following simple script that prints the time
when garbage collection runs for a target application. The
built-in variable
The
To run this script, you must first find the process id of
the Java application. Then use the process id in the
command line when you execute the script. For example, if
the script were named
In the following figure, the script is run for the
You can modify the script as follows to determine how much time was spent in each garbage collection event.
The
The
The first step in diagnosing a hung system is to discover if the virtual
machine process is idle or if a looping thread is consuming all CPU
cycles. You must use an operating system utility to make this
determination. On the Solaris OS, you can use the command
If a VM process appears to be looping, the first step in discovering the
source of the problem is to try to get a
thread dump. But, what if the process is running as a background
process, or the JVM output is directed to an unknown location? In such
cases, the application console and standard input/output is not
available. You can, however, use the
You can also run a DTrace agent library inside the Java Virtual Machine
(JVM) to provide DTrace probes that are specific to the JVM and the Java
platform. The agent, called
In addition to the integration of DTrace with Java technology, Java EE
software contains many other observability tools. These tools are
available on other platforms, but the integration of many of them with the
Solaris
Postmortem tools can provide information about hung Java processes or Java
core dumps. The Java tools are designed to work with the Solaris
One additional development tool deserves note: the Sun Studio Performance Analyzer, part of the Sun Studio Compilers and Tools suite. When profiling a Java application, the Sun Studio Performance Analyzer collects data on the JVM as it runs the Java application. Clock profiling, hardware-counter profiling, and synchronization tracing are all supported. The Sun Studio Performance Analyzer collects data by recording events in the life of each LWP of the Java process, along with the callstack at the time of the event. Java applications have unique characteristics that make profiling more difficult than for applications written in more traditional, natively compiled languages. For any method in a Java program, there is a version that is interpreted by the Hotspot JVM, and there may be another version that has been dynamically compiled by the HotSpot JVM. Moreover, the Java application may call precompiled native methods directly. In these mixed-mode Java applications, two callstacks are meaningful: a Java callstack and a machine callstack. Both callstacks are recorded during profiling by Sun Studio Performance Analyzer, and are reconciled during analysis. Profiling results can be shown with a GUI Analyzer or from the command line. Three different representations are provided:
Solaris Containers enable you to configure a container that acts as a completely separate instance of the Solaris OS, resulting in resource, fault, and security isolation. Solaris Containers are a type of operating system virtualization, and are made up of two major components: Solaris Zones and Solaris Resource Manager (SRM). SRM manages the physical system resources every Container receives, and Solaris Zones control the namespace isolation. The advantages of Solaris Containers for deployment are obvious:
Advantages for developers are obvious as well:
Solaris Containers for Linux Applications allow Linux applications to run unmodified on the Solaris OS. By leveraging all the benefits of Solaris Containers, this feature combines the best of virtualization, resource management, and OS flexibility. Server ergonomics for servers was introduced in the Hotspot JVM for Java SE 5.0. It has greatly reduced application tuning time for server applications, particularly with heap sizing and advanced garbage collector (GC) tuning. Based upon the platform configuration, it will select a compiler, Java heap configuration, and garbage collector that produce good to excellent performance for most applications. In many cases, out-of-the-box settings provide the best tuning options for your application. The HotSpot JVM has been ported to all major operating systems, but the Solaris OS remains the tier 1 development platform. To implement smart tuning, the JVM determines the type of machine the JVM is running on. If the machine is server class, the Hotspot JVM allocates a larger heap, implements parallel garbage collection (GC), and employs a server compiler. The server compiler is designed for long-lived applications in which runtime performance and high throughput are important, while start-up time and memory footprint are not. If the machine is client class, the JVM allocates a minimal heap, implements serial garbage collection, and employs a client compiler. The client compiler is designed for applications in which start-up time and small memory footprint are most important. Whether the JVM detects a server or client class machine, it uses an adaptive heap sizing policy to tune performance automatically. For developers, automated tuning through server ergonomics means that you can usually obtain near optimum performance from your application without time-consuming hand tuning of heap sizes. The ZFS file system, introduced in the Solaris 10 OS, is typically seen as a benefit to system administrators — it dramatically simplifies storage administration, provides data integrity and high performance, and provides essentially limitless scalability. While developers typically take file systems for granted and assume that one is as good as another for practical purposes, they are beginning to recognize specific benefits from ZFS. One Solaris developer uses ZFS to maintain several development workspaces on his laptop computer. The workspaces are snapshots of the entire Solaris development source tree, each about 2 GB in size. With a few ZFS commands, he maintains a single primary workspace locally, and as many smaller workspaces (composed of diffs) as he needs. Using this approach, he can also create a scratch build workspace to keep build artifacts out of his development workspaces. For this developer, ZFS provides many large workspaces on a relatively small hard drive, and lets him manage them easily. While some of the purposes could have been achieved with loopback mounts, the ZFS techniques provide a much more efficient use of disk space.
The ease of administration inherent in ZFS can be very convenient for
developers. For example, ZFS makes it easy to share a file system between
multiple installations of the Solaris OS on a single machine. To share a
file system, create a ZFS pool and mount it on each different Solaris
installation. On each Solaris installation, provide an initialization
script that performs a As an operating system for Java development, the Solaris OS provides many of the same advantages it does for development in traditional languages:
Java specific advantages include profiling tools that are integrated with the HotSpot Java VM. Finally, some additional comparisons with competing operating systems are inevitable: Compared with Microsoft Windows, the Solaris OS provides:
Finally, the OpenSolaris community has erased the perceived advantages of Linux and other open-source OS alternatives. Open source operating systems, which now include the Solaris OS, must now compete on the basis of performance, usability, interoperability, cost of service, and overall cost of ownership. Thanks to all who provided information for this article, especially Brian Doherty, Angelo Rajadurai, Scott Oaks, Marty Itzkowitz, and Alexander Kolbasov. References
|
| |||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||