1

I have an ubuntu linux virtual machine here and I think there is no disk cache.

For example this is the output from free -m:

             total       used       free     shared    buffers     cached
Mem:           512         98        413          0          0          0
-/+ buffers/cache:         98        413
Swap:            0          0          0

If I create large files, read large files, read all the files in my home directory (2.2GB of files), I always see 0 for 'buffers', 'cached' and the "buffers/cache" line is always the same as the line above it.

Likewise top and htop both show no disk cache being used.

I tried to drop all the caches with:

echo 3 > /proc/sys/vm/drop_caches

and I get an error of echo: write error: Operation not permitted (even when running as root).

So it looks like the cache is disabled, however I thought it wasn't possible to do that. Is it possible to disable the disk cache? Is there anyway to confirm if I have disk cache or not? Maybe I've just been unlucky and haven't seen any disk cache usage yet.

Note: This is a hosted VPS / virtual machine. Some things are disabled, like swap (that's right I can't swapon, the swapon system call returns EPERM). Is it possible to do that with the disk cache? Is there some way to see if that has been done?

4
  • Can you try "top" or "htop"? Perhaps they show other values? Feb 20, 2011 at 18:53
  • No, they show the same, 0. Feb 20, 2011 at 18:54
  • What hypervisor is this VPS running under? Depending on what it's running, I could see the disk caching layer not being visible to the guest OSes.
    – EEAA
    Feb 20, 2011 at 19:00
  • I'm not sure what hypervisor it's using. I know their client side stuff is "openvz / Virtuozzo" if that helps. Is there some way I could find out? Feb 20, 2011 at 19:02

1 Answer 1

4

Your VPS is running under Virtuozzo/OpenVZ. In this setup, it's not a true fully-segregated VM as would be the case with say Xen or VMware. With OpenVZ and Virtuozzo, there is one single instance of the kernel running (instead of one per VM), and this kernel is responsible for maintaining separation between all of the processes running under the different guest VMs. This includes managing the disk caching layer. Because this function is operating outside of your VM, you don't have any visibility into what your cache looks like.

I'm not sure if this is an issue specifically with your host's implementation of OpenVZ or if it's just a side-affect of how OpenVZ does virtualization.

As an aside, I checked on the one OpenVZ VM I have access to, and wasn't able to see cache info there either. If you need access to this information, I'd recommend moving to a VPS provider that uses Xen or some other real hypervisor.

4
  • Interesting. You said I "don't have any visibility into what you cache looks like", however does that mean I have a disk cache, but can't see it, or I don't have any disk cache? Is there any good way to see if I have disk cache at all? Feb 20, 2011 at 19:19
  • 1
    You very likely have a disk cache, but it's outside of your VM, so you can't see how it's being used, which honestly is probably ok. I manage linux servers for a living and I rarely (if ever) find myself looking to see how much cache is being used by a particular system. It's a kernel feature that's quite mature at this point and for the most part, just does the Right Thing.
    – EEAA
    Feb 20, 2011 at 19:22
  • The main reason I want to see if the disk cache is used is because the machine seems slow, and i want to rule that out Feb 20, 2011 at 19:38
  • I'm nearly 100% certain that cache is being used. It would be foolish for your host to turn that off. Have you checked on disk IO contention? When investigating poor performance, that seems to be the culprit 95% of the time in my experience. Run top and watch the iowait value. Other than that, it's probably something you're going to need to take up with your host - ask what the CPU/memory stats are on the host system. That or just move to a quality VPS host like Linode (long-time customer, very pleased).
    – EEAA
    Feb 20, 2011 at 20:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .