Class WinPerfAsmProfiler
- All Implemented Interfaces:
ExternalProfiler
,Profiler
You must install Windows Performance Toolkit
. Once installed, locate directory with xperf.exe
file and either add it to PATH
environment variable, or set it to jmh.perfasm.xperf.dir
system
property.
This profiler counts only SampledProfile
events. To achieve this, we set xperf
providers to
loader+proc_thread+profile
. You may optionally save xperf
binary or parsed outputs using
jmh.perfasm.savePerfBin
or jmh.perfasm.savePerf
system properties respectively. If you do so and
want to log more events, you can use jmh.perfasm.xperf.providers
system property to override providers.
However, you must specify loader
, proc_thread
and profile
providers anyway. Otherwise
sample events will not be generated and profiler will show nothing.
By default JDK distributive do not have debug symbols. If you want to analyze JVM internals, you must build OpenJDK
on your own. Once built, go to bin/server
directory and unpack jvm.diz
. Now you have jvm.pdb
file with JVM debug symbols. Finally, you must set debug symbols directory to jmh.perfasm.symbol.dir
system
property.
This profiler behaves differently comparing to it's Linux counterpart LinuxPerfAsmProfiler
. Linux profiler
employs perf
utility which can be used to profile a single process. Therefore, Linux profiler wraps forked
JVM command line. In contrast, xperf
cannot profile only a single process. It have -PidNewProcess
argument, but it's sole purpose is to start profiling before the process is started, so that one can be sure that
none events generated by this process are missed. It does not filter events from other processes anyhow. For this
reason, this profiler doesn't alter forked JVM startup command. Instead, it starts xperf
recording in
beforeTrial(BenchmarkParams)
method, and stops in ExternalProfiler.afterTrial(org.openjdk.jmh.results.BenchmarkResult, long, java.io.File, java.io.File)
. This
leaves possibility to run this profiler in conjunction with some other profiler requiring startup command
alteration.
For this reason the profiler must know PID of forked JVM process.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.openjdk.jmh.profile.AbstractPerfAsmProfiler
AbstractPerfAsmProfiler.ASMLine, AbstractPerfAsmProfiler.Assembly, AbstractPerfAsmProfiler.GeneratedRegion, AbstractPerfAsmProfiler.MethodDesc, AbstractPerfAsmProfiler.NativeRegion, AbstractPerfAsmProfiler.PerfEvents, AbstractPerfAsmProfiler.Region, AbstractPerfAsmProfiler.UnknownRegion
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final String
private static final String
private joptsimple.OptionSpec
<String> private joptsimple.OptionSpec
<String> private joptsimple.OptionSpec
<String> private final String
private String
PID.private final String
private final String
Fields inherited from class org.openjdk.jmh.profile.AbstractPerfAsmProfiler
hsLog, perfBinData, perfParsedData, requestedEventNames, set
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionaddJVMInvokeOptions
(BenchmarkParams params) Prepend JVM invocation with these commands.protected void
addMyOptions
(joptsimple.OptionParser parser) Collection
<? extends Result> afterTrial
(BenchmarkResult br, long pid, File stdOut, File stdErr) Run this code after the trial is done.void
beforeTrial
(BenchmarkParams params) Run this code before starting the trial.Human-readable one-line description of the profiler.protected void
Parse profiler events from binary to text form.protected String
Get perf binary data extension (optional).protected AbstractPerfAsmProfiler.PerfEvents
readEvents
(double skipMs, double lenMs) Read parsed events.Methods inherited from class org.openjdk.jmh.profile.AbstractPerfAsmProfiler
addJVMOptions, allowPrintErr, allowPrintOut, stripEventNames
-
Field Details
-
MSG_UNABLE_START
- See Also:
-
MSG_UNABLE_STOP
- See Also:
-
xperfProviders
-
symbolDir
-
path
-
pid
PID. -
optXperfDir
-
optXperfProviders
-
optSymbolDir
-
-
Constructor Details
-
WinPerfAsmProfiler
- Throws:
ProfilerException
-
-
Method Details
-
addMyOptions
protected void addMyOptions(joptsimple.OptionParser parser) - Specified by:
addMyOptions
in classAbstractPerfAsmProfiler
-
addJVMInvokeOptions
Description copied from interface:ExternalProfiler
Prepend JVM invocation with these commands.- Parameters:
params
- benchmark parameters used for current launch- Returns:
- commands to prepend for JVM launch
-
beforeTrial
Description copied from interface:ExternalProfiler
Run this code before starting the trial. This method will execute before starting the benchmark JVM.- Specified by:
beforeTrial
in interfaceExternalProfiler
- Overrides:
beforeTrial
in classAbstractPerfAsmProfiler
- Parameters:
params
- benchmark parameters used for current launch
-
afterTrial
public Collection<? extends Result> afterTrial(BenchmarkResult br, long pid, File stdOut, File stdErr) Description copied from interface:ExternalProfiler
Run this code after the trial is done. This method will execute after benchmark JVM had stopped.- Specified by:
afterTrial
in interfaceExternalProfiler
- Overrides:
afterTrial
in classAbstractPerfAsmProfiler
- Parameters:
br
- benchmark result that was the result of the trialpid
- pid that the forked JVM hadstdOut
- file containing the standard output from the benchmark JVMstdErr
- file containing the standard error from the benchmark JVM- Returns:
- profiler results
-
getDescription
Description copied from interface:Profiler
Human-readable one-line description of the profiler.- Returns:
- description
-
parseEvents
protected void parseEvents()Description copied from class:AbstractPerfAsmProfiler
Parse profiler events from binary to text form.- Specified by:
parseEvents
in classAbstractPerfAsmProfiler
-
readEvents
Description copied from class:AbstractPerfAsmProfiler
Read parsed events.- Specified by:
readEvents
in classAbstractPerfAsmProfiler
- Parameters:
skipMs
- Milliseconds to skip.lenMs
- Milliseconds to capture after skip- Returns:
- Events.
-
perfBinaryExtension
Description copied from class:AbstractPerfAsmProfiler
Get perf binary data extension (optional).- Specified by:
perfBinaryExtension
in classAbstractPerfAsmProfiler
- Returns:
- Extension.
-