Which is better? High cache memory or low cache?

24
2013-08
  • soul

    Which is better? High cache memory or low cache? And what exactly is their difference.

  • Answers
  • William Hilsum

    Always - More the better.

    If you are talking about the CPU cache, Wikipedia says it best -

    A CPU cache is a cache used by the central processing unit of a computer to reduce the average time to access memory. The cache is a smaller, faster memory which stores copies of the data from the most frequently used main memory locations. As long as most memory accesses are cached memory locations, the average latency of memory accesses will be closer to the cache latency than to the latency of main memory.


  • Related Question

    memory - How can I keep a file in Windows 7's cache?
  • netvope

    Sometimes you know better than Windows what files will be re-used later. Suppose you have 8GB of memory, and you use the same 1GB file every hour in an I/O-bound application (which takes 1 second to finish if the file is cached, and 1 minute if not.) Now you process some other 16GB of data that are not going to be re-used. Naturally the frequently used 1GB file will be pushed out of the cache. It would be beneficial if one can tell Windows to keep that 1GB file in memory. (Better yet, it would be great if one can tell Windows not to cache those 16GB of data, but I'm not optimistic that this can be done.)

    The situation is worse for files in network shares: Windows removes files form the cache even if there is free memory. If you immediately re-use a file, it will still be in the cache; but if you close the file and wait for 30 seconds, the cache is gone, and the system will need to re-fetch the file from the remote server. For me this is very noticeable because I'm on a 3 Mbps network link and I work with files that are about 10 MB in size.

    The poor-man's way to keep a file in the cache would be to keep reading the file. Are there any better ways? Are you aware of any programs that do this?

    (If this can be easily done under Linux, please let me know too.)


  • Related Answers
  • Nifle

    Two things comes to mind.

    1. Copy the file to a RamDisk before first use and move it back to file when you are done with it. (QSoft’s RamDisk for $12 was recommended here)
    2. Buy a fast SSD drive and see if that helps (enough)