JRA(JRockit Runtime Analyzer)是 JRockit Mission Control 工具的一部分。JRA是一款功能强大的剖析工具,我们可以使用它了解应用程序中有关性能瓶颈的信息,而且该工具占用的系统开销极低。
几乎任何一个JRA发行版都会在JRA记录中加入一些新的选项。在最新发行的JRockit Mission Control工具中,JRA向导会在启动JRockit进行记录时检查它具有哪些功能,并提供相应的可配置选项。但是此处存在一个问题:连接JRockit 1.4时所使用的遗留协议并不支持查询各种可用的参数。大家也不必绝望;我们仍然可以使用一些方法使JRA记录的启动支持这一功能。以下是解决方法:
JROCKIT_HOME/bin中有一个小巧的命令行工具,即jrcmd。Jrcmd工具可用于对本地运行的JRockit进程调用各种命令。运行过程如下所示:
- 执行JROCKIT_HOME/bin/jrcmd列出机器上的JRockit进程。
- 选中某个进程并执行JROCKIT_HOME/bin/jrcmd <pid> help。
- 输入想要了解的命令,比如JROCKIT_HOME/bin/jrcmd <pid> help startjrarecording。
- 使用所选设置调用命令。
在本例中,我们选择使用的是startjrarecording命令,我们想知道启用startjrarecording命令时可以对特定的JRockit使用哪些参数。
在Windows命令行中执行JROCKIT_HOME/bin/jrcmd,运行结果如下所示:
D:\jrockits\R27.3.0_R27.3.0-106_1.5.0>bin\jrcmd.exe
2640 com.jrockit.mc.rcp.start.MCMain
5012 jrockit.tools.jrcmd.JrCmd
注意jrcmd工具列出的方式。在本例中,我想知道对于当前运行任务控制工具(com.jrockit.mc.rcp.start.MCMain)的JRockit可以使用哪些参数,因此我执行以下命令:
D:\jrockits\R27.3.0_R27.3.0-106_1.5.0>bin\jrcmd.exe 2640 help
2640:
The following commands are available:
kill_rmp_server
start_rmp_server
kill_management_server
start_management_server
checkjrarecording
stopjrarecording
startjrarecording
print_object_summary
memleakserver
print_class_summary
print_codegenlist
run_optfile
dump_codelayout
dump_codelist
dump_codemap
print_utf8pool
print_properties
print_threads
datadump_request
runsystemgc
runfinalization
heap_diagnostics
oom_diagnostics
print_exceptions
version
timestamp
command_line
memprof
sanity
verbosity
set_filename
help
print_memusage
For more information about a specific command use 'help '.
Parameters to commands are optional unless otherwise stated.
要想知道启动jrarecording时可能使用哪些参数,可以使用以下命令:
D:\jrockits\R27.3.0_R27.3.0-106_1.5.0>bin\jrcmd.exe 2640 help startjrarecording
2640:
Starts a JRA recording.
filename - name of the file to store JRA recording to
(string, jrarecording.xml)
recordingtime - length of the recording in seconds (int, 60)
delay - delay before starting recording in seconds (int,
0)
methodsampling - enable method sampling (bool, true)
gcsampling - enable gc information (bool, true)
heapstats - include heap statistics (bool, true)
nativesamples - include native code in sampling (bool, false)
methodtraces - include stack traces (bool, true)
tracedepth - depth of stack traces (int, 16)
sampletime - time between samples in milliseconds (int, 30)
zip - zip the recording (bool, true)
hwsampling - use hardware sampling if possible (bool, false)
threaddump - do full threaddumps at start and end of recordning
(bool, true)
threaddumpinterval - also do threaddumps every 'n' interval (can be
specified as x[ns|ms|s]) (time, 0s)
latency - include latency analysis (bool, false)
latencythreshold - do not record events shorter than this number (can
be specified as x[ns|ms|s]) (time, 20ms)
cpusamples - sample cpu usage during the recording (bool,
true)
cpusampleinterval - cpu sample interval (can be specified as
x[ns|ms|s]) (time, 1s)
在本例中,我发现启动记录活动时确实具有一些新特性(比如说对于特定的JVM启用 延时分析数据 功能)。实际上,要启动这样一个记录活动,可以编写以下命令:
D:\jrockits\R27.3.0_R27.3.0-106_1.5.0>bin\jrcmd.exe 2640 startjrarecording laten
cy=true latencythreshold=20ms recordingtime=120s
2640:
JRA recording started.
原文出处:http://dev2dev.bea.com/blog/hirt/archive/2007/07/creating_fully.html