1The following are demonstrations of the hotuser DTrace program. 2 3 4Here, hotuser is run on a test program called "dofuncs", which is hard coded 5to spend half its time in delta(), a third in beta() and a sixth in alpha(). 6 7 # ./hotuser -c ./dofuncs 8 Sampling... Hit Ctrl-C to end. 9 ^C 10 FUNCTION COUNT PCNT 11 dofuncs`alpha 511 16.5% 12 dofuncs`beta 1029 33.3% 13 dofuncs`delta 1552 50.2% 14 15hotuser has accurately sampled which user-level functions are on the CPU, 16producing a report of the expected breakdown. The hottest user-level function 17is delta(), which was sampled 1552 times - 50.2% of the total samples. 18 19 20 21Now hotuser is run on gunzip, to find which functions are most often 22on the CPU, 23 24 # ./hotuser -c 'gunzip contents.gz' 25 Sampling... Hit Ctrl-C to end. 26 27 FUNCTION COUNT PCNT 28 libc.so.1`_free_unlocked 1 0.1% 29 gunzip`unzip 1 0.1% 30 ld.so.1`strcmp 1 0.1% 31 gunzip`inflate_dynamic 1 0.1% 32 libc.so.1`_write 1 0.1% 33 gunzip`write_buf 1 0.1% 34 gunzip`0x2d990 2 0.3% 35 libc.so.1`write 2 0.3% 36 gunzip`0x2d994 2 0.3% 37 ld.so.1`rtld_db_preinit 3 0.4% 38 gunzip`0x2d98c 7 0.9% 39 gunzip`huft_build 9 1.2% 40 libc_psr.so.1`memcpy 138 18.5% 41 gunzip`inflate_codes 233 31.2% 42 gunzip`updcrc 344 46.1% 43 44This shows that updcrc() was sampled 344 times, and 46.1% of the total 45samples. 46 47 48 49A -l option will provide a breakdown on libraries only. hotuser 50is run on gzip to show library usage only, 51 52 # ./hotuser -lc 'gzip contents' 53 Sampling... Hit Ctrl-C to end. 54 55 LIBRARY COUNT PCNT 56 libc.so.1 2 0.0% 57 libc_psr.so.1 37 0.9% 58 gzip 4113 99.1% 59 60This shows that code in the gzip binary itself was on the CPU 99.1% of 61the sample times, with libc_psr.so.1 code on the CPU 0.9% of the time. 62 63 64 65The following shows library usage of mozilla. The pgrep command is used to 66match the most recent PID of mozilla-bin. 67 68 # ./hotuser -lp `pgrep -n mozilla-bin` 69 Sampling... Hit Ctrl-C to end. 70 ^C 71 LIBRARY COUNT PCNT 72 libplds4.so 1 0.1% 73 libappcomps.so 1 0.1% 74 libi18n.so 1 0.1% 75 libuconv.so 1 0.1% 76 libpref.so 1 0.1% 77 libblueprint.so 1 0.1% 78 libz.so.1 2 0.2% 79 libcaps.so 2 0.2% 80 libXrender.so.1 2 0.2% 81 libimglib2.so 2 0.2% 82 libXft.so.2 3 0.3% 83 libCrun.so.1 3 0.3% 84 libdocshell.so 3 0.3% 85 libplc4.so 4 0.4% 86 libgtk-x11-2.0.so.0.400.9 5 0.5% 87 libjsd.so 5 0.5% 88 libX11.so.4 5 0.5% 89 libnecko.so 8 0.9% 90 libwidget_gtk2.so 9 1.0% 91 libgkgfx.so 13 1.4% 92 libglib-2.0.so.0.400.1 14 1.5% 93 libgfx_gtk.so 18 2.0% 94 libnspr4.so 20 2.2% 95 libxpconnect.so 22 2.4% 96 libgdk-x11-2.0.so.0.400.9 23 2.5% 97 libgobject-2.0.so.0.400.1 25 2.7% 98 libhtmlpars.so 27 3.0% 99 libfontconfig.so.1 41 4.5% 100 libxpcom.so 49 5.4% 101 mozilla-bin 55 6.0% 102 libmozjs.so 80 8.8% 103 libc.so.1 115 12.6% 104 libgklayout.so 352 38.6% 105 106This shows that 352 samples found code from libgklayout.so running, which 107was 38.6% of the samples. 108