Pages

Showing posts with label drop_caches. Show all posts
Showing posts with label drop_caches. Show all posts

Friday, June 3, 2011

The myth of drop_caches

I will try to clarify the myth about drop_caches.
This along with other settings can be made in the folder: /proc/sys/vm/
First, the files in this directory can be used to tune the operation
of the virtual memory (VM) subsystem of the Linux kernel and also to
write out of dirty data to disk.
About drop_caches we can say that is only one of the options and not only make
causes the kernel to drop clean caches, and entries inodes from memory,
the result causing that memory to become free.
We have three basic options :
  • to free pagecache: echo 1 > /proc/sys/vm/drop_caches
  • to free dentries and inodes: echo 2 > /proc/sys/vm/drop_caches
  • to free pagecache, dentries and inodes: echo 3 > /proc/sys/vm/drop_caches
Note that user should run sync first.
What happens then?
The answer is also simple and clear.
If you drop the cache than the CPU load goes up. This happens because the cache is gone.
Also, available RAM goes up because the cache is empty.
Logical, the performance will suffer because you are not taking advantage of the cache.
Then over time, the caches will fill and this is a good thing if you don't instruct Linux to drop the caches.

In reality, dropping caches has a little positive effect on performance, but in fact, it tends to have a negative effect in long-term.
I hope I have correctly understood and explained, so if you think it is not, I wait for your feedback.