4

OK, before you mark my thread a duplicate I want to say, that I know this very good answer: How do I clean or disable the memory cache?
But this is not case for me.

I am making some performance tests between in-memory application and disk-using application. So I want to have guarantee, that every time application tries to fetch something from disk, system really fetches this from disk, not from memory cache. (I want to have performance factor, by how much worse application operates, when it has to read from disk.)
I know, that I can clean cache by sync && echo 3 > /proc/sys/vm/drop_caches command, but cleaning every minute by cron is to slow for me, because cache is getting filled very quickly again.

So I have a question: Can't you really disable this feature? Or maybe go around it? It really can mess up my tests results.

PS: I am using Ubuntu 12.04 64-bit.

1 Answers1

0

You can disable it with hdparm, open your text editor and edit the /etc/hdparm.conf and uncomment the "write_cache = off" line. Reboot, to check if it worked, type sudo hdparm -i /dev/sdX ( use your drive leter ), and check the AdvancedPM line, in the end says the state of the write cache.

EDIT: you can check the hdparm -i /dev/sdX to see how is the write_cache option before changing.

EDIT2: use -o sync when mounting a partition to avoid writing the cache, I don't know about the reading part.

fpinto
  • 96