NOCACHE(1)

πŸ“¦
version 1.2 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

πŸ’– NOCACHE πŸ’–

okay bestie, so this is nocache, from section 1 of the manual (you know, the "just run it in your shell" section ✨). It does exactly what it says on the tin: it stops a command from trashing your Linux page cache. Your filesystem will literally thank you. 🫢


🌸 NAME 🌸

nocache β€” don't use Linux page cache on given command. periodt. πŸ’…


✨ SYNOPSIS ✨

nocache [-n <n>] command [argument...]

πŸŽ€ OPTIONS πŸŽ€

  • -n <n> "Set number of fadvise calls" β€” this makes it run the posix_fadvise system call <n> times back to back, in a row, no breaks. Depending on your machine this might give better results β€” so use it if in your tests nocache fails to eradicate pages from cache properly. (yeah, sometimes one fadvise just isn't enough, she needs to be told <n> times. iconic honestly. πŸ’€)

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea β˜• β€” nocache tries to minimize the effect an application has on the Linux file system cache. The way it does this is by intercepting the open and close system calls and calling posix_fadvise with the POSIX_FADV_DONTNEED parameter. slay. πŸ”₯

and the reason it remembers stuff is: the library remembers which pages (ie., 4K-blocks of the file) were already in file system cache when the file was opened. Those ones will not be marked as "don't need", because other applications might need that, even though they are not actively used (think: hot standby). so it's not out here evicting your friend's stuff. it's giving considerate. 🌈


🌟 ALTERNATIVE: HOW TO USE CGROUPS TO RESTRICT CACHE USE 🌟

if your use case is a backup process that should not interfere with the present state of the cache too much, lowkey consider using cgroups instead. They're much cleaner and carry less overhead than this tool. no cap. ✨

for example, if your system uses systemd, you can do:

systemd-run --scope --property=MemoryLimit=500M -- backup command

for more info, see the README on https://github.com/Feh/nocache πŸ‘‘


🫢 little reminder bestie: cgroups are the cleaner, lighter-overhead option when it's a backup process that shouldn't be messing with the current state of the cache too much. nocache is still the moment for everything else tho. πŸ’–

and that's the whole page!! this one's nocache, in the NOCACHE(1) manual, from March 2013 β€” go forth and keep your cache clean, main character. πŸŽ€πŸŒΈπŸ’…

πŸ“¦ where this page comes from