I am executing some benchmark using a DBMS and virtual machines. And I am using this command
free && sync && echo 3 > /proc/sys/vm/drop_caches && free
on each Guest, and on each Host, before executing a query, to minimize the effect of cache/buffering on my execution time. If the data is cached/buffered the execution time for a query may vary depending on what query was executed before, because a part of the file used to answer the query might be in memory.
I saw this post: How do you empty the buffers and cache on a Linux system?
But for me it's a little tricky to execute sync/drop caches after each query. I need to ask for every VM and for every physical server to sync/drop caches. I could write a script, and use SSH to do this, but I wonder if there's a way to keep the OS from buffering/caching the files because it would be easier for me.
I am using Ubuntu 12.04 on all the VMs (using KVM) and servers.
sync
fixes the problem, then they aren't due to caching, but to buffering.