Skip to content

Instantly share code, notes, and snippets.

@alarcher
Last active June 23, 2017 00:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alarcher/6463b77b754dc7f02e85382ef675f987 to your computer and use it in GitHub Desktop.
Save alarcher/6463b77b754dc7f02e85382ef675f987 to your computer and use it in GitHub Desktop.
alarcher@pikku:/home/alarcher$ sudo dtrace -qn 'syscall:::entry /execname == "firefox"/ { self->ts = timestamp; } syscall:::return /self->ts/ { @[probefunc] = count(); } tick-60s { printa(@); exit(0) }'
Password:
mmap 1
gtime 8
yield 12
lwp_kill 36
lwp_sigmask 36
setcontext 36
getpid 120
mprotect 170
memcntl 253
stat64 416
writev 667
sendmsg 774
ioctl 1462
write 5041
read 5047
rusagesys 6682
lwp_park 11968
pollsys 11987
recvmsg 12698
dtrace: description 'syscall:::entry ' matched 475 probes
CPU ID FUNCTION:NAME
1 80358 :tick-60s
key min .-----------------------------. max | count
gtime 256 : ▄▅▂ : 68719476736 | 8
getpid 256 : ▄▃▄ : 68719476736 | 8
rusagesys 256 : ▆▃ : 68719476736 | 4
mmap 256 : ▅▅ : 68719476736 | 2
yield 256 : ▅▃ ▃ : 68719476736 | 4
lwp_sigmask 256 : ▃▆ : 68719476736 | 35
setcontext 256 : █▁ : 68719476736 | 35
writev 256 : ▂▇ : 68719476736 | 12
sendmsg 256 : ▃▂▅▁ : 68719476736 | 18
lwp_kill 256 : █ : 68719476736 | 35
memcntl 256 : ▄▄▁▂ ▁ : 68719476736 | 22
read 256 : ▁▂▅▂▁ : 68719476736 | 129
mprotect 256 : ▄▅▁▁▁ : 68719476736 | 176
write 256 : ▁▂▅▃▁ : 68719476736 | 125
recvmsg 256 : ▃▅▂▁ : 68719476736 | 472
stat64 256 : ▁▃▄▃▁ : 68719476736 | 416
ioctl 256 : ▂▂▂ ▂▂▂ ▂▃▂ : 68719476736 | 26
pollsys 256 : ▁▅▂▁ ▁▁▁▁ ▁▁▁▁▁▁▁▁▁▁▁ : 68719476736 | 437
lwp_park 256 : ▁▁▃▂▁▁▁▁▁▂▁▁▁▁▁▁▁▁▁ ▁▂▁▁▁▁▁ : 68719476736 | 1718
alarcher@pikku:/home/alarcher$ sudo dtrace -n 'syscall::lwp_park:entry /execname == "firefox"/ {self->ts = timestamp} syscall::lwp_park:return /self->ts/ {@[probefunc] = quantize(timestamp - self->ts); self->ts = 0; } tick-60s {printa(@); exit(0)}'
dtrace: description 'syscall::lwp_park:entry ' matched 3 probes
CPU ID FUNCTION:NAME
0 80358 :tick-60s
lwp_park
value ------------- Distribution ------------- count
512 | 0
1024 |@ 47
2048 |@@@@@@@@@ 382
4096 |@@@@ 177
8192 | 18
16384 | 19
32768 |@ 60
65536 |@ 57
131072 |@ 49
262144 |@@@@@@@ 272
524288 | 14
1048576 |@ 31
2097152 | 6
4194304 | 0
8388608 | 0
16777216 | 0
33554432 |@@@ 113
67108864 | 2
134217728 |@@@ 108
268435456 | 1
536870912 | 13
1073741824 |@@@ 111
2147483648 |@@ 99
4294967296 |@ 33
8589934592 | 6
17179869184 | 1
34359738368 | 0
alarcher@pikku:/home/alarcher$ sudo dtrace -n 'syscall::lwp_park:entry /execname == "firefox"/ {self->ts = timestamp} syscall::lwp_park:return /self->ts/ {@[ustack()] = quantize(timestamp - self->ts); self->ts = 0; } tick-60s {printa(@); exit(0)}'
dtrace: description 'syscall::lwp_park:entry ' matched 3 probes
CPU ID FUNCTION:NAME
1 80358 :tick-60s
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN8LockImpl6UnlockEv+0x18
0xe5e5e501
value ------------- Distribution ------------- count
1024 | 0
2048 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
4096 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN2js6detail9MutexImpl6unlockEv+0x1b
0x400
0x1
value ------------- Distribution ------------- count
1024 | 0
2048 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
4096 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN2js6detail9MutexImpl6unlockEv+0x1b
0x5
0x1
value ------------- Distribution ------------- count
1024 | 0
2048 |@@@@@@@@@@@@@@@@@@@@ 3
4096 |@@@@@@@@@@@@@@@@@@@@ 3
8192 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`mutex_lock_impl+0x291
libc.so.1`mutex_lock+0x19
libxul.so`_ZN8LockImpl4LockEv+0x18
value ------------- Distribution ------------- count
16384 | 0
32768 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
65536 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN2js6detail9MutexImpl6unlockEv+0x1b
0x5
0xe5e5e501
value ------------- Distribution ------------- count
1024 | 0
2048 |@@@@@@@@@@@@@@@@@ 5
4096 |@@@@@@@@@@@@@@@@@@@@@@@ 7
8192 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN2js6detail9MutexImpl6unlockEv+0x1b
0x10400
0x1
value ------------- Distribution ------------- count
1024 | 0
2048 |@@@@@@@ 2
4096 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 9
8192 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN2js6detail9MutexImpl6unlockEv+0x1b
0x3
0x1
value ------------- Distribution ------------- count
1024 | 0
2048 |@@@@@@@@@@@@@ 4
4096 |@@@@@@@@@@@@@@@@@ 5
8192 |@@@@@@@@@@ 3
16384 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN2js6detail9MutexImpl6unlockEv+0x1b
0x8
value ------------- Distribution ------------- count
512 | 0
1024 |@@ 2
2048 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 34
4096 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN2js6detail9MutexImpl6unlockEv+0x1b
0x3
0xe5e5e501
value ------------- Distribution ------------- count
1024 | 0
2048 |@@@@@@@@@@@@@@@@@@@@@@@@@ 15
4096 |@@@@@ 3
8192 |@@@@@@@@@@ 6
16384 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`mutex_lock_impl+0x291
libc.so.1`cond_wait_queue+0x7f
libc.so.1`__cond_wait+0x8f
libc.so.1`cond_wait+0x2e
libc.so.1`pthread_cond_wait+0x24
libxul.so`_ZN2js17ConditionVariable4waitERNS_9LockGuardINS_5MutexEEE+0x21
value ------------- Distribution ------------- count
8192 | 0
16384 |@@@@@@@@@@@@@@@@@@@@@@@@@@@ 2
32768 | 0
65536 |@@@@@@@@@@@@@ 1
131072 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN2js6detail9MutexImpl6unlockEv+0x1b
0x10400
0xe5e5e501
value ------------- Distribution ------------- count
1024 | 0
2048 |@@ 1
4096 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 22
8192 | 0
16384 |@@ 1
32768 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN2js6detail9MutexImpl6unlockEv+0x1b
0x8
0x10400
0x4d580000
value ------------- Distribution ------------- count
1024 | 0
2048 |@@@@@@@@@@ 9
4096 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 26
8192 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`mutex_lock_impl+0x291
libc.so.1`mutex_lock+0x19
libxul.so`_ZN2js6detail9MutexImpl4lockEv+0x1b
0x8
0x400
0x4d580000
value ------------- Distribution ------------- count
1024 | 0
2048 |@@@@@@@@@@ 1
4096 | 0
8192 | 0
16384 | 0
32768 |@@@@@@@@@@ 1
65536 |@@@@@@@@@@@@@@@@@@@@ 2
131072 | 0
libc.so.1`__lwp_unpark+0x19
libnspr4.so`pt_PostNotifies+0xfb
value ------------- Distribution ------------- count
512 | 0
1024 |@@@@@@@@@@ 18
2048 |@@@@@@@@@@@@@@@@ 29
4096 |@@@@@@@@@@@@@@ 26
8192 | 0
libc.so.1`__lwp_unpark+0x19
libnspr4.so`pt_PostNotifies+0xfb
value ------------- Distribution ------------- count
1024 | 0
2048 |@@ 3
4096 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 45
8192 |@ 1
16384 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN17ConditionVariable9BroadcastEv+0x18
0xe5e5e501
value ------------- Distribution ------------- count
2048 | 0
4096 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 54
8192 |@@@@@@ 10
16384 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`__cond_wait+0x8f
libc.so.1`cond_wait+0x2e
libc.so.1`pthread_cond_wait+0x24
libxul.so`_ZN2js17ConditionVariable4waitERNS_9LockGuardINS_5MutexEEE+0x21
0xe95fe704
0x1
value ------------- Distribution ------------- count
8192 | 0
16384 |@@@@@@@@@@@@@@@@@@@@@@@@ 6
32768 |@@@@@@@@@@@@ 3
65536 | 0
131072 |@@@@ 1
262144 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN2js6detail9MutexImpl6unlockEv+0x1b
value ------------- Distribution ------------- count
512 | 0
1024 |@@@@@ 17
2048 |@@@@@@@@@@@@@@@@@@@@@ 73
4096 |@@@@@@@@@@@@@@ 51
8192 | 1
16384 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`__cond_wait+0x8f
libc.so.1`cond_wait+0x2e
libc.so.1`pthread_cond_wait+0x24
libxul.so`_ZN2js17ConditionVariable4waitERNS_9LockGuardINS_5MutexEEE+0x21
0xe49fe704
0xe5e5e501
value ------------- Distribution ------------- count
4096 | 0
8192 |@@@@@@@ 2
16384 |@@@@@@@ 2
32768 |@@@@@@@@@@@@@@@@@ 5
65536 |@@@@@@@ 2
131072 |@@@ 1
262144 | 0
libc.so.1`__lwp_unpark+0x19
libxul.so`_ZN2js6detail9MutexImpl6unlockEv+0x1b
0x8
0x400
0x4d580000
value ------------- Distribution ------------- count
512 | 0
1024 | 1
2048 |@@@@@@@@@@@@@@@@@@ 74
4096 |@@@@@@@@@@@@@@@@@@@@@ 84
8192 | 2
16384 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`__cond_wait+0x8f
libc.so.1`cond_wait+0x2e
libc.so.1`pthread_cond_wait+0x24
libxul.so`_ZN2js17ConditionVariable4waitERNS_9LockGuardINS_5MutexEEE+0x21
0xf0ffe704
0xe5e5e501
value ------------- Distribution ------------- count
4096 | 0
8192 |@@@@ 1
16384 |@@@@@@@@ 2
32768 |@@@@@@@@@@@@ 3
65536 |@@@@@@@@ 2
131072 |@@@@@@@@ 2
262144 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`__cond_wait+0x8f
libc.so.1`cond_wait+0x2e
libc.so.1`pthread_cond_wait+0x24
libxul.so`_ZN2js17ConditionVariable4waitERNS_9LockGuardINS_5MutexEEE+0x21
0x1
value ------------- Distribution ------------- count
65536 | 0
131072 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 11
262144 |@@@ 1
524288 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`__cond_wait+0x8f
libc.so.1`cond_wait+0x2e
libc.so.1`pthread_cond_wait+0x24
libxul.so`_ZN2js17ConditionVariable4waitERNS_9LockGuardINS_5MutexEEE+0x21
0xe5e5e501
value ------------- Distribution ------------- count
65536 | 0
131072 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 22
262144 |@@@ 2
524288 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`cond_wait_common+0x27b
libc.so.1`__cond_timedwait+0x85
libc.so.1`cond_timedwait+0x35
libc.so.1`pthread_cond_timedwait+0x2b
libxul.so`_ZN17ConditionVariable9TimedWaitERKN4base9TimeDeltaE+0xb3
value ------------- Distribution ------------- count
65536 | 0
131072 |@@@ 4
262144 | 0
524288 | 0
1048576 | 0
2097152 | 0
4194304 | 0
8388608 | 0
16777216 | 0
33554432 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 56
67108864 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`__cond_wait+0x8f
libc.so.1`cond_wait+0x2e
libc.so.1`pthread_cond_wait+0x24
libnspr4.so`PR_WaitCondVar+0x61
value ------------- Distribution ------------- count
1073741824 | 0
2147483648 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 1
4294967296 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`cond_wait_common+0x27b
libc.so.1`__cond_timedwait+0x85
libc.so.1`cond_timedwait+0x35
libc.so.1`pthread_cond_timedwait+0x2b
libnspr4.so`pt_TimedWait+0x9e
value ------------- Distribution ------------- count
32768 | 0
65536 |@@@@@@@@@@@@@ 37
131072 |@ 2
262144 |@ 4
524288 |@@ 6
1048576 |@ 3
2097152 | 0
4194304 | 0
8388608 | 0
16777216 | 0
33554432 |@ 2
67108864 |@ 2
134217728 |@@@@@@@@@@@@@@@@@ 46
268435456 | 0
536870912 |@@ 6
1073741824 |@ 2
2147483648 | 0
4294967296 | 0
8589934592 | 0
17179869184 | 1
34359738368 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`cond_wait_common+0x27b
libc.so.1`__cond_timedwait+0x85
libc.so.1`cond_timedwait+0x35
libc.so.1`pthread_cond_timedwait+0x2b
libnspr4.so`pt_TimedWait+0x9e
value ------------- Distribution ------------- count
4096 | 0
8192 | 1
16384 | 0
32768 | 0
65536 | 0
131072 | 0
262144 | 0
524288 | 0
1048576 |@@@@@@@@@@@@@ 30
2097152 |@@@ 6
4194304 | 0
8388608 | 0
16777216 | 0
33554432 | 0
67108864 |@@@@@ 12
134217728 |@@ 5
268435456 | 1
536870912 | 0
1073741824 |@@@@@@@@@@@@@@@@ 35
2147483648 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`__cond_wait+0x8f
libc.so.1`cond_wait+0x2e
libc.so.1`pthread_cond_wait+0x24
libxul.so`_ZN17ConditionVariable4WaitEv+0x1c
0x43560000
value ------------- Distribution ------------- count
16777216 | 0
33554432 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 52
67108864 | 0
134217728 | 0
268435456 | 0
536870912 | 0
1073741824 | 0
2147483648 | 0
4294967296 | 0
8589934592 |@@@@ 6
17179869184 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`__cond_wait+0x8f
libc.so.1`cond_wait+0x2e
libc.so.1`pthread_cond_wait+0x24
libnspr4.so`PR_WaitCondVar+0x61
value ------------- Distribution ------------- count
2147483648 | 0
4294967296 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 33
8589934592 | 0
libc.so.1`__lwp_park+0x19
libc.so.1`cond_wait_queue+0x6a
libc.so.1`__cond_wait+0x8f
libc.so.1`cond_wait+0x2e
libc.so.1`pthread_cond_wait+0x24
libxul.so`_ZN2js17ConditionVariable4waitERNS_9LockGuardINS_5MutexEEE+0x21
value ------------- Distribution ------------- count
512 | 0
1024 | 1
2048 | 0
4096 | 1
8192 | 7
16384 |@ 9
32768 |@@ 39
65536 |@@@ 50
131072 |@ 11
262144 |@@@@@@@@@@@@@@@ 262
524288 |@ 19
1048576 | 0
2097152 | 0
4194304 | 0
8388608 | 0
16777216 | 0
33554432 | 0
67108864 |@@@@@@ 96
134217728 | 0
268435456 | 0
536870912 | 0
1073741824 |@@@@@ 88
2147483648 |@@@@@@ 96
4294967296 | 0
alarcher@pikku:/home/alarcher$ prstat -mLc -p $(pgrep firefox)
Please wait...
PID USERNAME USR SYS TRP TFL DFL LCK SLP LAT VCX ICX SCL SIG PROCESS/LWPID
18821 alarcher 0.3 0.0 0.0 0.0 0.0 0.0 100 0.0 .2M 25K .19 0 firefox/1
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 997 1K .10 0 firefox/36
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 19K 1K 77K 3K firefox/51
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 20K 2K 70K 3K firefox/35
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 .1M 5K .2M 0 firefox/22
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 19K 1K 64K 3K firefox/63
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 3K 735 7K 0 firefox/78
18821 alarcher 0.0 0.0 0.0 0.0 0.0 0.0 100 0.0 8K 1K 59K 0 firefox/5
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 71K 323 .1M 0 firefox/4
18821 alarcher 0.0 0.0 0.0 0.0 0.0 0.0 100 0.0 49K 3K .1M 0 firefox/2
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 34K 257 72K 0 firefox/27
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 25K 339 38K 0 firefox/12
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 25K 345 38K 0 firefox/9
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 25K 328 39K 0 firefox/14
18821 alarcher 0.0 0.0 0.0 0.0 0.0 100 0.0 0.0 25K 301 37K 0 firefox/13
Total: 1 processes, 48 lwps, load averages: 0.01, 0.01, 0.03
dtrace -x ustackframes=100 -n 'profile-99 /execname == "firefox"/ { @[stack(), ustack()] = count(); } tick-120s { exit(0); }' -o ff52.stksk
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment