Brendan Gregg | 6af7b84 | 2019-02-02 12:45:23 -0800 | [diff] [blame] | 1 | Demonstrations of cachestat, the Linux eBPF/bcc version. |
unixtest | 57abe5b | 2016-01-31 10:47:03 +0000 | [diff] [blame] | 2 | |
Brendan Gregg | 6af7b84 | 2019-02-02 12:45:23 -0800 | [diff] [blame] | 3 | |
| 4 | cachestat shows hits and misses to the file system page cache. For example: |
| 5 | |
| 6 | # cachestat |
| 7 | HITS MISSES DIRTIES HITRATIO BUFFERS_MB CACHED_MB |
| 8 | 1132 0 4 100.00% 277 4367 |
| 9 | 161 0 36 100.00% 277 4372 |
| 10 | 16 0 28 100.00% 277 4372 |
| 11 | 17154 13750 15 55.51% 277 4422 |
| 12 | 19 0 1 100.00% 277 4422 |
| 13 | 83 0 83 100.00% 277 4421 |
| 14 | 16 0 1 100.00% 277 4423 |
| 15 | ^C 0 -19 360 0.00% 277 4423 |
| 16 | Detaching... |
| 17 | |
| 18 | While tracing, there was a burst of misses in the fourth second, bringing |
| 19 | the hit ration down to 55%. |
| 20 | |
| 21 | |
| 22 | This shows a 1 Gbyte uncached file that is read twice: |
| 23 | |
| 24 | (root) ~ # ./cachestat.py |
| 25 | HITS MISSES DIRTIES HITRATIO BUFFERS_MB CACHED_MB |
| 26 | 1 0 0 100.00% 5 191 |
| 27 | 198 12136 0 1.61% 5 238 |
| 28 | 1 11007 3 0.01% 5 281 |
| 29 | 0 6384 0 0.00% 5 306 |
| 30 | 1 14464 0 0.01% 5 363 |
| 31 | 0 11776 0 0.00% 5 409 |
| 32 | 1 11712 0 0.01% 5 454 |
| 33 | 32 13184 0 0.24% 5 506 |
| 34 | 0 11232 0 0.00% 5 550 |
| 35 | 1 13056 0 0.01% 5 601 |
| 36 | 16 14720 0 0.11% 5 658 |
| 37 | 33 9920 0 0.33% 5 697 |
| 38 | 0 13248 0 0.00% 5 749 |
| 39 | 4 14144 0 0.03% 5 804 |
| 40 | 0 9728 0 0.00% 5 842 |
| 41 | 1 10816 0 0.01% 5 885 |
| 42 | 808 13504 1 5.65% 5 938 |
| 43 | 0 11409 0 0.00% 5 982 |
| 44 | 0 11520 0 0.00% 5 1027 |
| 45 | 0 15616 0 0.00% 5 1088 |
| 46 | 1 9792 0 0.01% 5 1126 |
| 47 | 0 8256 0 0.00% 5 1158 |
| 48 | 1 9600 0 0.01% 5 1196 |
| 49 | 599 4804 0 11.09% 5 1215 |
| 50 | 1 0 0 100.00% 5 1215 |
| 51 | 0 0 0 0.00% 5 1215 |
| 52 | 3 1 0 75.00% 5 1215 |
| 53 | 79536 34 0 99.96% 5 1215 |
| 54 | 87693 274 4 99.69% 6 1214 |
| 55 | 89018 3546 0 96.17% 7 1227 |
| 56 | 33531 201 4 99.40% 7 1228 |
| 57 | 22 44 0 33.33% 8 1228 |
| 58 | 0 0 0 0.00% 8 1228 |
| 59 | 73 21 2 77.66% 8 1228 |
| 60 | |
| 61 | It took 24 seconds to read the 1 Gbyte file the first time, shown in the output |
| 62 | by the high MISSES rate and low HITRATIO. The second time it took 4 seconds, |
| 63 | and the HITRATIO was around 99%. |
| 64 | |
| 65 | |
| 66 | This output shows a 1 Gbyte file being created and added to the page cache: |
| 67 | |
| 68 | (root) ~ # ./cachestat.py |
| 69 | HITS MISSES DIRTIES HITRATIO BUFFERS_MB CACHED_MB |
| 70 | 1 0 0 100.00% 8 209 |
| 71 | 0 0 165584 0.00% 8 856 |
| 72 | 0 0 96505 0.00% 8 1233 |
| 73 | 0 0 0 0.00% 8 1233 |
| 74 | |
Hang Yan | 1b64fd1 | 2021-07-02 20:46:59 +0800 | [diff] [blame] | 75 | Note the high rate of DIRTIES, and the CACHED_MB size increases by 1024 Mbytes. |
Brendan Gregg | 6af7b84 | 2019-02-02 12:45:23 -0800 | [diff] [blame] | 76 | |
| 77 | |
| 78 | USAGE message: |
| 79 | |
| 80 | # cachestat -h |
| 81 | usage: cachestat.py [-h] [-T] [interval] [count] |
| 82 | |
| 83 | Count cache kernel function calls |
| 84 | |
| 85 | positional arguments: |
| 86 | interval output interval, in seconds |
| 87 | count number of outputs |
unixtest | 57abe5b | 2016-01-31 10:47:03 +0000 | [diff] [blame] | 88 | |
| 89 | optional arguments: |
Brendan Gregg | 6af7b84 | 2019-02-02 12:45:23 -0800 | [diff] [blame] | 90 | -h, --help show this help message and exit |
| 91 | -T, --timestamp include timestamp on output |