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

Galder Zamarreño galder at openjdk.org
Fri Oct 11 05:01:25 UTC 2024


On Fri, 11 Oct 2024 04:57:58 GMT, Galder Zamarreño <galder at openjdk.org> wrote:

>> Fixes https://bugs.openjdk.org/browse/CODETOOLS-7903740
>
> Galder Zamarreño has updated the pull request incrementally with one additional commit since the last revision:
> 
>   Avoid reading the perf record output

Just pushed this:


diff --git a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.j>
index c948532f..69d74a86 100644
--- a/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java
+++ b/jmh-core/src/main/java/org/openjdk/jmh/profile/LinuxPerfAsmProfiler.java
@@ -46,7 +46,7 @@ public class LinuxPerfAsmProfiler extends AbstractPerfAsmProfiler {
     public LinuxPerfAsmProfiler(String initLine) throws ProfilerException {
         super(initLine, "cycles");

-        String[] senseCmd = { PerfSupport.PERF_EXEC, "stat", "--event", Utils.join(requestedEventNames, ","), "--log-fd", "2", "echo", "1" };
+        String[] senseCmd = { PerfSupport.PERF_EXEC, "record", "-q", "--event", Utils.join(requestedEventNames, ","), "-o", "-", "echo", "1"};

         Collection<String> failMsg = Utils.tryWith(senseCmd);
         if (!failMsg.isEmpty()) {


`org.openjdk.jmh.it.profilers.LinuxPerfAsmProfilerTest` runs fine in my local env:


Running org.openjdk.jmh.it.profilers.LinuxPerfAsmProfilerTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 21.079 sec - in org.openjdk.jmh.it.profilers.LinuxPerfAsmProfilerTest


The time it takes to run the test hints that something actually happened, rather than skipping the test, but we can verify it in the test output:


$ cat ./target/surefire-reports/org.openjdk.jmh.it.profilers.LinuxPerfAsmProfilerTest-output.txt
...
Secondary result "org.openjdk.jmh.it.profilers.LinuxPerfAsmProfilerTest.work:asm":
PrintAssembly processed: 70607 total address lines.
Perf output processed (skipped 8.197 seconds):
 Column 1: cycles (2717 events)


Also, running with skid option works fine:


$ java -jar target/benchmarks.jar JMHSample_01 -f 1 -i 1 -r 1 -wi 1 -w 1 -prof perfasm:events=cycles:p
...
Secondary result "org.openjdk.jmh.samples.JMHSample_01_HelloWorld.wellHelloThere:asm":
PrintAssembly processed: 59617 total address lines.
Perf output processed (skipped 5.870 seconds):
 Column 1: cycles (cycles:p) (713 events)


Now let's wait and see what CI says.

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

PR Comment: https://git.openjdk.org/jmh/pull/132#issuecomment-2406555993


More information about the jmh-dev mailing list