1 The following is a demonstration of the diskhits command.
4 Here we run diskhits on a large file, /extra1/contents with is 46 Mb, and
5 currently hasn't been accessed (so isn't in any cache).
7 While diskhits is running, the file is grep'd in another window. This causes
8 the entire file to be read,
10 # ./diskhits /extra1/contents
11 Tracing... Hit Ctrl-C to end.
15 value ------------- Distribution ------------- count
41 value ------------- Distribution ------------- count
45 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 818
50 Ok, so the file was read evently with each access around 32 to 63 Kb in size,
51 and a total of 46 Mb read. This all makes sense, as it is reading the file
56 Now the same file is grep'd with diskhits running, this time we can see what
57 effect caching the file has made,
59 # ./diskhits /extra1/contents
60 Tracing... Hit Ctrl-C to end.
64 value ------------- Distribution ------------- count
88 value ------------- Distribution ------------- count
90 4 |@@@@@@@@@@@@@@@@@@@@@@@@@ 1137
98 The difference is dramatic. This time only 29 Mb is read, leaving around
99 17 Mb that was read from the cache. The way the file is read differs -
100 in the later half of the file it looks the same, but in the first half there
101 are many more events; oddly enough, this is because the early part of the
102 file is cached more, the extra events are likely to be much smaller in size -
103 as indicated in the difference in the size distribution.
105 It appears that everything less that 4606 Kb has remained in the cache, with
106 zero hits for that range.