0

I am well aware on how to drop (e.g. /sbin/sysctl vm.drop_caches=3 ) caches in Linux, but for benchmarking I'd like to do the reverse, fill up the caches up to 100% RAM if possible. How would I do that pragmatically?

4
  • 5
    Try just reading all the bits in the file system until cache usage seems to high water-mark: find / -type f -exec md5sum {} \;
    – MadHatter
    Aug 29 '13 at 10:11
  • 2
    -exec cat {} >>/dev/null would use less CPU
    – symcbean
    Aug 29 '13 at 10:17
  • Grumble. Not only are you a CPU cheapskate, you're right, as well.
    – MadHatter
    Aug 29 '13 at 10:29
  • 1
    Why are you commenting instead of clicking answer button to give a proper answer I can mark up as the right one? =)
    – Dima
    Aug 29 '13 at 11:49
0

Do you want to fill cache or do you want to cache specific data?

The system automatically will fill cache as the system is used, filling it with whatever is needed, and expire those pages as it becomes more useful to either cache something else or use the memory as part of an active process.

If you want to cache specific data so it is in ram ready for fast use, the act of reading it from disk once is normally enough, assuming it doesn't get pushed out of cache by something else before you need it again.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.