The following is a demonstration of the diskhits command.


Here we run diskhits on a large file, /extra1/contents with is 46 Mb, and
currently hasn't been accessed (so isn't in any cache).

While diskhits is running, the file is grep'd in another window. This causes
the entire file to be read,

   # ./diskhits /extra1/contents
   Tracing... Hit Ctrl-C to end.
   ^C
   Location (KB),
   
              value  ------------- Distribution ------------- count    
                < 0 |                                         0        
                  0 |@@                                       47       
               2303 |@@                                       41       
               4606 |@@                                       41       
               6909 |@@                                       42       
               9212 |@@                                       41       
              11515 |@@                                       41       
              13818 |@@                                       42       
              16121 |@@                                       43       
              18424 |@@                                       42       
              20727 |@@                                       41       
              23030 |@@                                       41       
              25333 |@@                                       41       
              27636 |@@                                       41       
              29939 |@@                                       42       
              32242 |@@                                       44       
              34545 |@@                                       41       
              36848 |@@                                       41       
              39151 |@@                                       41       
              41454 |@@                                       41       
              43757 |@@                                       40       
           >= 46060 |                                         0        
   
   Size (KB),
   
              value  ------------- Distribution ------------- count    
               4 |                                         0        
                  8 |                                         6        
                 16 |                                         10       
                 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@  818      
                 64 |                                         0        
   
   Total RW: 46064 KB

Ok, so the file was read evently with each access around 32 to 63 Kb in size,
and a total of 46 Mb read. This all makes sense, as it is reading the file
for the first time.



Now the same file is grep'd with diskhits running, this time we can see what
effect caching the file has made,

   # ./diskhits /extra1/contents
   Tracing... Hit Ctrl-C to end.
   ^C
   Location (KB),
   
              value  ------------- Distribution ------------- count    
               2303 |                                         0        
               4606 |                                         5        
               6909 |@                                        67       
               9212 |@@@@                                     170      
              11515 |@@@@@                                    216      
              13818 |@@@@@                                    224      
              16121 |@@@@@@                                   287      
              18424 |@@@@@                                    227      
              20727 |@@@                                      144      
              23030 |@@                                       75       
              25333 |@                                        59       
              27636 |@                                        42       
              29939 |@                                        41       
              32242 |@                                        44       
              34545 |@                                        41       
              36848 |@                                        41       
              39151 |@                                        41       
              41454 |@                                        41       
              43757 |@                                        39       
           >= 46060 |                                         0        
   
   Size (KB),
   
              value  ------------- Distribution ------------- count    
                  2 |                                         0        
                  4 |@@@@@@@@@@@@@@@@@@@@@@@@@                1137     
                  8 |@@@@@                                    211      
                 16 |@@                                       111      
                 32 |@@@@@@@@                                 345      
                 64 |                                         0        
   
   Total RW: 29392 KB

The difference is dramatic. This time only 29 Mb is read, leaving around 
17 Mb that was read from the cache. The way the file is read differs - 
in the later half of the file it looks the same, but in the first half there
are many more events; oddly enough, this is because the early part of the 
file is cached more, the extra events are likely to be much smaller in size -
as indicated in the difference in the size distribution.

It appears that everything less that 4606 Kb has remained in the cache, with 
zero hits for that range.

