RFR: CODETOOLS-7902928: Improve support for async-profiler 2.x [v3]

Aleksey Shipilev shade at openjdk.java.net
Tue May 11 12:55:11 UTC 2021

On Tue, 11 May 2021 05:48:26 GMT, Jason Zaugg <jzaugg at openjdk.org> wrote:

>> Allow multiple events to be captured simultaneously in this version,
>> provided that JFR is chosen as output format.
>> Delegate output file writing to the async-profiler. This is required
>> in 2.x for the JFR output but is supported in both versions. The file
>> path must be provided when starting the profiler with JFR output, so
>> we need to create the per-trial output directory in the first
>> `beforeIteration`.
>> Avoid the character '%' in the generated directory name as this
>> is interpreted by async-profiler as part %p or %t placeholder.
> Jason Zaugg has updated the pull request incrementally with one additional commit since the last revision:
>   Add cpu,alloc options for use as secondary events

No, wait. This secondary event handling is messy. I cannot convince myself it works correctly everywhere. (Try to run with `-prof async:output=jfr;event=cpu,alloc;verbose=true` to see the preview of the headache I am having now.)

Let me suggest a simpler, reduced patch: handle only single event per profiling session, for now. Then we can discuss in what form to introduce the secondary event handling.

jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java line 106:

> 104:                 "Enable allocation profiling. Optional argument (e.g. =512k) reduces sampling from the default of one-sample-per-TLAB. " + secondaryEventOk)
> 105:                 .withOptionalArg().ofType(String.class).describedAs("sample bytes");
> 106:         OptionSpec<String> optLock = parser.accepts("lock",

Style: should be separated by new-line here.

jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java line 375:

> 373: 
> 374:         StringWriter outputWriter = new StringWriter();
> 375:         PrintWriter printWriter = new PrintWriter(outputWriter);

Let's call these `sw` and `pw`, respectively.

jmh-core/src/main/java/org/openjdk/jmh/profile/AsyncProfiler.java line 518:

> 516:             String optionName = option.options().iterator().next();
> 517:             for (T value : ts) {
> 518:                 profilerOptions.append(',').append(optionName).append('=').append(value.toString());

Should probably call `separate()` instead of `append(',')`...


Changes requested by shade (Committer).

PR: https://git.openjdk.java.net/jmh/pull/37

More information about the jmh-dev mailing list