From IcedTea

Jump to: navigation, search

These are notes for developers working on the instrumenting profiler.

Thermostat includes an instrumenting profiler. The code for the entire profiler lies in the vm-profiler directory:

|-- agent
|-- client-cli
|-- client-core
|-- client-swing
|-- common
|-- distribution
`-- jvm-agent

agent contains the code specific to the profiler on the agent. This includes code that detects that JVMs are up, listens for commands to start/stop profiling and instruments JVMs to enable or disable profiling. This closely interacts with jvm-agent and there are a few conventions between them set up to facilitiate data transfer, including location and name of the profile data file (only if the JVM exits before user stops profiling), the InstrumentationControl interface that exposes the API of the jvm-agent and the name the API is published at.

client-cli contains cli-specific code for the profiler.

client-core contains general client-side code shared by the thermostat GUI and the CLI.

client-swing contains swing-specific client-side code.

common contains code shared between the agent and the client, including the data models and interfaces to save and load data.

distribution builds the entire plugin

jvm-agent contains code that is loaded by a target JVM. It contains the code that instruments the JVM it is iteself loaded in. It provides an interfaces for the agent to control it. It uses ASM to transform the bytecode to It is a stand-alone jar. It is not an OSGi bundle and does not load any other thermostat bundles.

The code is split over several classes. The main idea behind the profiler is to instrument the bytecode in classes to add code that calls into a custom class that records the method entry and exit times. The timing information is then saved to disk at the end of the profiling session and sent over to the storage. The main classes to note are:

  • AsmBasedInstrumentor contains the logic to instrument code.
  • ProfileRecorder measures and records timing information for method entry/exit.

This guide contains a good overview of how to use ASM to achive the bytecode transofmrations.

Personal tools