1

Under Ubuntu, how much performance gain will the RAM disk provide over the normal nvme m.2 SSD? Could you please let us know what is the effective size of extra RAM to get to make RAM disk's performance optimal? Is 32GB a good amount? How do I create and remove RAM disk? Thanks.

  • The net effect of Meltdown and Spectre was only about 2% degradation because the coincided with a kernel upgrade for faster processing. The problem with a RAM disk is it still needs to be written to disk so you don't loose everything if the lights go out. PCIe Gen 3.0 x 4 NVMe SSD is a better investment than RAM disk plus regular SSD. – WinEunuuchs2Unix Apr 25 '18 at 17:44

1 Answers1

0

RAM disks will not make up for losses due to Meltdown/Spectre patching. Those patches do not affect read speed, they instead affect how the processor executes code - there will be no difference from using a ramdisk.

That said, a ramdisk is a very good way of speeding up access to certain important files, often at significant gains over NVMe drives. This affects file load times, and everything dependent on loading files.

Your ramdisk size depends very heavily on what your usecase is, and what you're trying to do. Most programs will load their required resources into RAM anyways, meaning you're likely to not see any gain in already running programs (usually). For example, a ramdisk won't make browsing the Internet any faster. A good idea to determine a ramdisk size is to look at files you use and open very regularly, and then get the total size of that. Double it, and that's your ramdisk size.

Creating the ramdisk is just a couple of simple commands. Assuming you want a 4 GB ramdisk, simply run (as root):

mkdir -p /media/ramdisk
mount -t tmpfs -o size=4096M tmpfs /media/ramdisk

Once created, you can copy your often-accessed files into RAM. If you want to make a persistent ramdisk (that is, a disk that's auto-created at boot), see the above linked thread.

Note that your ramdisk will not persist data through reboots, nor will changes made to files in your ramdisk get written back to your real disk. Both initially loading data to your ramdisk on every boot and saving files off it is completely your responsibility, though you can write scripts/utilities to help you with this.

Kaz Wolfe
  • 34,122
  • 21
  • 114
  • 172
  • Thanks. Usecase is scientific computations and simulations using CUDA and GPU. Will using ramdisk in this case lead to much better performance? After using the ramdisk, how do I get rid of it besides rebooting the computer? In this usecase, is it better to get more RAM, say 64GB, with a 1T HD/SATA III SSD rather than 32GB RAM with 1TB nvme m.2 SSD? Under Ubuntu, is there a limitation on the amount of ramdisk one can make? – lovedrinking Apr 25 '18 at 17:32
  • @lovedrinking For scientific computation, the only use case I can see for a ramdisk is initially loading data (especially if you're iterating over the same set over and over again, and don't want to wait for a disk reload). It will not (reasonably) speed up computation. You can just unmount /media/ramdisk to get rid of it. The only limitation is the amount of RAM you have. – Kaz Wolfe Apr 25 '18 at 17:33
  • Am I correct that even for the initial loading of big data, I still need to copy the data from a real physical drive to ramdisk. The bottleneck is at the speed of the real drive, ramdisk won't help. How about the case in which at each hour, the long simulation that lasts for days saves the partial data. Will having a ramdisk help a lot? Another possible case is the data amount is so big that the physical 32-64GB RAM is insufficient to load all the data at once. So, the simulation needs to read partial data regularly from the storage. In this case, will setting aside some ram as ramdisk help? – lovedrinking Apr 25 '18 at 17:57
  • @lovedrinking Yes, you will need to copy the data from your permanent storage to your ramdisk. Practically, however, this will only be bottlenecked by your drive's read speed. You can store data directly to RAM, but if your power dies, so does all of your data. If your data needs are larger than your RAM, you will need to do it piece by piece. Personally, I advise you just get a fast NVMe drive - the bottleneck here will almost certainly be crunching through all of that data, load times will be more or less irrelevant compared to compute time. – Kaz Wolfe Apr 25 '18 at 18:00