Introduction To Low-Level Profiling and Tracing
Introduction To Low-Level Profiling and Tracing
[email protected] / [email protected]
@ChristianHeimes
Our systems block every 5 minutes.
We are loosing money. Fix it!
Christoph Heer
EuroPython 2019
● from Hamburg/Germany
●
Python and C developer
●
Python core contributor since 2008
●
maintainer of ssl and hashlib module
●
Python security team
●
CPU power states (P-states, C-states, TurboBoost, thermal throttling)
●
caches (L1 CPU, file system, JIT warm-up, DNS/HTTP)
●
hardware IRQs, Address Space Layout Randomization (ASLR)
https://vstinner.readthedocs.io/benchmark.html
%% time
time seconds
seconds usecs/call
usecs/call calls
calls errors
errors syscall
syscall
------
------ -----------
----------- -----------
----------- ---------
--------- ---------
--------- ----------------
----------------
28.78
28.78 0.000438
0.000438 00 1440
1440 read
read
27.33
27.33 0.000416
0.000416 11 440
440 25
25 stat
stat
9.72
9.72 0.000148
0.000148 11 144
144 mmap
mmap
...
...
0.79
0.79 0.000012
0.000012 11 11
11 munmap
munmap
Benchmark
Benchmark inside
inside aa virtual
virtual environment
environment
%% time
time seconds
seconds usecs/call
usecs/call calls
calls errors
errors syscall
syscall
------
------ -----------
----------- -----------
----------- ---------
--------- ---------
--------- ----------------
----------------
57.12
57.12 0.099023
0.099023 22 61471
61471 munmap
munmap
41.87
41.87 0.072580
0.072580 11 61618
61618 mmap
mmap
0.23
0.23 0.000395
0.000395 11 465
465 27
27 stat
stat
●
https://mail.python.org/pipermail/python-dev/2019-February/156522.html
●
https://homes.cs.washington.edu/~bornholt/post/performance-evaluation.html
start
start == time.time()
time.time()
with
with open('/etc/os-release')
open('/etc/os-release') as
as f:
f:
lines = f.readlines()
lines = f.readlines()
print(time.time()
print(time.time() -- start)
start)
$$ ltrace
ltrace -e
-e 'malloc+free+realloc@*'
'malloc+free+realloc@*' -c
-c -p
-p 6504
6504
%% time
time seconds
seconds usecs/call
usecs/call calls
calls function
function
------
------ -----------
----------- -----------
----------- ---------
--------- --------------------
--------------------
53.49
53.49 1.104804
1.104804 37
37 29796
29796 free
free
45.78
45.78 0.945565
0.945565 37
37 25523
25523 malloc
malloc
0.73
0.73 0.015069
0.015069 48
48 309
309 realloc
realloc
------
------ -----------
----------- -----------
----------- ---------
--------- --------------------
--------------------
100.00
100.00 2.065438
2.065438 55628
55628 total
total
Ring 3
Ring 1
Ring 0
syscall Kernel
Most privileged
Device drivers
Device drivers
Applications
$$ strace
strace -c
-c cat
cat /etc/os-release
/etc/os-release >/dev/null
>/dev/null
%% time
time seconds
seconds usecs/call
usecs/call calls
calls errors
errors syscall
syscall
------
------ -----------
----------- -----------
----------- ---------
--------- ---------
--------- ----------------
----------------
31,40
31,40 0,000591
0,000591 590
590 11 execve
execve
13,51
13,51 0,000254
0,000254 28
28 99 mmap
mmap
8,67
8,67 0,000163
0,000163 40
40 44 mprotect
mprotect
7,20
7,20 0,000135
0,000135 22
22 66 read
read
6,95
6,95 0,000131
0,000131 32
32 44 openat
openat
6,36
6,36 0,000120
0,000120 19
19 66 close
close
6,21
6,21 0,000117
0,000117 29
29 44 brk
brk
...
...
------
------ -----------
----------- -----------
----------- ---------
--------- ---------
--------- ----------------
----------------
100.00
100.00 0,001882
0,001882 49
49 22 total
total
$$ strace
strace -P
-P /etc/os-release
/etc/os-release cat
cat /etc/os-release
/etc/os-release >/dev/null
>/dev/null
strace:
strace: Requested
Requested path
path '/etc/os-release'
'/etc/os-release' resolved
resolved into
into '/usr/lib/os.release.d/os-release-fedora'
'/usr/lib/os.release.d/os-release-fedora'
openat(AT_FDCWD,
openat(AT_FDCWD, "/etc/os-release",
"/etc/os-release", O_RDONLY)
O_RDONLY) == 33
fstat(3,
fstat(3, {st_mode=S_IFREG|0644,
{st_mode=S_IFREG|0644, st_size=693,
st_size=693, ...})
...}) == 00
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL)
fadvise64(3, 0, 0, POSIX_FADV_SEQUENTIAL) = 0= 0
read(3,
read(3, "NAME=Fedora\nVERSION=\"29
"NAME=Fedora\nVERSION=\"29 (Twenty
(Twenty "...,
"..., 131072)
131072) == 693
693
read(3,
read(3, "",
"", 131072)
131072) == 00
close(3)
close(3) == 00
+++
+++ exited
exited with
with 00 +++
+++
$$ strace
strace -e
-e %net
%net -p
-p 6504
6504
socket(AF_INET,
socket(AF_INET, SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK,
SOCK_DGRAM|SOCK_CLOEXEC|SOCK_NONBLOCK, IPPROTO_IP)
IPPROTO_IP) == 33
connect(3,
connect(3, {sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.38.5.26")}, 16)
{sa_family=AF_INET, sin_port=htons(53), sin_addr=inet_addr("10.38.5.26")}, 16) == 00
sendto(3,
sendto(3, "\323\300\1\0\0\1\0\0\0\0\0\0\3www\6python\3org\0\0\1\0\1", 32, MSG_NOSIGNAL, NULL,
"\323\300\1\0\0\1\0\0\0\0\0\0\3www\6python\3org\0\0\1\0\1", 32, MSG_NOSIGNAL, NULL, 0)0) == 32
32
recvfrom(3, "\323\300\201\200\0\1\0\2\0\0\0\0\3www\6python\3org\0\0\1\0\1"..., 2048,
recvfrom(3, "\323\300\201\200\0\1\0\2\0\0\0\0\3www\6python\3org\0\0\1\0\1"..., 2048, 0, 0,
{sa_family=AF_INET,
{sa_family=AF_INET, sin_port=htons(53),
sin_port=htons(53), sin_addr=inet_addr("10.38.5.26")},
sin_addr=inet_addr("10.38.5.26")}, [28->16])
[28->16]) == 93
93
socket(AF_INET,
socket(AF_INET, SOCK_STREAM|SOCK_CLOEXEC,
SOCK_STREAM|SOCK_CLOEXEC, IPPROTO_TCP)
IPPROTO_TCP) == 33
setsockopt(3,
setsockopt(3, SOL_TCP,
SOL_TCP, TCP_NODELAY,
TCP_NODELAY, [1],
[1], 4)
4) == 00
connect(3,
connect(3, {sa_family=AF_INET,
{sa_family=AF_INET, sin_port=htons(443),
sin_port=htons(443), sin_addr=inet_addr("151.101.36.223")},
sin_addr=inet_addr("151.101.36.223")}, 16)
16) == 00
getsockopt(3,
getsockopt(3, SOL_SOCKET,
SOL_SOCKET, SO_TYPE,
SO_TYPE, [1],
[1], [4])
[4]) == 00
getpeername(3,
getpeername(3, {sa_family=AF_INET,
{sa_family=AF_INET, sin_port=htons(443),
sin_port=htons(443), sin_addr=inet_addr("151.101.36.223")},
sin_addr=inet_addr("151.101.36.223")}, [16])
[16]) == 00
$$ dd
dd if=/dev/zero
if=/dev/zero of=/dev/null
of=/dev/null bs=1M
bs=1M count=10
count=10
10485760
10485760 bytes (10 MB, 10 MiB) copied, 0,00328225
bytes (10 MB, 10 MiB) copied, 0,00328225 s,
s, 3,2
3,2 GB/s
GB/s
$$ strace
strace -e inject=write:delay_exit=100000 -o /dev/null \\
-e inject=write:delay_exit=100000 -o /dev/null
dd
dd if=/dev/zero
if=/dev/zero of=/dev/null
of=/dev/null bs=1M
bs=1M count=10
count=10
10485760
10485760 bytes
bytes (10
(10 MB,
MB, 10
10 MiB)
MiB) copied,
copied, 1,10699
1,10699 s,
s, 9,5
9,5 MB/s
MB/s
User-space probes
●
(almost) all functions in binaries
●
applications
●
shared libraries
## trace-cmd
trace-cmd record
record -e
-e 'cfg80211:cfg80211_inform_bss_frame'
'cfg80211:cfg80211_inform_bss_frame' -e
-e 'cfg80211:cfg80211_get_bss'
'cfg80211:cfg80211_get_bss'
## trace-cmd report
trace-cmd report
...
...
irq/140-iwlwifi-1834
irq/140-iwlwifi-1834 [002]
[002] 91697.995389:
91697.995389: cfg80211_inform_bss_frame:
cfg80211_inform_bss_frame: phy0,
phy0, band:
band: 1,
1, freq:
freq:
5180(scan_width:
5180(scan_width: 0)
0) signal:
signal: -6600,
-6600, tsb:132269768490547,
tsb:132269768490547, detect_tsf:0,
detect_tsf:0, tsf_bssid:
tsf_bssid: 00:00:00:00:00:00
00:00:00:00:00:00
kworker/u16:3-23176
kworker/u16:3-23176 [004]
[004] 91697.995468:
91697.995468: cfg80211_inform_bss_frame:
cfg80211_inform_bss_frame: phy0,
phy0, band:
band: 1,
1, freq:
freq:
5180(scan_width:
5180(scan_width: 0)
0) signal:
signal: -6600,
-6600, tsb:132269768490547,
tsb:132269768490547, detect_tsf:0,
detect_tsf:0, tsf_bssid:
tsf_bssid: 00:00:00:00:00:00
00:00:00:00:00:00
irq/140-iwlwifi-1834
irq/140-iwlwifi-1834 [002]
[002] 91698.002485:
91698.002485: cfg80211_inform_bss_frame:
cfg80211_inform_bss_frame: phy0,
phy0, band:
band: 1,
1, freq:
freq:
5180(scan_width:
5180(scan_width: 0)
0) signal:
signal: -6700,
-6700, tsb:132269775585563,
tsb:132269775585563, detect_tsf:0,
detect_tsf:0, tsf_bssid:
tsf_bssid: 00:00:00:00:00:00
00:00:00:00:00:00
wpa_supplicant-2320
wpa_supplicant-2320 [000]
[000] 91698.198168:
91698.198168: cfg80211_get_bss:
cfg80211_get_bss: phy0,
phy0, band:
band: 1,
1, freq:
freq: 5180,
5180,
08:96:d7:XX:XX:XX,
08:96:d7:XX:XX:XX, buf:
buf: 0x73,
0x73, bss_type:
bss_type: 0,
0, privacy:
privacy: 22
wpa_supplicant-2320
wpa_supplicant-2320 [000]
[000] 91698.216052:
91698.216052: cfg80211_get_bss:
cfg80211_get_bss: phy0,
phy0, band:
band: 1,
1, freq:
freq: 5180,
5180,
08:96:d7:XX:XX:XX, buf: 0x73, bss_type: 0, privacy:
08:96:d7:XX:XX:XX, buf: 0x73, bss_type: 0, privacy: 2 2
80,335503652
80,335503652 seconds
seconds time
time elapsed
elapsed
185,163504000
185,163504000 seconds
seconds user
user
18,416851000
18,416851000 seconds
seconds sys
sys
## perf
perf stat
stat -M
-M Turbo_Utilization
Turbo_Utilization make
make -j
-j
599.287.742.470
599.287.742.470 cpu_clk_unhalted.thread
cpu_clk_unhalted.thread ## 1,7
1,7 Turbo_Utilization
Turbo_Utilization
354.672.677.325
354.672.677.325 cpu_clk_unhalted.ref_tsc
cpu_clk_unhalted.ref_tsc
Intel
Intel i5-8265U
i5-8265U 1.60GHz
1.60GHz // 3.90GHz
3.90GHz
$$ sudo
sudo perf
perf stat
stat -e
-e 'probe_libc:malloc*'
'probe_libc:malloc*' -e
-e 'probe_libc:free*'
'probe_libc:free*' -e
-e 'probe_libc:realloc*'
'probe_libc:realloc*' -p
-p 18154
18154
25.540
25.540 probe_libc:malloc_1
probe_libc:malloc_1
00 probe_libc:malloc
probe_libc:malloc
00 probe_libc:free
probe_libc:free
29.948
29.948 probe_libc:free_1
probe_libc:free_1
00 probe_libc:realloc
probe_libc:realloc
309
309 probe_libc:realloc_1
probe_libc:realloc_1
$$ perf
perf report
report
$$ perf
perf annotate
annotate
$$ perf
perf script
script || stackcollapse-perf.pl
stackcollapse-perf.pl >> out.perf-folded-full
out.perf-folded-full
$$ flamegraph.pl
flamegraph.pl out.perf-folded-full
out.perf-folded-full >> perf-calls-full.svg
perf-calls-full.svg
[l..
_.. [libpy..
_.. [libpytho..
_.. [libpython..
_.. [libpython..
_.. [libpython3..
_.. [libpython3..
_.. _PyMethodDe..
_.. _.. _PyCFunctio..
_.. _.. _PyEval_EvalFr..
_.. P.. _PyEval_EvalCo.. _.. _..
_.. _.. P.. _Py.. _PyFunction_FastC.. _..
_.. _.. _.. [l.. _Py.. _PyEval_EvalFrameD.. _Py..
[.. _P.. _.. _.. _P.. _P.. _PyFunction_FastCallKeyw.. _Py.. _..
[.. P.. [l.. _P.. _.. _.. [lib.. _P.. _.. _P.. _PyEval_EvalFrameDefault _Py.. _Py_..
[lib.. [libpytho.. _Py.. _.. _P.. [lib.. _P.. _.. _P.. _PyFunction_FastCallKeywords _Py.. _Py_..
PE.. [libpyth.. [libpython3.7m... _Py.. [.. _P.. _PyO.. _PyFun.. _P.. _PyEval_EvalFrameDefault _PyF.. [libp..
X50.. [libpyth.. _PyGC_CollectNo.. _Py.. _.. _.. [l.. [libp.. _PyEval_.. _PyFunction_FastCallKeywords _PyE.. [libp.. dl..
by_.. PyGC_Col.. PyImport_Cleanup _Py.. P.. _P.. _P.. _PyMet.. _PyEval_E.. _PyEval_EvalFrameDefault _PyF.. _Py_U.. _d..
X50.. Py_FinalizeEx _Py.. _PyEval.. Py.. _PyCFu.. _PyFunction_FastCallKeywords _PyEva.. _.. __lib.. _d..
[_s.. [libpython3.7m.so.1.0] _PyEval.. _PyEval_EvalFrameDefault _PyFun.. _PyF.. _start
python3
$$ perf
perf record
record -Fmax
-Fmax --call-graph
--call-graph lbr
lbr -p
-p 19414
19414
^C[
^C[ perf
perf record:
record: Woken
Woken up
up 11 times
times to
to write
write data
data ]]
$$ perf
perf script
script || stackcollapse-perf.pl
stackcollapse-perf.pl >> out.perf-folded-partial
out.perf-folded-partial
$$ flamegraph.pl
flamegraph.pl out.perf-folded-partial
out.perf-folded-partial >> perf-calls-partial.svg
perf-calls-partial.svg
39%
as..
asn..
asn..
asn..
EC.. asn1.. AS..
a.. eck.. asn1.. AS.. as.. x.. _..
as.. ecke.. asn1.. ASN.. asn1_.. _..
asn.. x509_.. ASN1.. x509_name_canon asn1_i.. [..
asn.. pubke.. x509_name_ex_d2i asn1_t.. P..
asn1_item_embed_d2i asn1_i.. _P..
asn1_template_noexp_d2i m.. _.. ASN1_i.. m.. [li.. _..
asn1_template_ex_d2i m.. [.. X509_O.. _.. _PyEva.. _..
asn1_item_embed_d2i ms.. _.. OPENSS.. [.. _PyFun.. _..
asn1_template_noexp_d2i ms.. _.. X509_S.. [.. _PyEval_.. [.. a..
asn1_template_ex_d2i __.. _.. SSL_CT.. P.. _PyEval_.. P.. A..
select@.. asn1_item_embed_d2i in.. _P.. [_ssl... _.. _PyFunctio.. _P.. A..
[readline... ASN1_item_ex_d2i B.. EVP_D.. X5.. _Py.. [libpy.. _.. P.. _PyEval_Eva.. [li.. P..
PyOS_Readl.. ASN1_item_d2i PEM_read_bio_ex x5.. _Py.. [libpy.. _.. _P.. [l.. _PyEval_Eva.. _PyEva.. X..
PyTokenize.. PEM_X509_INFO_read_bio X5.. _Py.. [libpyt.. _Py.. _P.. _P.. _PyFunction_FastCall.. b..
PyParser_P.. o.. X509_load_cert_crl_file _Py.. _PyEval_Eval.. _P.. _P.. _PyEval_EvalFrameDefault X..
PyParser_A.. state.. by_file_ctrl _PyFunction_FastCa.. _P.. [l.. _PyEval_EvalCodeWithName _Py.. [_s..
[libpython.. SSL_d.. X509_STORE_load_locations _PyEval_EvalFrameDe.. Py.. Py.. _PyFunction_FastCallKeywords _.. _Py..
PyRun_Inte.. [_ssl.cpython-37m-x86_64-linux-gnu.so] _PyEval_EvalCodeWit.. _PyEval_EvalFrameDefault _P.. _Py..
python3
## ./ext4slower
./ext4slower 11
Tracing
Tracing ext4
ext4 operations
operations slower
slower than
than 11 ms
ms
TIME
TIME COMM
COMM PID
PID TT BYTES
BYTES OFF_KB
OFF_KB LAT(ms)
LAT(ms) FILENAME
FILENAME
18:44:18
18:44:18 bash
bash 4573
4573 RR 128
128 00 6.45
6.45 balooctl
balooctl
18:44:19
18:44:19 IndexedDB
IndexedDB #198
#198 4571
4571 SS 00 00 8.90
8.90 583651055lp.sqlite-wal
583651055lp.sqlite-wal
18:44:21
18:44:21 IndexedDB
IndexedDB #198
#198 4571
4571 SS 00 00 10.02
10.02 583651055lp.sqlite-wal
583651055lp.sqlite-wal
18:44:21
18:44:21 IndexedDB
IndexedDB #198
#198 4571
4571 SS 00 00 3.90
3.90 583651055lp.sqlite
583651055lp.sqlite
18:44:43
18:44:43 mozStorage
mozStorage #5
#5 4571
4571 WW 24
24 288
288 6.10
6.10 cookies.sqlite-wal
cookies.sqlite-wal
## ./tcpconnect
./tcpconnect -u
-u 1000
1000
PID
PID COMM
COMM IP
IP SADDR
SADDR DADDR
DADDR DPORT
DPORT
4874
4874 Chrome_IOThr
Chrome_IOThr 44 192.168.7.168
192.168.7.168 107.170.8.46
107.170.8.46 80
80
4874
4874 Chrome_IOThr
Chrome_IOThr 44 192.168.7.168
192.168.7.168 107.170.8.46
107.170.8.46 443
443
4874
4874 Chrome_IOThr
Chrome_IOThr 44 192.168.7.168
192.168.7.168 107.170.8.46
107.170.8.46 443
443
4874
4874 Chrome_IOThr
Chrome_IOThr 44 192.168.7.168
192.168.7.168 107.170.8.46
107.170.8.46 443
443
4874
4874 Chrome_IOThr
Chrome_IOThr 44 192.168.7.168
192.168.7.168 107.170.8.46
107.170.8.46 443
443
4874
4874 Chrome_IOThr
Chrome_IOThr 44 192.168.7.168
192.168.7.168 107.170.8.46
107.170.8.46 443
443
## ./sslsniff
./sslsniff -p18888
-p18888
FUNC
FUNC TIME(s)
TIME(s) COMM
COMM PID
PID LEN
LEN
WRITE/SEND
WRITE/SEND 0.000000000
0.000000000 python3
python3 18888
18888 146
146
-----
----- DATA
DATA -----
-----
GET
GET // HTTP/1.1
HTTP/1.1
Host:
Host: ep2019.europython.eu
ep2019.europython.eu
User-Agent:
User-Agent: python-requests/2.20.0
python-requests/2.20.0
Accept-Encoding:
Accept-Encoding: identity
identity
Accept:
Accept: */*
*/*
Connection:
Connection: keep-alive
keep-alive
-----
----- END
END DATA
DATA -----
-----
READ/RECV
READ/RECV 0.159023041
0.159023041 python3
python3 18888
18888 8192
8192
-----
----- DATA
DATA -----
-----
HTTP/1.1
HTTP/1.1 200
200 OK
OK
Server:
Server: nginx
nginx
Date:
Date: Sun,
Sun, 07
07 Jul
Jul 2019
2019 19:18:46
19:18:46 GMT
GMT
Content-Type:
Content-Type: text/html;
text/html; charset=utf-8
charset=utf-8
Content-Length:
Content-Length: 33617
33617
Connection:
Connection: keep-alive
keep-alive
X-Frame-Options:
X-Frame-Options: SAMEORIGIN
SAMEORIGIN
ETag:
ETag: "c35dc4fdb282b799d8d77703a7553424"
"c35dc4fdb282b799d8d77703a7553424"
Vary:
Vary: Accept-Language,
Accept-Language, Cookie
Cookie
Content-Language:
Content-Language: enen
Set-Cookie:
Set-Cookie: django_language=en;
django_language=en; expires=Mon,
expires=Mon, 06-Jul-2020
06-Jul-2020 19:18:46
19:18:46 GMT;
GMT; Max-Age=31536000;
Max-Age=31536000; Path=/
Path=/
>>>
>>> requests.get("https://ep2019.europython.eu/")
requests.get("https://ep2019.europython.eu/")
$$ sudo
sudo bpftrace
bpftrace -e
-e 'uprobe:/lib64/libc.so.6:malloc
'uprobe:/lib64/libc.so.6:malloc // comm
comm ==
== "python3"
"python3" // {{ @bytes
@bytes == hist(arg0);
hist(arg0); }'
}'
@bytes:
@bytes:
[1]
[1] 171
171 || ||
[2,
[2, 4)
4) 661
661 |@@@
|@@@ ||
[4,
[4, 8)
8) 356
356 |@|@ ||
[8,
[8, 16)
16) 1699
1699 |@@@@@@@@
|@@@@@@@@ ||
[16,
[16, 32)
32) 7929
7929 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
|@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ||
[32,
[32, 64)
64) 10513
10513 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
|@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@|
[64,
[64, 128)
128) 1574
1574 |@@@@@@@
|@@@@@@@ ||
[128,
[128, 256)
256) 609
609 |@@@
|@@@ ||
[256,
[256, 512)
512) 1006
1006 |@@@@
|@@@@ ||
[512,
[512, 1K)
1K) 608
608 |@@@
|@@@ ||
[1K,
[1K, 2K)
2K) 362
362 |@|@ ||
[2K,
[2K, 4K)
4K) 57
57 || ||
[4K,
[4K, 8K)
8K) 10
10 || ||
[8K,
[8K, 16K)
16K) 12
12 || ||
[16K,
[16K, 32K)
32K) 13
13 || ||
[32K,
[32K, 64K)
64K) 22 || ||
[64K,
[64K, 128K)
128K) 11 || ||
$$ stap
stap -l
-l 'process.provider("php").mark("*")'
'process.provider("php").mark("*")' -c
-c /usr/bin/php
/usr/bin/php
process("/usr/bin/php").provider("php").mark("compile__file__entry")
process("/usr/bin/php").provider("php").mark("compile__file__entry")
process("/usr/bin/php").provider("php").mark("compile__file__return")
process("/usr/bin/php").provider("php").mark("compile__file__return")
process("/usr/bin/php").provider("php").mark("error")
process("/usr/bin/php").provider("php").mark("error")
process("/usr/bin/php").provider("php").mark("exception__caught")
process("/usr/bin/php").provider("php").mark("exception__caught")
process("/usr/bin/php").provider("php").mark("exception__thrown")
process("/usr/bin/php").provider("php").mark("exception__thrown")
process("/usr/bin/php").provider("php").mark("execute__entry")
process("/usr/bin/php").provider("php").mark("execute__entry")
process("/usr/bin/php").provider("php").mark("execute__return")
process("/usr/bin/php").provider("php").mark("execute__return")
process("/usr/bin/php").provider("php").mark("function__entry")
process("/usr/bin/php").provider("php").mark("function__entry")
process("/usr/bin/php").provider("php").mark("function__return")
process("/usr/bin/php").provider("php").mark("function__return")
process("/usr/bin/php").provider("php").mark("request__shutdown")
process("/usr/bin/php").provider("php").mark("request__shutdown")
process("/usr/bin/php").provider("php").mark("request__startup")
process("/usr/bin/php").provider("php").mark("request__startup")
$$ stap
stap -l
-l 'process("/usr/lib/jvm/java*/jre/lib/amd64/server/libjvm.so").mark("*")'
'process("/usr/lib/jvm/java*/jre/lib/amd64/server/libjvm.so").mark("*")' || wc
wc -l
-l
521
521
$$ sudo
sudo systemctl
systemctl reboot
reboot --firmware-setup
--firmware-setup
probe
probe process("python3").library("libpython3.7m.so.1.0").mark("import__find__load__start")
process("python3").library("libpython3.7m.so.1.0").mark("import__find__load__start") {{
modname
modname == user_string($arg1);
user_string($arg1);
now
now == local_clock_ns()
local_clock_ns()
timing[tid(),
timing[tid(), depths]
depths] == now
now
printf("%*s*
printf("%*s* Importing '%s'
Importing '%s' ...\n",
...\n", 2*depths,
2*depths, "",
"", modname);
modname);
depths++;
depths++;
}}
probe
probe process("python3").library("libpython3.7m.so.1.0").mark("import__find__load__done")
process("python3").library("libpython3.7m.so.1.0").mark("import__find__load__done") {{
modname
modname == user_string($arg1);
user_string($arg1);
found
found == $arg2;
$arg2;
depths--;
depths--;
now
now == local_clock_ns()
local_clock_ns()
dur
dur == now
now -- timing[tid(),
timing[tid(), depths]
depths]
if
if (found)
(found)
printf("%*s+
printf("%*s+ Imported
Imported '%s'
'%s' in
in %ldus\n",
%ldus\n", 2*depths,
2*depths, "",
"", modname,
modname, dur/1000);
dur/1000);
else
else
printf("%*s-
printf("%*s- Failed
Failed '%s'
'%s' in
in %ldus\n",
%ldus\n", 2*depths,
2*depths, "",
"", modname,
modname, dur/1000);
dur/1000);
}}
@ChristianHeimes
[email protected]
[email protected]
https://speakerdeck.com/tiran/
THANK YOU
plus.google.com/+RedHat facebook.com/redhatinc
linkedin.com/company/red-hat twitter.com/RedHat
youtube.com/user/RedHatVideos