I'm looking to install perf which is a kernel profiling tool for Linux.

Basically I'm trying to trace all page faults, so I run equivalent of:

sudo perf record -e page-faults -ag

Is it possible to install/use above tool on Mac? If not, what's the equivalent tool to achieve similar results (tracing all page faults with stack traces).

  • If you want to elaborate on what you want to do ultimately - we can avoid an XY problem type exchange. I'll go ahead and ask about your solution in case that's actually all you wanted to know. – bmike Jul 23 '16 at 15:14

No - there is no linux kernel to profile on OS X - so that tool is a fish out of water. OS X probably ships with everything you need though.

On macOS / OS X - there is a mach_kernel in use. It's exhaustively documented at: https://developer.apple.com/library/prerelease/content/documentation/Darwin/Conceptual/KernelProgramming/About/About.html

Additionally, you might be fine profiling the BSD based unix layer with the supplied command line tools. It really depends on which operations or aspect of system performance you wish to measure or debug.

To the specific topic of page faults, you can get cumulative statistics from top and vm_stat and then dig into specific processes using either dtrace or Instruments - which is a free tool part of Xcode on the app store and has a graphical interface for profiling the system calls per process or as a system.

  • I'm aware of vm_stat, but it gives me only the number of page faults per second, so doesn't trace anything. The same with top. If dtrace can do that, some example would be useful. – kenorb Jul 23 '16 at 15:20
  • @kenorb Let's leave this a general answer to a general question. If you want to ask a narrow dtrace question on OS X with the probe it might be answerable. I'd probably use instruments to trace your program since it's easy to figure if you even need dtrace – bmike Jul 23 '16 at 15:33
  • 1
    Let's see if someone else has tips then. Thanks @kenorb – bmike Jul 23 '16 at 19:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .