1*387f9dfdSAndroid Build Coastguard Worker# ./cachetop -h 2*387f9dfdSAndroid Build Coastguard Workerusage: cachetop.py [-h] [interval] 3*387f9dfdSAndroid Build Coastguard Worker 4*387f9dfdSAndroid Build Coastguard Workershow Linux page cache hit/miss statistics including read and write hit % per 5*387f9dfdSAndroid Build Coastguard Workerprocesses in a UI like top. 6*387f9dfdSAndroid Build Coastguard Worker 7*387f9dfdSAndroid Build Coastguard Workerpositional arguments: 8*387f9dfdSAndroid Build Coastguard Worker interval Interval between probes. 9*387f9dfdSAndroid Build Coastguard Worker 10*387f9dfdSAndroid Build Coastguard Workeroptional arguments: 11*387f9dfdSAndroid Build Coastguard Worker -h, --help show this help message and exit 12*387f9dfdSAndroid Build Coastguard Worker 13*387f9dfdSAndroid Build Coastguard Workerexamples: 14*387f9dfdSAndroid Build Coastguard Worker ./cachetop # run with default option of 5 seconds delay 15*387f9dfdSAndroid Build Coastguard Worker ./cachetop 1 # print every second hit/miss stats 16*387f9dfdSAndroid Build Coastguard Worker 17*387f9dfdSAndroid Build Coastguard Worker# ./cachetop 5 18*387f9dfdSAndroid Build Coastguard Worker13:01:01 Buffers MB: 76 / Cached MB: 114 / Sort: HITS / Order: ascending 19*387f9dfdSAndroid Build Coastguard WorkerPID UID CMD HITS MISSES DIRTIES READ_HIT% WRITE_HIT% 20*387f9dfdSAndroid Build Coastguard Worker 1 root systemd 2 0 0 100.0% 0.0% 21*387f9dfdSAndroid Build Coastguard Worker 680 root vminfo 3 4 2 14.3% 42.9% 22*387f9dfdSAndroid Build Coastguard Worker 567 syslog rs:main Q:Reg 10 4 2 57.1% 21.4% 23*387f9dfdSAndroid Build Coastguard Worker 986 root kworker/u2:2 10 2457 4 0.2% 99.5% 24*387f9dfdSAndroid Build Coastguard Worker 988 root kworker/u2:2 10 9 4 31.6% 36.8% 25*387f9dfdSAndroid Build Coastguard Worker 877 vagrant systemd 18 4 2 72.7% 13.6% 26*387f9dfdSAndroid Build Coastguard Worker 983 root python 148 3 143 3.3% 1.3% 27*387f9dfdSAndroid Build Coastguard Worker 981 root strace 419 3 143 65.4% 0.5% 28*387f9dfdSAndroid Build Coastguard Worker 544 messageb dbus-daemon 455 371 454 0.1% 0.4% 29*387f9dfdSAndroid Build Coastguard Worker 243 root jbd2/dm-0-8 457 371 454 0.4% 0.4% 30*387f9dfdSAndroid Build Coastguard Worker 985 root (mount) 560 2457 4 18.4% 81.4% 31*387f9dfdSAndroid Build Coastguard Worker 987 root systemd-udevd 566 9 4 97.7% 1.2% 32*387f9dfdSAndroid Build Coastguard Worker 988 root systemd-cgroups 569 9 4 97.8% 1.2% 33*387f9dfdSAndroid Build Coastguard Worker 986 root modprobe 578 9 4 97.8% 1.2% 34*387f9dfdSAndroid Build Coastguard Worker 287 root systemd-journal 598 371 454 14.9% 0.3% 35*387f9dfdSAndroid Build Coastguard Worker 985 root mount 692 2457 4 21.8% 78.0% 36*387f9dfdSAndroid Build Coastguard Worker 984 vagrant find 9529 2457 4 79.5% 20.5% 37*387f9dfdSAndroid Build Coastguard Worker 38*387f9dfdSAndroid Build Coastguard WorkerAbove shows the run of `find /` on a newly booted system. 39*387f9dfdSAndroid Build Coastguard Worker 40*387f9dfdSAndroid Build Coastguard WorkerCommand used to generate the activity 41*387f9dfdSAndroid Build Coastguard Worker# find / 42*387f9dfdSAndroid Build Coastguard Worker 43*387f9dfdSAndroid Build Coastguard WorkerBelow shows the hit rate increases as we run find a second time and it gets it 44*387f9dfdSAndroid Build Coastguard Workerits pages from the cache. 45*387f9dfdSAndroid Build Coastguard Worker# ./cachetop.py 46*387f9dfdSAndroid Build Coastguard Worker13:01:01 Buffers MB: 76 / Cached MB: 115 / Sort: HITS / Order: ascending 47*387f9dfdSAndroid Build Coastguard WorkerPID UID CMD HITS MISSES DIRTIES READ_HIT% WRITE_HIT% 48*387f9dfdSAndroid Build Coastguard Worker 544 messageb dbus-daemon 2 2 1 25.0% 50.0% 49*387f9dfdSAndroid Build Coastguard Worker 680 root vminfo 2 2 1 25.0% 50.0% 50*387f9dfdSAndroid Build Coastguard Worker 243 root jbd2/dm-0-8 3 2 1 40.0% 40.0% 51*387f9dfdSAndroid Build Coastguard Worker 1068 root python 5 0 0 100.0% 0.0% 52*387f9dfdSAndroid Build Coastguard Worker 1071 vagrant bash 350 0 0 100.0% 0.0% 53*387f9dfdSAndroid Build Coastguard Worker 1071 vagrant find 12959 0 0 100.0% 0.0% 54*387f9dfdSAndroid Build Coastguard Worker 55*387f9dfdSAndroid Build Coastguard Worker 56*387f9dfdSAndroid Build Coastguard WorkerBelow shows that the dirty pages increases as a file of 80M is created running 57*387f9dfdSAndroid Build Coastguard Worker# dd if=/dev/urandom of=/tmp/c bs=8192 count=10000 58*387f9dfdSAndroid Build Coastguard Worker 59*387f9dfdSAndroid Build Coastguard Worker# ./cachetop.py 10 60*387f9dfdSAndroid Build Coastguard Worker13:01:01 Buffers MB: 77 / Cached MB: 193 / Sort: HITS / Order: ascending 61*387f9dfdSAndroid Build Coastguard WorkerPID UID CMD HITS MISSES DIRTIES READ_HIT% WRITE_HIT% 62*387f9dfdSAndroid Build Coastguard Worker 544 messageb dbus-daemon 9 10 7 10.5% 15.8% 63*387f9dfdSAndroid Build Coastguard Worker 680 root vminfo 9 10 7 10.5% 15.8% 64*387f9dfdSAndroid Build Coastguard Worker 1109 root python 22 0 0 100.0% 0.0% 65*387f9dfdSAndroid Build Coastguard Worker 243 root jbd2/dm-0-8 25 10 7 51.4% 8.6% 66*387f9dfdSAndroid Build Coastguard Worker 1070 root kworker/u2:2 85 0 0 100.0% 0.0% 67*387f9dfdSAndroid Build Coastguard Worker 1110 vagrant bash 366 0 0 100.0% 0.0% 68*387f9dfdSAndroid Build Coastguard Worker 1110 vagrant dd 42183 40000 20000 27.0% 24.3% 69*387f9dfdSAndroid Build Coastguard Worker 70*387f9dfdSAndroid Build Coastguard WorkerThe file copied into page cache was named /tmp/c with a size of 81920000 (81920000/4096) = 20000 71