はじめに

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.

JIRA also has a plugin to profile JIRA's CPU and memory usage with YourKit.

JVM で YourKit を構成する

Download YourKit 6.0 or higher for your platform, and install it by following the installation instructions.

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

Windows configuration

Windows では、YourKit インストール ディレクトリの下の bin/win32/ ディレクトリの PATH 環境変数を追加します。たとえば、[コントロール パネル] > [システム] > [詳細] > [環境変数] 経由で、PATH に "C:\Program Files\YourKit Java Profiler 6.0.12\bin\win32" を追加することができます。

To configure Confluence's JVM to use the YourKit agent, you need to add a parameter to JAVA_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.

末尾に、次のような 'agentlib' パラメーターを追加します。

set JAVA_OPTS=%JAVA_OPTS% -Xms128m -Xmx256m -agentlib:yjpagent

Linux/Mac OS X configuration

Unix ベースのシステムでは、次のように、ライブラリパス環境変数にインストール ディレクトリが含まれます。

  • Mac の場合: export DYLD_LIBRARY_PATH=$DYLD_LIBRARY_PATH:/path/to/yourKitAgent
  • 他の Unix ベースのシステムの場合: export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/path/to/yourKitAgent

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

java -agentlib:yjpagent ...

これを、Tomcat の bin/setenv.sh に追加できます。例:

JAVA_OPTS="-Xms128m -Xmx256m $JAVA_OPTS -Djava.awt.headless=true -agentlib:yjpagent "

パフォーマンスの影響

YourKit の実行はパフォーマンスに影響を与える可能性があります。

パフォーマンスの問題を最小限に抑えるため、agentlib パラメーターで次の変更を使用します。

-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 will appear under the 'Administration' heading. Click it and you should see the options to take a memory or CPU snapshot.


YourKit Profiling menu item

このプロファイラー ダンプはローカルの一時ディレクトリに保存され、完了するとパスを示します。CPU スナップショットの場合は、30 秒以上かかります。メモリ スナップショットの場合は、10~15 秒かかります。


You can take either a memory or CPU snapshot

この操作を行う理由

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.

次の場合に CPU スナップショットを作成します。

  • Confluence が応答しない場合がある
  • ページの読み込みに時間がかかる
  • Confluence の CPU 使用率がピークに達しています。

次の場合にメモリ スナップショットを作成します。

  • Confluence のメモリ使用量が予想より多い
  • ログに OutOfMemoryError が表示される
  • 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 shutdown 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/.