System Usage(Instruments)
seems only trace explicit file io calls(open
, close
, write
, read
). System Trace(Instruments)
trace page fault
, but it is organized by call stack, make it hard to filter.
So any tool can trace the low level io events for a specific file?
DTrace can do some of that (at least in Solaris, you’ll have to try it out yourself on macOS). The
vm
provider has probes namedfspgin
,fspgout
, andfsfree
which fire when FS-backed pages are paged in or out of memory or are freed if they’re unmodified, respectively. There’s also a more general one calledmaj_fault
which fires whenever a page fault results in IO.The only problem is that DTrace doesn’t give you a way to get back to the filename from those probes, which might be ok if you’re mainly page faulting on a single file, or might be really annoying if you’re trying to figure out which file is the one getting paged. However, you can still get the
execname
orpid
of the process that’s causing the page fault though, in case that helps.Here’s where you can see the documentation for the
vm
provider. There are some example scripts there, but this one is probably the nicest to use:This prints out a timeline of memory activity for each type of fault, and the docs explain it in a little more detail.