Experiment/research: Discover Java processes via VMStructs
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 .
Why hsperfdata is not 100% reliable I understand, but can you lay out briefly what the other mechanisms could be added?
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.
Perfect, thank you!
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
Fixed by #2580