hoytech / vmtouch

Portable file system cache diagnostics and control
https://hoytech.com/vmtouch/
BSD 3-Clause "New" or "Revised" License
1.79k stars 210 forks source link

Print only file names that are (partly) cached #68

Open crazy4chrissi opened 6 years ago

crazy4chrissi commented 6 years ago

I would like to see a parameter that prints the same as -v, just without all the files that are not cached at all i.e. that say 0/x. When I have a folder with 1000 files and only 5 pages cached, I want to find out which files are cached.

Edit: Basically, the same as this:

vmtouch -v /bin/ | grep '\[.*O.*\]' --before-context=1

Okay, so grepping is easy, so maybe no extra option is necessary.

crazy4chrissi commented 6 years ago

This is also really useful:

vmtouch -vf . | grep '\[.*O.*\]' --before-context=1 | grep '^\.' It prints the list of currently (partly) cached files in the current folder. You can write this into a file cached: vmtouch -vf . | grep '\[.*O.*\]' --before-context=1 | grep '^\.' > cached and enforce that these files remain cached: vmtouch -d -l -b cached

hoytech commented 6 years ago

Thanks for the feature suggestion and the command-line workaround. I'm not opposed to adding a switch or option to implement this functionality either.

Ideally there would be a more machine-friendly output for vmtouch that is easier to post-process, I think there is a ticket or TODO item for that also.

crazy4chrissi commented 6 years ago

I think it may be very useful to have a vmtouch parameter that enforces caching of the currently cached files of a given folder. For example, I don't want to enforce caching of my entire /usr/lib, which is about 1,4 GiB and contains lots of libraries almost never used. But I like to enforce caching the 170 MiB currently cached. This is useful for me, as some WordPress sites hosted on my server have plugins that do huge backups. I cannot really make sure these don't get cached. So these backups pollute the page cache and sometimes, even frequently used libraries get thrown out. vmtouch helps me a lot to keep the most important stuff inside the page cache. Thanks a lot for that.

hoytech commented 6 years ago

I like this idea too. I think it is possible with vmprobe but I agree would be a great feature to have in vmtouch as well.