Profiling using the YourKit Plugin

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 analyse 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?

Analysing 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 analyse 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

Plugin Source Code

The source code for this Confluence plugin is available from Subversion and browseable in Fisheye. The JAR produced by 'mvn package' includes a copy of the YJP redistributable bundled in META-INF/lib/.

Was this helpful?

Thanks for your feedback!

13 Archived comments

  1. User avatar

    Rajendra

    Instructions available in this sections are not clear.

    Here are the steps that I have followed to install Yourkit plugin for Confluence Wiki (2.2.4) on Linux using JDK 1.4 on Tomcat Application Server 5.0:

    1. Download yourkit for OS platform on which you want to run and install it
    2. set LD_LIBRARY_PATH path
      First find out the path where libyjpagent.so file is present for given OS.
    3. Now we want to configure the Tomcat application server for Yourkit
      Since we are using JDK 1.4, go to tomcat/bin
      And modify "startup.sh" (in order to refer to yourkit library) as follows:
      or refer to http://confluence.atlassian.com/display/JIRA/Setting+Up+YourKit+Agent+Parameter
      Snapshots will be stored in directory set as "dir"
    4. Then install Yourkit plugin for Confluence Wiki

    Hope this helps.

    Few questions that I have still are:

    1. Current Confluence Yourkit plugin has only one option i.e. to take the Memory snapshot. It doesn't explain how one can take the CPU Snapshots.

    2. Also bit strange but worth to mention; whenever we ran the Yourkit plugin to take the memory snapshot, Apache has exceeded the max threads available due to which Wiki was inaccessible. Only way to restore the order was to restart tomcat, Apache.

    hope this information helps for everybody!

    regards,
    Rajendra

    18 Jan 2007
    1. User avatar

      Matt Ryall [Atlassian]

      Thanks for the info, Rajendra.

      I didn't cover instructions for JDK 1.4 because the profiling is markedly better in 1.5, and it also simplifies the document.

      Anyone who is looking at improving performance should definitely investigate upgrading their JDK. In our testing, both JDK 1.5 and 1.6 deliver significant performance benefits over their predecessors.

      Taking CPU snapshots is available in the new 0.2 release of the YourKit plugin. You can download it above.

      30 Apr 2007
  2. User avatar

    Rajendra

    Hi Matt,

    Yes, we have upgraded ourselves to JDK1.5. Addition of CPU snapshot feature is definitely going to be useful. Thanks for the same.

    One question: When you say performance benefits, can you please explain how you do this benchmark testing ?

    There is equivalent load testing we want to do it as we are planning to roll out Confluence Wiki to very large user audience and want to find out how much load one Confluence instance can handle. That will help us to know if need to go with Massive or not.

    Can you please share some detailed tips on Atlassian does load testing, performance testing? I know there is one tool Megatron that is being shared. But I couldn't able to much follow with result output.

    Your detailed answer is much appreciated.

    thanks,
    Rajendra

    01 May 2007
    1. User avatar

      Matt Ryall [Atlassian]

      Our experience is anecdotal at the moment; the result of running JIRA's functional tests against Sun JDKs 1.4, 1.5, 1.6.

      We're hoping to get some more detailed figures by adding performance analysis code to the test suite, but at the moment it's just the raw time to complete the entire suite of tests. There seemed to be a 20% improvement from 1.4 to 1.5, and a massive 50-60% from 1.5 to 1.6. The JIRA developers suspect the improvement mainly comes from storing local variables on the stack in 1.6, although again we have no evidence for this yet.

      03 May 2007
  3. User avatar

    Eric Wells

    Any chance you can make a version that works on an AIX server?

    Thanks,

    Eric

    08 Nov 2007
    1. User avatar

      Matt Ryall [Atlassian]

      Eric, if you can run the YourKit Java Profiler on AIX, then you should be able to use this Confluence plugin. If you can't run the profiler on AIX, you'll need to contact YourKit and ask them to support it.

      12 Dec 2007
  4. User avatar

    Keerthika Koteeswaran

    I have Confluence 2.5.5 running on Tomcat server. There seems to be a missing instruction in the installation procedure documented here. I followed the steps above and I got this error message when I clicked on Yourkit Profiling in Administration:
    I had to copy and save yjpagent.dll and yjp.ini in C:\Windows\system32 to finally get it running. I wonder if someone else has faced the same problem...

    26 Feb 2008
    1. User avatar

      Matt Ryall [Atlassian]

      Keerthika, you missed this step in the instructions:

      On Windows, add to your PATH environment variable the bin/win32/ directory underneath the YourKit installation directory.

      Copying these files to system32 is the equivalent of putting this YourKit directory on your PATH. However, this is not a recommended approach because you shouldn't modify files in that directory on a production system.

      26 Feb 2008
  5. User avatar

    Karen Conneely

    We are running Confluence 2.5.7/JDK 1.5.0/Tomcat 5.5.  
    When selecting "YourKit Profiling", the following is displayed:

    The following error(s) occurred:

    • Please ensure Confluence is started with the profiler libraries.

    The issue is that I can't find "the bin/setenv.bat file in your Confluence application directory" or any reference to JAVA_OPTS.  I have added the following to the Java Options within Tomcat properties but it didn't fix things: 

    "-agentpath:C:\Program Files\YourKit Java Profiler 7.0.11\bin\win32\yjpagent.dll"

     Can you please tell me where I should be adding the "-agentlib:yjpagent" parameter?

    Thanks,

    Steve

    04 Mar 2008
    1. User avatar

      Matt Ryall [Atlassian]

      Steve/Karen, when running Tomcat as a service you should add the -agentlib parameter to Tomcat's VM parameters, just like you have done with the -agentpath one. The instructions above are for Confluence Standalone.

      If you're still having problems, try adding the agent path to your PATH as described above, rather than using the -agentpath parameter. That is the method we have tested on Windows.

      04 Mar 2008
  6. User avatar

    Daniel Browne

    Version 6 is not available any longer, is this still supported by the newer version of YourKit?

    27 Jan 2011
  7. User avatar

    Andreas Wachowski

    I second Daniel's question - is your plugin for YourKit compatible with a more recent (ie still available) version of YourKit? I would appreciate if this page could be updated accordingly. Thx!

    03 May 2012
  8. User avatar

    Anonymous

    Hi Matt,

    I want to profile the performance of Android Kernel using YourKit Profiler.Is it possible?If so please provide me the steps to do it.

     

    Thanks

    Narayanan

     

    08 May 2012
Powered by Confluence and Scroll Viewport