JMH benchmark fails on M1 MacBook Pro

John Auden lovedthefaioli at gmail.com
Mon Jan 31 19:39:55 UTC 2022


Good morning,

Some of my benchmarks keep constantly failing in "-prof dtraceasm" mode on
the new MacBook Pro because of dtrace error. Is there any way to debug it,
because "-v EXTRA" does not provide any details? Note: Some benchmarks run
fine, but few of them fail
Env:
OJDK 17.0.1 MacOS aarch64/M1
HSDIS compiled out of the tip of OJDK git repo
MacOS Monterey 12.1
JMH v1.34
The error is (I run it in sudo):
# Processing profiler results: DTraceAsmProfiler Exception in thread "main"
*java.lang.IllegalStateException: Non-zero error code from dtrace: 1* at
org.openjdk.jmh.profile.DTraceAsmProfiler.afterTrial(DTraceAsmProfiler.java:106)

I created a minimum example which reproduces the issue 100% of time:

>
> *@State(Scope.Benchmark)*
> *@BenchmarkMode(Mode.AverageTime)*
> *@OutputTimeUnit(TimeUnit.MICROSECONDS)*
> *@Warmup(iterations = 5, time = 10, timeUnit = TimeUnit.SECONDS)*
> *@Measurement(iterations = 3, time = 10, timeUnit = TimeUnit.SECONDS)*
> *//Disabled LSE to check if LL/SC could be faster than ARM v8.1 SWP*
> *@Fork(value = 1, jvmArgsAppend = {"-XX:+UnlockExperimentalVMOptions",
> "-XX:+UseEpsilonGC", "-XX:+AlwaysPreTouch", "-Xms2g", "-Xmx2g",
> "-XX:-RestrictContended", "-XX:-UseLSE"})*
> *@Threads(4)*
> *public class ContendedCounterBenchmark {*
> *  @Contended**  private final AtomicInteger _atomicInteger = new
> AtomicInteger(0);*
>
> *  @Benchmark*
> *  public int testAtomicInt() {*
> *    for(int i = 0; i < 100; i++) {*
> *      _atomicInteger.incrementAndGet();*
> *    }*
> *    return _atomicInteger.get();*
> *  }**}*


Thanks

Regards,
Alex Dubrouski


More information about the jmh-dev mailing list