Question I'm stuck and confused on why my ramdisk is slower than my nvme ssd using DDR5 ram.

ZachTheDoggo

Prominent
Oct 29, 2022
3
0
510
I'm curious if it is possible to achieve above nvme similar speeds on a ramdisk using Linux's ramfs file system moving and transferring files from one ramdisk to another? I have tried and I haven't got great results, and in some cases are worse than my nvme ssd.

If possible what tweaks or suggestions to make it faster could I deploy?
 

ZachTheDoggo

Prominent
Oct 29, 2022
3
0
510
Hello,

I currently want to know how to boost my RamDisk speed on Linux. I picked Linux since it has two ram functions builtin to the operating system. TMPFS and RAMFS. I have used the ramfs filesystem a while back on ddr4-3200mhz ram, and although fast, I would say speeds were comparable to one being on an SSD. I was expecting atleast 17gbs a second since DDR4 3200MHZ has the capability to go to 25.6GB, but the number I got was somewhat low and unexpected.

1. Is it possible to achieve atleast half of the throughput for the ramdisk. I don't expect full performance but I do atleast expect it to compete with my nvme ssd.
2. What are some tips that I can do on Linux to achieve better throughput for data for the ramdisk.


Your probably wondering why do I need a ramfs or ramdisk, it's because I just want to see speed and eye watering performance numbers if possible. I don't plan using it for important data.
 

bit_user

Polypheme
Ambassador
I should ask why you're doing this, but let's see if we can't first at least explain what you're seeing.

When you copy something to a SSD, it first goes into the kernel's page cache (i.e. in RAM) and the kernel subsequently flushes those pages when the device isn't busy. To see the true speed of writing something to disk, try this:

> time ( dd if=/dev/zero bs=1048576 count=N of=target_filename; fsync target_filename )

Replace N with the number of megabytes and target_filename with the file name & path (in both places).

The fsync command will ensure all pages allocated to the file have been flushed out. The parenthesis put everything into a subshell and we time that compound statement. Now, just divide N by the amount of realtime and that's your write speed.

Try this with your ramdisk and with your real SSD for some large values like 4096 and let us know what you find.

Note that I'm trying to simplify the situation by looking just at the "write" side, since that's where SSDs tend to be weakest. We can do something analogous for reading, but let's take one step at a time.
 

ZachTheDoggo

Prominent
Oct 29, 2022
3
0
510
Ramdisks usually have a better limitations in theory, but it seems that ramdisks are as slow as nvme drives. A good example is looking up ramdisk on google and finding really low gb/s reads and writes. Up to 4 - 7GB.

My question is are they really slow? Especially using Linux and in dual channel? Also, if not what can I do to make them faster?
 

Order 66

Grand Moff
Apr 13, 2023
2,150
902
2,570
I should ask why you're doing this, but let's see if we can't first at least explain what you're seeing.

When you copy something to a SSD, it first goes into the kernel's page cache (i.e. in RAM) and the kernel subsequently flushes those pages when the device isn't busy. To see the true speed of writing something to disk, try this:
> time ( dd if=/dev/zero bs=1048576 count=N of=target_filename; fsync target_filename )

Replace N with the number of megabytes and target_filename with the file name & path (in both places).

The fsync command will ensure all pages allocated to the file have been flushed out. The parenthesis put everything into a subshell and we time that compound statement. Now, just divide N by the amount of realtime and that's your write speed.

Try this with your ramdisk and with your real SSD for some large values like 4096 and let us know what you find.

Note that I'm trying to simplify the situation by looking just at the "write" side, since that's where SSDs tend to be weakest. We can do something analogous for reading, but let's take one step at a time.
I am not really sure why you would want to use a RAM disk for anything, except maybe Starfield. What are RAM disks even for anyway?
 

bit_user

Polypheme
Ambassador
Ramdisks usually have a better limitations in theory, but it seems that ramdisks are as slow as nvme drives.
Most NVMe drives can't sustain high write speeds. They have a DRAM buffer and some amount of SLC, beyond which you hit the native write speed of the full-density NAND.

A good example is looking up ramdisk on google and finding really low gb/s reads and writes. Up to 4 - 7GB.
Depends on the hardware specs of the machine.

My question is are they really slow? Especially using Linux and in dual channel? Also, if not what can I do to make them faster?
If you'd try the experiment I outlined, what I think you'd find is that your NVMe drive is probably slower than you think it is. You're not seeing its true speed, due to the page cache buffering the writes.

Whether that's an issue for you depends on what you're trying to do.
 
  • Like
Reactions: Order 66

bit_user

Polypheme
Ambassador
What are RAM disks even for anyway?
Decades ago, operating systems weren't nearly as sophisticated about using free memory to buffer writes or doing read-ahead optimizations. Furthermore, hard disks were vastly slower than RAM. Making a RAM disk could therefore provide massive benefits.

Another modern use for RAM disks is for loading the OS image into temporary storage, so that any modifications to the root filesystem won't be persisted across reboots. Containers use a nice variation on this, using something called OverlayFS, which enables you to get the benefits of an immutable base image without the memory footprint of copying the entire thing into RAM.
 
  • Like
Reactions: Order 66

Order 66

Grand Moff
Apr 13, 2023
2,150
902
2,570
Decades ago, operating systems weren't nearly as sophisticated about using free memory to buffer writes or doing read-ahead optimizations. Furthermore, hard disks were vastly slower than RAM. Making a RAM disk could therefore provide massive benefits.

Another modern use for RAM disks is for loading the OS image into temporary storage, so that any modifications to the root filesystem won't be persisted across reboots. Containers use a nice variation on this, using something called OverlayFS, which enables you to get the benefits of an immutable base image without the memory footprint of copying the entire thing into RAM.
would it make sense to load games into a RAM disk or is it not worth it except starfield?
 

bit_user

Polypheme
Ambassador
would it make sense to load games into a RAM disk or is it not worth it except starfield?
Even Starfield shouldn't really need a RAM disk. At worst, you could load the entire game into the OS' page cache, so that reads are serviced from RAM instead of the SSD. However, a more clever way to do it would be to tune the OS read-ahead parameters. I don't know the first thing about how to do that on Windows, unfortunately.
 
  • Like
Reactions: Order 66

Order 66

Grand Moff
Apr 13, 2023
2,150
902
2,570
Even Starfield shouldn't really need a RAM disk. At worst, you could load the entire game into the OS' page cache, so that reads are serviced from RAM instead of the SSD. However, a more clever way to do it would be to tune the OS read-ahead parameters. I don't know the first thing about how to do that on Windows, unfortunately.
I don't know the first thing about how to do either of those things on Windows. It could be one of those things where just because you can do it doesn't mean you should. Are there any downsides to doing either of these things.