Well, I've tried blogging before, running the backend server software myself. Maybe not having to maintain the software/hardware will actually let me think about posting to the blog!

9/15/2007

Tip of the day: drop_caches

OK, so as you know, I'm a systems architect at a service provider. I'm going to start posting tips that I get from various other people, and stuff that I generally don't want to forget and might be useful to other people here. The first in this hopefully regular series is about the drop_caches tunable. It's available in kernel 2.6.16 and above, and exists in /proc/sys/vm. If you echo various values to it, various kernel cache data structures are dropped. This is a non-destructive operation, so if you still see stuff hanging out after it, it's likely that it was dirty cache. Anyhow, on to the values: 1 - drop the pagecache 2 - drop the dentry and inode caches 3 - drop both the dentry and inode caches, as well as the pagecache. Here's an example of the impact on the pagecache by doing this: [root@rugrat ~]# free total used free shared buffers cached Mem: 2060656 1448748 611908 0 239620 649220 -/+ buffers/cache: 559908 1500748 Swap: 4194296 41056 4153240 [root@rugrat ~]# echo 3 > /proc/sys/vm/drop_caches [root@rugrat ~]# free total used free shared buffers cached Mem: 2060656 615108 1445548 0 244 89128 -/+ buffers/cache: 525736 1534920 Swap: 4194296 41056 4153240 Note how the pagecache went from ~650MB to around ~89MB after dropping it. In practicality, you would likely never want to do this. However, if you are performing testing on the machine in question, you likely want to test the efficiency of the hardware ,and not the kernel's caching mechanisms.

Labels: , ,