1N/AThe following is a demonstration of the diskhits command.
1N/A
1N/A
1N/AHere we run diskhits on a large file, /extra1/contents with is 46 Mb, and
1N/Acurrently hasn't been accessed (so isn't in any cache).
1N/A
1N/AWhile diskhits is running, the file is grep'd in another window. This causes
1N/Athe entire file to be read,
1N/A
1N/A # ./diskhits /extra1/contents
1N/A Tracing... Hit Ctrl-C to end.
1N/A ^C
1N/A Location (KB),
1N/A
1N/A value ------------- Distribution ------------- count
1N/A < 0 | 0
1N/A 0 |@@ 47
1N/A 2303 |@@ 41
1N/A 4606 |@@ 41
1N/A 6909 |@@ 42
1N/A 9212 |@@ 41
1N/A 11515 |@@ 41
1N/A 13818 |@@ 42
1N/A 16121 |@@ 43
1N/A 18424 |@@ 42
1N/A 20727 |@@ 41
1N/A 23030 |@@ 41
1N/A 25333 |@@ 41
1N/A 27636 |@@ 41
1N/A 29939 |@@ 42
1N/A 32242 |@@ 44
1N/A 34545 |@@ 41
1N/A 36848 |@@ 41
1N/A 39151 |@@ 41
1N/A 41454 |@@ 41
1N/A 43757 |@@ 40
1N/A >= 46060 | 0
1N/A
1N/A Size (KB),
1N/A
1N/A value ------------- Distribution ------------- count
1N/A 4 | 0
1N/A 8 | 6
1N/A 16 | 10
1N/A 32 |@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 818
1N/A 64 | 0
1N/A
1N/A Total RW: 46064 KB
1N/A
1N/AOk, so the file was read evently with each access around 32 to 63 Kb in size,
1N/Aand a total of 46 Mb read. This all makes sense, as it is reading the file
1N/Afor the first time.
1N/A
1N/A
1N/A
1N/ANow the same file is grep'd with diskhits running, this time we can see what
1N/Aeffect caching the file has made,
1N/A
1N/A # ./diskhits /extra1/contents
1N/A Tracing... Hit Ctrl-C to end.
1N/A ^C
1N/A Location (KB),
1N/A
1N/A value ------------- Distribution ------------- count
1N/A 2303 | 0
1N/A 4606 | 5
1N/A 6909 |@ 67
1N/A 9212 |@@@@ 170
1N/A 11515 |@@@@@ 216
1N/A 13818 |@@@@@ 224
1N/A 16121 |@@@@@@ 287
1N/A 18424 |@@@@@ 227
1N/A 20727 |@@@ 144
1N/A 23030 |@@ 75
1N/A 25333 |@ 59
1N/A 27636 |@ 42
1N/A 29939 |@ 41
1N/A 32242 |@ 44
1N/A 34545 |@ 41
1N/A 36848 |@ 41
1N/A 39151 |@ 41
1N/A 41454 |@ 41
1N/A 43757 |@ 39
1N/A >= 46060 | 0
1N/A
1N/A Size (KB),
1N/A
1N/A value ------------- Distribution ------------- count
1N/A 2 | 0
1N/A 4 |@@@@@@@@@@@@@@@@@@@@@@@@@ 1137
1N/A 8 |@@@@@ 211
1N/A 16 |@@ 111
1N/A 32 |@@@@@@@@ 345
1N/A 64 | 0
1N/A
1N/A Total RW: 29392 KB
1N/A
1N/AThe difference is dramatic. This time only 29 Mb is read, leaving around
1N/A17 Mb that was read from the cache. The way the file is read differs -
1N/Ain the later half of the file it looks the same, but in the first half there
1N/Aare many more events; oddly enough, this is because the early part of the
1N/Afile is cached more, the extra events are likely to be much smaller in size -
1N/Aas indicated in the difference in the size distribution.
1N/A
1N/AIt appears that everything less that 4606 Kb has remained in the cache, with
1N/Azero hits for that range.
1N/A