Check out the new USENIX Web site. next up previous
Next: The HPROF Agent Up: Profiling Architecture Previous: Profiling Architecture

Java Virtual Machine Profiler Interface

Figure 1 illustrates the role of the JVMPI in the overall profiler architecture. The JVMPI is a two-way function call interface between the Java virtual machine and the profiler agent.

The profiler agent is typically implemented as a dynamically-loaded library. The virtual machine makes function calls to inform the profiler agent about various events that occur during the execution of the Java application. The agent in turn receives profiling events, and calls back into the Java virtual machine to accomplish one the the following tasks:

Using function calls is a good approach to an efficient binary interface between the profiler agent and different virtual machine implementations. Sending profiling events through function calls is somewhat slower than directly instrumenting the virtual machine to gather specific profiling information. As we will see, however, majority of the profiling events are sent in situations where we can tolerate the additional cost of a function call.

JVMPI events are data structures consisting of an integer indicating the type of the event, the identifier of the thread in which the event occurred, followed by information specific to the event. To illustrate, we list the definition of the JVMPI_Event structure and one of its variants gc_info below. The gc_info variant records information about an invocation of the garbage collector. The event-specific information indicates the number of live objects, total space used by live objects, and the total heap size.

typedef struct {
    jint event_type;
    JNIEnv *thread_id;
    ...
    union {
        ...
        struct {
            jlong used_objects;
            jlong used_object_space;
            jlong total_object_space;
        } gc_info;
        ...
    } u;
} JVMPI_Event;

Additional details of the JVMPI can be found in the documentation that is shipped with the JDK 1.2 release [15].


next up previous
Next: The HPROF Agent Up: Profiling Architecture Previous: Profiling Architecture
Sheng Liang
1998-12-19