Exercise 2: DNLC, the directory name lookup cache


Exercise 2: DNLC, the directory name lookup cache

If you have discovered the fine art of kernel tuning, then you are already familiar with the directory name lookup cache. The DNLC maintains directory names and information about their vnodes in a cache in memory. The goal of this cache is to reduce actual disk accesses .

On a live system, we use the -s option to the UNIX vmstat command to see what the DNLC hit rate is. Unfortunately, vmstat cannot be run against system crash dump files. The example below is from a live system. The underlined output shows the statistics relating to DNLC performance.

Figure 14-1 Using vmstat to view the DNLC hit rate
 Hiya...  vmstat -s  0 swap ins          0 swap outs          0 pages swapped in          0 pages swapped out     166176 total address trans. faults taken      25476 page ins       5261 page outs      37742 pages paged in      25936 pages paged out      11063 total reclaims      11030 reclaims from free list          0 micro (hat) faults     166176 minor (as) faults      25006 major faults      24725 copy-on-write faults      59393 zero fill page faults     218960 pages examined by the clock daemon         29 revolutions of the clock hand      52878 pages freed by the clock daemon       1103 forks         31 vforks       1108 execs   16624282 cpu context switches   15593437 device interrupts     231838 traps   28941879 system calls  291807 total name lookups (cache hits 90%)   39 toolong  124902 user   cpu      73504 system cpu   10051975 idle   cpu      75699 wait   cpu  Hiya... 

We see from the underlined output that the system is currently experiencing a 90% success rate in utilization of the DNLC. This is good. The kernel has only had 39 encounters of directory names too long (over 14 characters ) to go into the cache. This is also good. But, is this all that we can learn about the DNLC performance? And are we limited to examining DNLC performance on live systems only? Hardly!

Task:

Write an adb macro that provides all the DNLC statistical information. Test your macro on a running system and compare the results to vmstat -s output.

Hints:

Read the dnlc.h header file for guidance.

The vmstat program uses the following section of code to calculate the hit rate.

 nchtotal = ncstats.hits + ncstats.misses + ncstats.long_look;  printf("%9lu total name lookups (cache hits %lu%%)\n", nchtotal,     ncstats.hits * 100 / nchtotal); 

An example of output to aim for:

 #  adb -k -I /mymacros /dev/ksyms /dev/mem  physmem 1e03  $<dnlcstats  **  Directory Name Lookup Cache Statistics  **                  ---------------------------------------------- ncsize:  ncsize:         600             Directory name cache size  ncstats:  ncstats:        347153          # of cache hits that we used  ncstats+4:      34503           # of misses  ncstats+8:      10806           # of enters done  ncstats+0xc:    0               # of enters tried when already cached  ncstats+0x10:   30              # of long names tried to enter  ncstats+0x14:   32              # of long name tried to look up  ncstats+0x18:   0               # of times LRU list was empty  ncstats+0x1c:   1759            # of purges of cache                  90              Hit rate percentage                  (See /usr/include/sys/dnlc.h for more information)  $q  # 


PANIC. UNIX System Crash Dump Analysis Handbook
PANIC! UNIX System Crash Dump Analysis Handbook (Bk/CD-ROM)
ISBN: 0131493868
EAN: 2147483647
Year: 1994
Pages: 289
Authors: Chris Drake

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net