Remote profiling Neo4j using yourkit
yourkit is my favourite JVM profiling tool and whilst it’s really easy to profile a local JVM process, sometimes I need to profile a process on a remote machine.
In that case we need to first have the remote JVM started up with a yourkit agent parameter passed as one of the args to the Java program.
Since I’m mostly working with Neo4j this means we need to add the following to conf/neo4j-wrapper.conf:
wrapper.java.additional=-agentpath:/Users/markhneedham/Downloads/YourKit_Java_Profiler_2013_build_13074.app/bin/mac/libyjpagent.jnilib=port=8888
If we run lsof with the Neo4j process ID we’ll see that there’s now a socket listening on port 8888:
java 4388 markhneedham 20u IPv6 0x901df453b4e9a125 0t0 TCP *:8888 (LISTEN)
...
We can connect to that via the 'Monitor Remote Applications' section of yourkit:
In this case I’m demonstrating how to connect to it on my laptop and am using localhost but usually we’d specify the remote machine’s host name instead.
We also need to ensure that port 8888 is open on any firewalls we have in front of the machine.
The file we refer to in the 'agentpath' flag is a bit different depending on the operating system we’re using. All the details are on the yourkit website.
About the author
I'm currently working on short form content at ClickHouse. I publish short 5 minute videos showing how to solve data problems on YouTube @LearnDataWithMark. I previously worked on graph analytics at Neo4j, where I also co-authored the O'Reilly Graph Algorithms Book with Amy Hodler.