RFR: 7903740: JMH: Perf event validation not working with skid options [v4]

Aleksey Shipilev shade at openjdk.org
Thu Aug 22 12:56:17 UTC 2024


On Thu, 22 Aug 2024 12:46:59 GMT, Galder Zamarreño <galder at openjdk.org> wrote:

>> Also note what happens [here](https://github.com/galderz/github-actions/actions/runs/10418351274/job/28854335728).
>> 
>> The command executed is:
>> 
>> 
>> $ perf record --event cycles --output perf-record-validate.data echo 1
>> 
>> 
>> And the output contains:
>> 
>> 
>> [ perf record: Captured and wrote 0.001 MB perf-record-validate.data (3 samples) ]
>> 
>> 
>> So you can't use my logic [here](https://github.com/galderz/jmh/blob/2a9380664f9dd667fa10fe08b12d5c7e97c58b95/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java#L58) to decide whether perf record worked or not by checking if the output has `[ perf record: Captured and wrote 0.000 MB (null) ]`. So, how do you expect to sense that the perf record command worked from that alone?
>
> Also, you could have the situation that you pass in multiple events and a subset is only supported. To validate that you have to process the `perf record` output and see if there are events for all of them, otherwise fail.

Well, I would have expected we parsed `perf record` error and error code directly?


% perf record -e blah echo 1
event syntax error: 'blah'
                     ___ parser error
Run 'perf list' for a list of valid events

 Usage: perf record [<options>] [<command>]
    or: perf record [<options>] -- <command> [<options>]

    -e, --event <event>   event selector. use 'perf list' to list available events

% echo $?
129

% perf record -e cycles:p echo 1 
Error:
cycles:p: PMU Hardware doesn't support sampling/overflow-interrupts. Try 'perf stat'

% echo $?                       
255

% perf record -e cycles echo 1       
1
[ perf record: Woken up 1 times to write data ]
[ perf record: Captured and wrote 0.013 MB perf.data (16 samples) ]

% echo $?                       
0


Yes, I understand it actually does not test whether the counters _report_ non-zero values, but that's okay. We only do a light-weight validation that `perf record` even accepts these.

-------------

PR Review Comment: https://git.openjdk.org/jmh/pull/132#discussion_r1727001343


More information about the jmh-dev mailing list