I have a directory with many files with high access rate. And I need to reduce the cache pressure of this specific directory to prevent other files (like my home directory files) from the pushing out from the filesystem cache. Can I limit filesystem cache for specific directory, or for specific processes or users under Linux ?

  • How are these files accessed? Be as precise as possible. – David Schwartz May 1 '13 at 17:58
  • You're not going to get useful answers if you don't explain precisely how the files are accessed. The solution will be to prevent that access from pushing other things out of cache. How that's done depends on what that access is. – David Schwartz May 2 '13 at 5:15

You can lock a particular directory (or files) into the filesystem cache/VM subsystem by using the vmtouch utility.


Daemonise and lock all files in a /var/app/data into physical memory:

vmtouch -dl /var/app/data
  • That's the opposite of what the OP is asking for. – David Schwartz May 1 '13 at 18:00
  • I dont need caching of partucular direcotory, I need to limit caching the particular directory, to specify how many megabytes of this directory files be in the cache. Or maybe limit the cacheing by process touching this files. – s9gf4ult May 1 '13 at 18:07
  • Think include versus exclude. Include the things that need to be cached (the particular directory) and lock them in cache so that they are not pushed out by insignificant files. – ewwhite May 1 '13 at 18:07
  • I dont have particular directory I need to include in cache, I have a directory which I need to limit. – s9gf4ult May 1 '13 at 18:11
  • @s9gf4ult Why do you want to limit it? – ewwhite May 4 '13 at 4:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.