parca-agent icon indicating copy to clipboard operation
parca-agent copied to clipboard

Experiment/research: Discover Java processes via VMStructs

Open v-thakkar opened this issue 2 years ago • 4 comments

By default, JVM generates hsperfdata files as mentioned here #1277. While relying on it to discover java processes should work for the first few versions of java support, in the long run, we should adhere to using multiple methods to cover the corner cases. [for example, absence of hsperfdata files if the user chooses to use -XX:-UsePerfData to turn off this functionality].

As JVM has VM structs, the idea is to check if we can rely on some stable ELF symbol to discover the java processes. Then we can do something similar as rbperf does here.

Few other ideas:

  • Use 'comm' and 'exe' along with hsperfdata during the java process discovery
  • Check whether the process is a JVM one by checking for libjvm in the dynamic libraries it loaded

This is not planned to be worked on for the next few weeks. Just opening this to keep track of this idea. Part of #1115 .

v-thakkar avatar Feb 27 '23 05:02 v-thakkar

Why hsperfdata is not 100% reliable I understand, but can you lay out briefly what the other mechanisms could be added?

brancz avatar Feb 27 '23 06:02 brancz

Why hsperfdata is not 100% reliable I understand, but can you lay out briefly what the other mechanisms could be added?

Updated. Let me know if you would like me to elaborate more.

v-thakkar avatar Feb 27 '23 07:02 v-thakkar

Perfect, thank you!

brancz avatar Feb 27 '23 09:02 brancz

Few other ways:

  • Use libjvm ELF ID - may not be reliable in case different JVM flavors are being used
  • Send a request to JVM attach API which allows querying the information about running Java processes

v-thakkar avatar Apr 19 '23 07:04 v-thakkar

Fixed by #2580

kakkoyun avatar Mar 04 '24 08:03 kakkoyun