Linux: echo 3 > /proc/sys/vm/drop_caches takes hours to complete

linuxlinux-kernelnetwork-attached-storagenfs

I have a Thecus N8900 NAS, which is a Linux based file server, providing files via NFS to six clients. For some reason that Thecus support has yet to explain, it runs a script that checks /proc/meminfo every 60 seconds and if the disk cache exceeds 50% of available RAM they do a "echo 3 > /proc/sys/vm/drop_caches" command to flush the cache.

Leaving aside the issue of whether that makes sense or not, the actual "echo 3 > /proc/sys/vm/drop_caches" command can take hours to complete, which seems way too long to me.

The big problem is that when this happens, the load on the machine spikes, as does the disk utilization, making all NFS traffic crawl until the command finally completes, at which point things are responsive again.

The NAS itself has 16 gigs of RAM, 7 drives in a raid6 configuration (plus a hot spare), no drive problems at all (according to S.M.A.R.T. tests).

So the question is: what would cause the drop_caches command to take so long?

Best Answer

Dropping the caches shouldn't take much time at all. Are you sure it's really not returning from that echo command for several hours?

It makes sense that the machine is slower after the caches are dropped, since files that it could previously read from cache now have to be read from disk.