• BasicTraveler
      link
      fedilink
      21 year ago

      Not really, you can get all the same benefits with adding extra memory without having to deal with setting up and managing a massive RAM drive.

      When a program or the OS itself needs to read data from the disk, it does a disk read operation. Before reading the data directly from the disk, the OS checks if the requested data is already present in its cache. If the data is found in the cache (a cache hit), the OS can retrieve it quickly from the RAM, avoiding the slower disk access. If the data is not present in the cache (a cache miss), the OS reads it from the disk and also stores a copy in the cache for future use. If the cache is already full, the OS needs to make space for newly read data. There are various strategies for what data to evict, but something will be bumped out of the disk cache, it’s fast, but not free. The data stays in disk cache until it gets evicted to make space for something else. If you have enough memory, nothing needs to be evicted so even if the game unloads assets, the files on disk are still cached and can be accessed without loading from the physical disk.

      So point being, if you have enough memory, after the data is read once, it’s going to stick around in memory and be access just as fast, and maybe a little faster than a RAM drive. Why maybe a little faster? A RAM disk is effectively double caching the data, once in the RAM disk and once in the disk cache so you need twice as much memory to not have cache misses. Imagine a game that has 10 GB of data on disk, lets ignore the memory it takes to run the game, os, etc, just think about that 10 GB of game data, disk cache, and RAM drive.

      Say you have 16 GB of memory. 10 GB of that will need to be made into a RAM drive, so we have 6 GB left for disk cache. When you’re playing the game, it’s going to try and access that 10 GB of game data, it’s first going to look in the disk cache. The cache is only 6 GB, so the game can’t fit entirely, sometimes the data will be cached, sometimes it’s not. When it’s not, it’s going to go through a few extra steps to remove something and fetch the requested data from the RAM drive. The data eventually gets loaded from RAM, but with a few extra steps. Now without the RAM drive, there would be 16 GB of disk cache, the game will fit entirely. Once it’s all loaded, no more disk access, it’s all in memory.

      • tal
        link
        fedilink
        11 year ago

        If I recall correctly, the current Linux RAM disk implementation uses the paging/caching backend anyway. Just doesn’t let it be purged from memory.

        • @Difficult_Bit_1339
          link
          English
          21 year ago

          Yeah. I use Tempfs for compiling because it gives me a lot more IO.

          It’d take some pretty simple scripting to create a tempfs and copy game files into it prior to launching the game. You’d have to dig a bit into each game to ensure that you’re not loading any directories or files that store permanent data but it wouldn’t be too hard.