JVMTI interface and agent architecture
The Rational Application Developer Java profiler consists of a set of native agents that are implemented through the Java Virtual Machine's JVMTI interface. The JVMTI interface is a standard interface that allows native libraries (known as agents) to control a running virtual machine (VM) and obtain information about the executing Java application. A JVMTI agent subscribes to JVM events (and, where needed, instrument class byte code), to ensure that it is notified of all profiling events as the Java application executes on that VM.
The profiler registers its native functions through the JVMTI interface: these functions are invoked by the JVM when registered events occur. With the Rational Application Developer Java profiling agent, profiling data is generated in real-time. That is, the agent does not wait until the application has terminated to provide and present that data. The product supports agents to collect information on the three dimensions listed previously.
One important note: The Rational Application Developer JVMTI Java Profiler is not a sample-based profiler, and as such, all JVM events that are not filtered by the profiling filters will be transmitted back to the workbench. This method of profiling ensures a high level of accuracy, but at the expense of a greater profiling overhead versus sample-based profiling.
Profiling agents are executed alongside the JVM (and inside the JVM process) when that JVM is run with special JVMTI-specific VM arguments. When the profiling agents run, they collect data from the JVM in the form of execution, heap, or thread events. Within the Rational Application Developer profiling sphere, these agents are referred to as the Execution Analysis, Heap Analysis, and Thread Analysis agents.
- The Execution Analysis agent is used to collect execution statistics, such as time spent in each method, the number of method calls, and the overall call graph.
- The Heap Analysis agent is used to generate memory usage statistics. It collects object allocation details, such as live instances and active size in memory.
- The Thread Analysis agent is used to obtain details about the threads spawned by the Java application, and to track object monitor use and contention throughout the target application.
To facilitate agent launching and client-agent communication, the profiling tooling uses a second component called the agent controller in order to allow agents to communicate with the workbench. This component is pre-bundled with Rational Application Developer.
Using the agent controller, a target Java application may reside on a different machine than that of the developer's workbench. The agent controller functions as an intermediary, sending commands and data between the workbench and the profiling agent. The following figure shows a remote profiling scenario. Communication between the developer's workbench and the agent controller is through sockets, while communication between the agent controller and agents is through named pipes and shared memory.
Figure 1. Remote profiling
In additional to agent support and communication, the agent controller provides additional services such as process launch, termination, and monitoring, and file transfer. It is always necessary for the agent controller process to be running on the target machine in order to utilize the profiling functionality on that machine. Fortunately, there are a variety of ways to start this process.
When profiling locally-launched applications directly in your local workbench, an Integrated Agent Controller (IAC) is started automatically, without user intervention, whenever any functionality that requires it is activated. The IAC will remain running as long as the workbench is open, and will shut down when the workbench is closed. The default IAC settings can be adjusted through the configuration view available under Preferences > Agent Controller.
In addition to local launch through the IAC, the agent controller can be used to launch applications on any supported remote host. A standalone agent controller, packaged as the IBM® Rational® Agent Controller daemon process, is available for download for 32- and 64-bit Linux®, Microsoft® Windows®, IBM® AIX®, Solaris, IBM® z/OS®, and Linux on IBM® System z® systems. These provide the ability for applications to be directly executed on a remote host, with the data generated by the remote agents being transmitted back to the local workbench through a socket connection to the remote machine.
See the Resources section at the end of this tutorial for the Rational Agent Controller download locations.