Profiling using the YourKit Plugin

On this page

Still need help?

The Atlassian Community is here for you.

Ask the community

There is a plugin for Confluence 2.2 and later which allows easy profiling using the YourKit profiler. No license is required to generate a memory or CPU snapshot, but you will need at least an evaluation license to analyze the results.

On this page:

Configuring YourKit in your JVM

Download YourKit 6.0 for your platform and follow the installation instructions to install it.
(warning) Note: YourKit version 7 is not compatible with the Confluence yourkit plugin.

The following instructions apply to Confluence and Tomcat installations with the Oracle (previously Sun) JDK. They should be easily applicable to other application servers and JVMs, however. The YourKit documentation covers this in more detail.

Windows Configuration

On Windows, add to your PATH environment variable the bin/win32/ directory underneath the YourKit installation directory. For example, you might add "C:\Program Files\YourKit Java Profiler 6.0.12\bin\win32" to your PATH, via Control Panel, System, Advanced, Environment Variables.

To configure Confluence's JVM to use the YourKit agent, you need to add a parameter to CATALINA_OPTS in the bin/setenv.bat file in your Confluence application directory. This file controls the startup parameters for Tomcat, so you'll need to restart it after making the changes.

Add the 'agentlib' parameter to the end like this:

set CATALINA_OPTS=%CATALINA_OPTS% -Xms1024m -Xmx1024m -XX:MaxPermSize=256m -XX:+UseG1GC -agentlib:yjpagent

Linux/Mac OS X Configuration

On Unix-based systems, include the installation directory in the library path environment variable, as shown below:

  • For the Mac: export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/path/to/yourKitAgent
  • For other Unix-based systems: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/yourKitAgent

In general, to configure the JDK, you add the agentlib parameter:

java -agentlib:yjpagent ...

You can add this to Tomcat's bin/setenv.sh like this:

CATALINA_OPTS="$CATALINA_OPTS -Djava.awt.headless=true" -agentlib:yjpagent "

Performance Impact

Running YourKit can have detrimental effects on performance.

To minimize performance problems use the following modifications to the agentlib parameter:

-agentlib:yjpagent=disablecounts,disablealloc,disablej2ee

See also Profiling overhead: how to reduce or avoid in the YourKit documentation.

Installing the YourKit Plugin

Download the plugin and upload it into Confluence through the Administration, Plugins page.

A new menu option, "YourKit Profiling' will appear under the 'Administration' heading. Click it and you should see the options to take a memory or CPU snapshot.

This profiler dump will be saved to a local temp directory, and the path shown once it is complete. For the CPU snapshot, this will take at least 30 seconds. For the memory snapshot, 10-15 seconds.

Screenshot: You can take a memory or CPU snapshot

Why would I do this?

Analyzing a profiler dump enables Atlassian Support (or you, if you are interested) to see exactly what is happening in your application: what classes are using the memory, what is using CPU and so on. This can help us debug tricky performance problems which would otherwise be impossible to analyze remotely.

Take a CPU snapshot if:

  • Confluence is sometimes unresponsive
  • Pages take a long time to load
  • Confluence's CPU usage is peaking.

Take a memory snapshot if:

  • Confluence's memory usage is higher than you expect
  • You are getting OutOfMemoryError's in your logs.

(info) If you run into situations where Confluence is unresponsive and you are not able to trigger a memory snapshot, please ensure that you start Confluence with the onexit=memory parameter in the JVM options (as in the example below) and simply shut down Confluence. Before shutting down a memory snapshot will be created.

 -agentlib:yjpagent=onexit=memory
Last modified on Feb 8, 2024

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.