This document describes how you can configure the JDisc Container to allow for profiling custom searchers in order to identify performance bottlenecks - be it lock contention or CPU intensive algorithms. It also describes how to enable remote debugging using the IntelliJ IDEA.
Yourkit is a good and simple tool for finding hotspots in Java code. It supports both sampling and tracing. Very often it is necessary to use both modes. Tracing is accurate as to how many times a method is invoked and from where. That can be used to analyze if you are actually not computing the same thing from multiple places and overall doing more than you need. However it will hide effects of cache miss and especially cost of atomic operations and synchronization costs.
Assume there is an installation in a data center that you would like to profile, preferably with a nice UI running on your local desktop. All this is just a few steps away:
<nodes jvmargs="-agentlib:yjpagent -Dvespa.freezedetector.disable=true"> ... </nodes>
Read more about the jvmargs services attribute. Disabling the freezedetector stops the container from shutting down during profiling.
vespa-deploy prepare && vespa-deploy activate
Browse $VESPA_HOME/logs/vespa.log for errors. You are now ready to perform profiling; you just need to install the UI on your desktop.
The server is ready for profiling, now install the YourKit profiler on the desktop. Download the distribution that fits the OS you are running from YourKit. Follow the installation instructions, including setting the license server.
Note: By default the YourKit agent runs on port 10001. If Vespa is running on hosts not directly reachable from the desktop, setting up an SSH tunnel can work around:
ssh -L 1080:$hostname:10001 $hostname
Where $hostname is the node that is running the container with the YourKit agent profiler. All traffic to localhost (the desktop) port 1080 will be forwarded to the remote application running on port 10001.
You are now ready to profile your application. (You will need to put some realistic load against the container instance, please see the Vespa benchmarking guide) After having started the load simulation you can start the profiling session, open the YourKit application installed locally and chose Monitor Remote Applications => Connect to remote application. Enter localhost:1080 and press Connect. You should now see the profiling screen with Remote application "Server" (PID XXXXX) is being profiled at localhost:1080.
To remote debug the container, use the jvmargs attribute of the container element in services.xml:
<nodes jvmargs="-Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8998"> ... </nodes>
Re-deploy the application, then restart Vespa on the node that runs the container. Browse vespa.log for errors. You are now ready to perform remote debug. In IDEA, add a new run task -> remote -> host= port= , where host is the host running the container instance configured with the specific debug jvmargs, and port is 8998. Feel free to change the port.