]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/blob - cddl/contrib/dtracetoolkit/Examples/cpuwalk_example.txt
Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.
[FreeBSD/stable/10.git] / cddl / contrib / dtracetoolkit / Examples / cpuwalk_example.txt
1 The following is a demonstration of the cpuwalk.d script,
2
3
4 cpuwalk.d is not that useful on a single CPU server,
5
6    # cpuwalk.d
7    Sampling... Hit Ctrl-C to end.
8    ^C
9    
10         PID: 18843    CMD: bash
11    
12               value  ------------- Distribution ------------- count
13                 < 0 |                                         0
14                   0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 30
15                   1 |                                         0
16    
17         PID: 8079     CMD: mozilla-bin
18    
19               value  ------------- Distribution ------------- count
20                 < 0 |                                         0
21                   0 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 10
22                   1 |                                         0
23
24 The output above shows that PID 18843, "bash", was sampled on CPU 0 a total
25 of 30 times (we sample at 1000 hz).
26
27
28
29 The following is a demonstration of running cpuwalk.d with a 5 second
30 duration. This is on a 4 CPU server running a multithreaded CPU bound
31 application called "cputhread",
32
33    # cpuwalk.d 5
34    Sampling...
35    
36         PID: 3        CMD: fsflush
37    
38               value  ------------- Distribution ------------- count
39                   1 |                                         0
40                   2 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 30
41                   3 |                                         0
42    
43         PID: 12186    CMD: cputhread
44    
45               value  ------------- Distribution ------------- count
46                 < 0 |                                         0
47                   0 |@@@@@@@@@@                               4900
48                   1 |@@@@@@@@@@                               4900
49                   2 |@@@@@@@@@@                               4860
50                   3 |@@@@@@@@@@                               4890
51                   4 |                                         0
52
53 As we are sampling at 1000 hz, the application cputhread is indeed running
54 concurrently across all available CPUs. We measured the applicaiton on
55 CPU 0 a total of 4900 times, on CPU 1 a total of 4900 times, etc. As there
56 are around 5000 samples per CPU available in this 5 second 1000 hz sample,
57 the application is using almost all the CPU capacity in this server well.
58
59
60
61 The following is a similar demonstration, this time running a multithreaded
62 CPU bound application called "cpuserial" that has a poor use of locking
63 such that the threads "serialise",
64
65
66    # cpuwalk.d 5
67    Sampling...
68    
69         PID: 12194    CMD: cpuserial
70    
71               value  ------------- Distribution ------------- count
72                 < 0 |                                         0
73                   0 |@@@                                      470
74                   1 |@@@@@@                                   920
75                   2 |@@@@@@@@@@@@@@@@@@@@@@@@@                3840
76                   3 |@@@@@@                                   850
77                   4 |                                         0
78
79 In the above, we can see that this CPU bound application is not making
80 efficient use of the CPU resources available, only reaching 3840 samples
81 on CPU 2 out of a potential 5000. This problem was caused by a poor use
82 of locks.
83
84
85