pyroscope-java
pyroscope-java copied to clipboard
Java agent does not work with Java Flight Recorder
I can't run pyroscope-java agent with the Java flight recorder (-XX:StartFlightRecording
flag).
15:41:51 ❯ java -XX:-Inline -XX:StartFlightRecording -javaagent:pyroscope.jar Main
2022-01-24 15:41:58.002 INFO PyroscopeAgent We recommend specifying application name via env variable PYROSCOPE_APPLICATION_NAME
2022-01-24 15:41:58.025 INFO PyroscopeAgent For now we chose the name for you and it's javaspy.UaQzrZeWTfGFueCnID015w
2022-01-24 15:41:58.025 WARN PyroscopeAgent PYROSCOPE_SERVER_ADDRESS is not defined, using http://localhost:4040
2022-01-24 15:41:58.255 INFO PyroscopeAgent Profiling started
[1] 91159 illegal hardware instruction java -XX:-Inline -XX:StartFlightRecording -javaagent:pyroscope.jar Main
Steps to reproduce
- Copy
Main.java
from the java example in the main repo - Compile it and then run with
-XX:StartFlightRecording
flag
javac Main.java
java -XX:-Inline -XX:StartFlightRecording -javaagent:pyroscope.jar Main
Error:
[1] 91159 illegal hardware instruction java -XX:-Inline -XX:StartFlightRecording -javaagent:pyroscope.jar Main
OS: MacOS 11.6.1 Big Sur (intel)
If I run it inside docker I get java_app_1 exited with code 139
Expected behaviour
From my understanding the java pyroscope agent uses async-profiler
under the hood. And because async-profiler works even with Java flight recorder enabled, I expect pyroscope to work too.
Java app with flight recorder and without pyroscope:
15:47:18 ❯ java -XX:-Inline -XX:StartFlightRecording Main
Started recording 1. No limit specified, using maxsize=250MB as default.
Use jcmd 92349 JFR.dump name=1 filename=FILEPATH to copy recording data to file.
Running async-profiler on the java process works even with flight recorder:
15:47:06 ❯ ./profiler.sh -e cpu,alloc,lock -f profile2.jfr 92349
Profiling for 60 seconds
Done
The async-profiler worked with flight recorder, so I was expecting pyroscope to work too.
2023-03-20 15:12:43.413 [WARN] Invalid PYROSCOPE_PROFILER_EVENT value cpu,alloc, using itimer