109 points · by epenn · 14y ago · 24 comments
- monitor execve() calls system-wide
- monitor I/O to a specific file, from any process
- measure per-process network usage
(note that newer Linux kernels may have other ways of accomplishing some of these tasks that I'm not aware of).
I've had a lot of success using SystemTap to look at low-level filesystem performance issues in the kernel. We've run SystemTap scripts on our production filesystem servers for over a year with no problems whatsoever.
Edit: formatting
ltrace is like strace, but does library calls instead of system calls.
value ------------- Distribution ------------- count
0 | 0
1 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1278
2 | 0
4 | 0
8 | 0
16 | 0
32 | 0
64 | 0
128 | 0
256 | 0
512 | 1
1024 | 0
2048 |@ 20
4096 | 2
8192 | 0
16384 | 0
32768 | 0
65536 | 3
131072 | 2
262144 | 1
524288 | 0
and if you want to know where, say, the 512-byte reads are coming from:# dtrace -n 'syscall::read:entry/arg2 == 512/{ @[ ustack() ] = count(); }'
mdworker
libSystem.B.dylib`read+0xa
Foundation`-[NSConcreteFileHandle readDataOfLength:]+0x1d6
RichText`GetMetadataForURL+0x338
mdworker`0x100006a66
mdworker`0x100009ec1
libSystem.B.dylib`_pthread_start+0x14b
libSystem.B.dylib`thread_start+0xd
1dtruss - similar to strace opensnoop - all files nettop - all network access iosnoop/iotop - all io execsnoop - all new processes errinfo - all system calls resulting in errors
Not exactly the same info but I think much more powerful as it is system wide and you call always filter out what you don't need to know, or write your own scripts!
BTW, the Windows equivalent is called "Process Monitor" from the SysInternals guy...
Unfortunately you need to "sudo" to use it, since dtrace needs root permsisions.
I think it would be a great visualization to go along with my documentation.
https://github.com/CyanogenMod/android_external_strace/blob/...
$ strace -tt -q -o graph.strace -s 100 -f bash -c 'ls |wc -l'
$ ./strace-graph graph.strace
bash -c ls |wc -l
+-- ls
`-- wc -l
The comments in the code claim it will show elapsed time for each process, but that's not working for me.I discovered the Python ptrace module while I was searching for this. I have a project for which modifying the Python module might be a nice alternative to parsing strace output.
(Obviously the cmdline tools are there as well.)
Additionally, OS X has several useful stock dtrace scripts, check 'apropos dtrace' for a listing