RFR: 7903696: JMH: Add xctrace-based perfasm profiler for macOS

Filipp Zhinkin fzhinkin at openjdk.org
Sat Mar 16 22:33:16 UTC 2024


Currently, the only perfasm profiler available on macOS is dtraceasm.
While it serves its purposes well, there are a few shortcomings: dtrace requires superuser privileges and it can only sample by timer interrupts.

Xcode comes with a performance-analysis tool called Instruments and it has a command-line tool, called xctrace.
xctrace allows profiling an app using both timer interrupts and PMI, and it does not require superuser privileges.

This PR brings JMH profilers that uses xctrace on macOS.

There are two profilers:
- XCTraceAsmProfiler, a perfasm profiler based on xctrace that works fine out of the box;
- XCTraceNormProfiler, a perfnorm profiler that requires mandatory parameter, that has to be setup using Instruments UI.

The latter is added as a PoC and could be wiped out of this PR.

Unfortunately, `xctrace` exports data in XML format, thus most of the code is responsible for XML parsing.

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

Commit messages:
 - 7903696: Add xctrace-based perfasm and perfnorm profilers
 - 7903696: Extract a method copying profiling result to a separate method

Changes: https://git.openjdk.org/jmh/pull/130/files
  Webrev: https://webrevs.openjdk.org/?repo=jmh&pr=130&range=00
  Issue: https://bugs.openjdk.org/browse/CODETOOLS-7903696
  Stats: 4298 lines in 26 files changed: 4285 ins; 8 del; 5 mod
  Patch: https://git.openjdk.org/jmh/pull/130.diff
  Fetch: git fetch https://git.openjdk.org/jmh.git pull/130/head:pull/130

PR: https://git.openjdk.org/jmh/pull/130


More information about the jmh-dev mailing list