MacOs ASM-profiler based on xctrace/Instruments
Filipp Zhinkin
filipp.zhinkin at gmail.com
Mon Mar 11 18:06:54 UTC 2024
Hi all!
JMH comes with a DTraceAsmProfiler, which could be used on macOs as a
replacement for LinuxPerfAsmProfiler.
While it serves its purposes well, there are a few shortcomings: dtrace
requires superuser privileges and it can only sample by timer interrupts.
While the first shortcoming may not be considered as a big issue (as long
as you know that a benchmark you're profiling won't attempt to remove '/'),
the latter sets a limit on what and how could be profiled.
You can argue that developers could always take a Linux host and profile
their benchmarks there, but it's definitely not as convenient as profiling
the code on the same host you're developing it.
Thankfully, XCode comes with the Instruments tool [1] which allows you to
do a lot of different things, including sampling profiling (both using
timer interrupts and PMI). And it has a CLI called xctrace [2].
xctrace allows profiling an app from the command line the same way
Instruments does it (with a caveat that some non-trivial configuration has
to be performed in UI beforehand) and it requires neither superuser
privileges, nor SIP being disabled.
How do you feel about adding a new JMH ASM-profiler wrapping the xctrace
tool?
Some time ago I developed such a wrapper [3] and it works fine, so if there
are no strong arguments for not having such a profiler, I would love to
contribute it to the JMH.
It's also worth mentioning that xctrace not only allows to implement
LinuxPerfAsmProfiler replacement for the macOs, but it's also possible to
implement LinuxPerfNormProfiler-alike profiler on top of xctrace.
There are some implementation-specific questions that need to be discussed
if you will be positive about adding a xctrace-based profiler to the JMH,
but I'll abstain from posting it for now.
Best regards,
Filipp.
[1] https://help.apple.com/instruments/mac/current/#/
[2] https://keith.github.io/xcode-man-pages/xctrace.1.html
[3] https://github.com/fzhinkin/xctraceprof
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.org/pipermail/jmh-dev/attachments/20240311/e53d820b/attachment.htm>
More information about the jmh-dev
mailing list