1The following is a demonstration of the cpuwalk.d script, 2 3 4cpuwalk.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 24The output above shows that PID 18843, "bash", was sampled on CPU 0 a total 25of 30 times (we sample at 1000 hz). 26 27 28 29The following is a demonstration of running cpuwalk.d with a 5 second 30duration. This is on a 4 CPU server running a multithreaded CPU bound 31application 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 53As we are sampling at 1000 hz, the application cputhread is indeed running 54concurrently across all available CPUs. We measured the applicaiton on 55CPU 0 a total of 4900 times, on CPU 1 a total of 4900 times, etc. As there 56are around 5000 samples per CPU available in this 5 second 1000 hz sample, 57the application is using almost all the CPU capacity in this server well. 58 59 60 61The following is a similar demonstration, this time running a multithreaded 62CPU bound application called "cpuserial" that has a poor use of locking 63such 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 79In the above, we can see that this CPU bound application is not making 80efficient use of the CPU resources available, only reaching 3840 samples 81on CPU 2 out of a potential 5000. This problem was caused by a poor use 82of locks. 83 84 85 86