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 | |
| 18 | # ./cachestat 1 |
| 19 | HITS MISSES DIRTIES READ_HIT% WRITE_HIT% BUFFERS_MB CACHED_MB |
| 20 | 0 58 0 0.0% 100.0% 0 11334 |
| 21 | 146113 0 0 100.0% 0.0% 0 11334 |
| 22 | 244143 0 0 100.0% 0.0% 0 11334 |
| 23 | 216833 0 0 100.0% 0.0% 0 11334 |
| 24 | 248209 0 0 100.0% 0.0% 0 11334 |
| 25 | 205825 0 0 100.0% 0.0% 0 11334 |
| 26 | 286654 0 0 100.0% 0.0% 0 11334 |
| 27 | 275850 0 0 100.0% 0.0% 0 11334 |
| 28 | 272883 0 0 100.0% 0.0% 0 11334 |
| 29 | 261633 0 0 100.0% 0.0% 0 11334 |
| 30 | 252826 0 0 100.0% 0.0% 0 11334 |
| 31 | 235253 70 3 100.0% 0.0% 0 11335 |
| 32 | 204946 0 0 100.0% 0.0% 0 11335 |
| 33 | 0 0 0 0.0% 0.0% 0 11335 |
| 34 | 0 0 0 0.0% 0.0% 0 11335 |
| 35 | 0 0 0 0.0% 0.0% 0 11335 |
| 36 | |
| 37 | Above shows the reading of a 12GB file already cached in the OS page cache and again below with timestamps. |
| 38 | |
| 39 | # ./cachestat -T 1 |
| 40 | TIME HITS MISSES DIRTIES READ_HIT% WRITE_HIT% BUFFERS_MB CACHED_MB |
| 41 | 16:07:10 0 0 0 0.0% 0.0% 0 11336 |
| 42 | 16:07:11 0 0 0 0.0% 0.0% 0 11336 |
| 43 | 16:07:12 117849 0 0 100.0% 0.0% 0 11336 |
| 44 | 16:07:13 212558 0 0 100.0% 0.0% 0 11336 |
| 45 | 16:07:14 302559 1 0 100.0% 0.0% 0 11336 |
| 46 | 16:07:15 309230 0 0 100.0% 0.0% 0 11336 |
| 47 | 16:07:16 305701 0 0 100.0% 0.0% 0 11336 |
| 48 | 16:07:17 312754 0 0 100.0% 0.0% 0 11336 |
| 49 | 16:07:18 308406 0 0 100.0% 0.0% 0 11336 |
| 50 | 16:07:19 298185 0 0 100.0% 0.0% 0 11336 |
| 51 | 16:07:20 236128 0 0 100.0% 0.0% 0 11336 |
| 52 | 16:07:21 257616 0 0 100.0% 0.0% 0 11336 |
| 53 | 16:07:22 179792 0 0 100.0% 0.0% 0 11336 |
| 54 | |
| 55 | Command used to generate the activity |
| 56 | # dd if=/root/mnt2/testfile of=/dev/null bs=8192 |
| 57 | 1442795+0 records in |
| 58 | 1442795+0 records out |
| 59 | 11819376640 bytes (12 GB) copied, 3.9301 s, 3.0 GB/s |
| 60 | |
| 61 | Below shows the dirty ratio increasing as we add a file to the page cache |
| 62 | # ./cachestat.py |
| 63 | HITS MISSES DIRTIES READ_HIT% WRITE_HIT% BUFFERS_MB CACHED_MB |
| 64 | 1074 44 13 94.9% 2.9% 1 223 |
| 65 | 2195 170 8 92.5% 6.8% 1 143 |
| 66 | 182 53 56 53.6% 1.3% 1 143 |
| 67 | 62480 40960 20480 40.6% 19.8% 1 223 |
| 68 | 7 2 5 22.2% 22.2% 1 223 |
| 69 | 348 0 0 100.0% 0.0% 1 223 |
| 70 | 0 0 0 0.0% 0.0% 1 223 |
| 71 | 0 0 0 0.0% 0.0% 1 223 |
| 72 | 0 0 0 0.0% 0.0% 1 223 |
| 73 | 0 0 0 0.0% 0.0% 1 223 |
| 74 | |
| 75 | The file copied into page cache was named 80m with a size of 83886080 (83886080/4096) = 20480, this matches what we see under dirties |