unixtest | 57abe5b | 2016-01-31 10:47:03 +0000 | [diff] [blame] | 1 | # ./cachestat -h |
| 2 | USAGE: ./cachestat [-T] [ interval [count] ] |
| 3 | |
| 4 | show Linux page cache hit/miss statistics including read and write hit % |
| 5 | |
| 6 | optional arguments: |
| 7 | -T include timestamp on output |
| 8 | |
| 9 | examples: |
| 10 | ./cachestat # run with default option of 5 seconds delay |
| 11 | ./cachestat -T # run with default option of 5 seconds delay with timestamps |
| 12 | ./cachestat 1 # print every second hit/miss stats |
| 13 | ./cachestat -T 1 # include timestamps with one second samples |
| 14 | ./cachestat 1 5 # run with interval of one second for five iterations |
| 15 | ./cachestat -T 1 5 # include timestamps with interval of one second for five iterations |
| 16 | |
| 17 | |
Joel Fernandes | 2b34870 | 2018-02-27 20:38:42 -0800 | [diff] [blame] | 18 | Following commands show a 2GB file being read into the page cache. |
unixtest | 57abe5b | 2016-01-31 10:47:03 +0000 | [diff] [blame] | 19 | |
Joel Fernandes | 2b34870 | 2018-02-27 20:38:42 -0800 | [diff] [blame] | 20 | Command used to generate activity: |
| 21 | # dd if=/root/tmpfile of=/dev/null bs=8192 |
unixtest | 57abe5b | 2016-01-31 10:47:03 +0000 | [diff] [blame] | 22 | |
Joel Fernandes | 2b34870 | 2018-02-27 20:38:42 -0800 | [diff] [blame] | 23 | Output from cachestat running simultatenously: |
| 24 | # ./tools/cachestat.py 1 |
| 25 | TOTAL MISSES HITS DIRTIES BUFFERS_MB CACHED_MB |
| 26 | 1 0 1 0 8 283 |
| 27 | 0 0 0 0 8 283 |
| 28 | 0 0 0 2 8 283 |
| 29 | 0 0 0 0 8 283 |
| 30 | 10009 9173 836 2 9 369 |
| 31 | 152032 152032 0 0 9 1028 |
| 32 | 157408 157405 3 0 9 1707 |
| 33 | 150432 150432 0 0 9 2331 |
| 34 | 0 0 0 0 9 2331 |
| 35 | 1 1 0 1 9 2331 |
| 36 | 0 0 0 0 9 2331 |
| 37 | 0 0 0 0 9 2331 |
| 38 | 0 0 0 0 9 2331 |
unixtest | 57abe5b | 2016-01-31 10:47:03 +0000 | [diff] [blame] | 39 | |
Joel Fernandes | 2b34870 | 2018-02-27 20:38:42 -0800 | [diff] [blame] | 40 | The misses counter reflects a 2GB file being read and almost everything being |
| 41 | a page cache miss. |
unixtest | 57abe5b | 2016-01-31 10:47:03 +0000 | [diff] [blame] | 42 | |
Joel Fernandes | 2b34870 | 2018-02-27 20:38:42 -0800 | [diff] [blame] | 43 | Below shows an example of a new 100MB file added to page cache, by using |
| 44 | the command: dd if=/dev/zero of=/root/tmpfile2 bs=4k count=$((256*100)) |
unixtest | 57abe5b | 2016-01-31 10:47:03 +0000 | [diff] [blame] | 45 | |
Joel Fernandes | 2b34870 | 2018-02-27 20:38:42 -0800 | [diff] [blame] | 46 | # ./tools/cachestat.py 1 |
| 47 | TOTAL MISSES HITS DIRTIES BUFFERS_MB CACHED_MB |
| 48 | 0 0 0 0 15 2440 |
| 49 | 0 0 0 0 15 2440 |
| 50 | 0 0 0 0 15 2440 |
| 51 | 1758 0 1758 25603 15 2540 |
| 52 | 0 0 0 0 15 2540 |
| 53 | 0 0 0 0 15 2541 |
| 54 | |
| 55 | ~25600 pages are being dirtied (writes) which corresponds to the 100MB file |
| 56 | added to the page cache. |