THIS EXAMPLE MOVED INTO parca-dev/parca-demo
This repo is an example for how a Java application can be profiled with Parca Agent. First deploy Parca and Parca Agent as usual, for example on Kubernetes.
In order for Parca Agent to be able to make sense of the just-in-time compiled code by the Java VM, the Java process needs to comply to the Linux Kernel perf jit-interface. To do this, the java process needs to be started with the following two flags -XX:+PreserveFramePointer
and -agentpath:/your/path/to/libperfmap.so
where the libperfmap.so
agent can be downloaded here.
What the agent does is, it maintains a file in /tmp/perf-PID.map
, that contains mappings from memory address to Java class and function names. This is the Linux Kernel perf jit-interface, and when this file is present, Parca Agent will detect that and resolve the otherwise to humans incomprehensible memory addresses to the human readable class and function names.
To run this example Java spring boot app on the same Kubernetes cluster execute:
kubectl run spring-boot-example --image=ghcr.io/parca-dev/spring-boot-example:v0.0.1 --port=8080
The important parts to make this work are:
- Adding the
libperfmap.so
agent to the container image (see this line in the Dockerfile). - Adding the
-XX:+PreserveFramePointer
and-agentpath:/app/libperfmap.so
flags to the Java command. Depending on the setup and framework these flags may need to be set using theJAVA_OPTS
environment variable.
In the future there will be no need to load the additional agent at all, and everything will happen automatically. Follow parca-dev/praca-agent#1 for the latest status.
An example screenshot of parts of an iciclegraph/flamegraph of data produced with this example: