1 Tested on Fedora25 4.11.3-200.fc25.x86_64, gcc (GCC) 6.3.1 20161221 (Red Hat 6.3.1-1)
3 As an alternative to using ...bcc/tests/python/include/folly/tracing/StaticTracepoint.h,
4 it's possible to use systemtap-sdt-devel.
5 However, this is *not* required for this sample.
7 $ sudo dnf install systemtap-sdt-devel # For Fedora25, other distro's might have differently named packages.
10 If using systemtap-sdt-devel, the following commands can be used to generate the corresponding header and object files:
11 Also see the CMakeLists.txt file for an example how to do this using cmake.
13 $ dtrace -h -s usdt_sample_lib1/src/lib1_sdt.d -o usdt_sample_lib1/include/usdt_sample_lib1/lib1_sdt.h
14 $ dtrace -G -s usdt_sample_lib1/src/lib1_sdt.d -o lib1_sdt.o
21 $ mkdir -p examples/usdt_sample/build && pushd examples/usdt_sample/build
26 After building, you should see the available probes:
28 $ python tools/tplist.py -l examples/usdt_sample/build/usdt_sample_lib1/libusdt_sample_lib1.so
29 examples/usdt_sample/build/usdt_sample_lib1/libusdt_sample_lib1.so usdt_sample_lib1:operation_end
30 examples/usdt_sample/build/usdt_sample_lib1/libusdt_sample_lib1.so usdt_sample_lib1:operation_start
31 $ readelf -n examples/usdt_sample/build/usdt_sample_lib1/libusdt_sample_lib1.so
33 Displaying notes found at file offset 0x000001c8 with length 0x00000024:
34 Owner Data size Description
35 GNU 0x00000014 NT_GNU_BUILD_ID (unique build ID bitstring)
36 Build ID: 3930c19f654990159563394669f2ed5281513302
38 Displaying notes found at file offset 0x0001b9ec with length 0x000000c0:
39 Owner Data size Description
40 stapsdt 0x00000047 NT_STAPSDT (SystemTap probe descriptors)
41 Provider: usdt_sample_lib1
43 Location: 0x000000000000ed6d, Base: 0x0000000000000000, Semaphore: 0x0000000000000000
44 Arguments: -8@%rbx -8@%rax
45 stapsdt 0x0000004e NT_STAPSDT (SystemTap probe descriptors)
46 Provider: usdt_sample_lib1
48 Location: 0x000000000000ee2c, Base: 0x0000000000000000, Semaphore: 0x0000000000000000
49 Arguments: -8@-24(%rbp) -8@%rax
52 Start the usdt sample application:
54 $ examples/usdt_sample/build/usdt_sample_app1/usdt_sample_app1 "pf" 1 30 10 1 50
55 Applying the following parameters:
59 Latency range: [1, 50] ms.
60 You can now run the bcc scripts, see usdt_sample.md for examples.
65 Use argdist.py on the individual probes:
67 $ sudo python tools/argdist.py -p 25433 -i 5 -C 'u:usdt_sample_lib1:operation_start():char*:arg2#input' -z 32
98 Use latency.py to trace the operation latencies:
100 $ sudo python examples/usdt_sample/scripts/latency.py -p=25433 -f="pf_2"
101 Attaching probes to pid 25433
102 Tracing... Hit Ctrl-C to end.
103 time(s) id input output start (ns) end (ns) duration (us)
104 0.000000000 7204 pf_28 resp_pf_28 11949439999644 11949489234565 49234
105 0.100211886 7205 pf_28 resp_pf_28 11949540211530 11949574403064 34191
106 0.300586675 7207 pf_21 resp_pf_21 11949740586319 11949742773571 2187
107 0.400774366 7208 pf_28 resp_pf_28 11949840774010 11949859965498 19191
108 0.701365719 7211 pf_21 resp_pf_21 11950141365363 11950152551131 11185
109 0.901736620 7213 pf_25 resp_pf_25 11950341736264 11950347924333 6188
110 1.102162217 7215 pf_21 resp_pf_21 11950542161861 11950567484183 25322
111 1.302595998 7217 pf_23 resp_pf_23 11950742595642 11950761841242 19245
112 1.503047601 7219 pf_2 resp_pf_2 11950943047245 11950951213474 8166
113 1.703371457 7221 pf_27 resp_pf_27 11951143371101 11951176568051 33196
114 2.104228899 7225 pf_24 resp_pf_24 11951544228543 11951588432769 44204
115 2.304608175 7227 pf_21 resp_pf_21 11951744607819 11951790796068 46188
116 2.404796703 7228 pf_21 resp_pf_21 11951844796347 11951877984160 33187
117 2.605134923 7230 pf_27 resp_pf_27 11952045134567 11952065327660 20193
118 3.206291642 7236 pf_29 resp_pf_29 11952646291286 11952660443343 14152
119 3.506887492 7239 pf_21 resp_pf_21 11952946887136 11952995060987 48173
122 Use lat_dist.py to trace the latency distribution:
124 $ sudo python examples/usdt_sample/scripts/lat_dist.py -p=25433 -i=30 -f="pf_20"
125 Attaching probes to pid 25433
129 latency (us) : count distribution
140 1024 -> 2047 : 1 |********** |
141 2048 -> 4095 : 1 |********** |
143 8192 -> 16383 : 1 |********** |
144 16384 -> 32767 : 4 |****************************************|
145 32768 -> 65535 : 3 |****************************** |
148 Use lat_avg.py to trace the moving average of the latencies:
150 $ sudo python examples/usdt_sample/scripts/lat_avg.py -p=25433 -i=5 -c=10 -f="pf_2"
151 Attaching probes to pid 25433
152 Tracing... Hit Ctrl-C to end.
154 input count latency (us)