73

I am new to the hardware side of things. I run a few machines which have 400GB+ SSD's and 32GB RAM. I have been thinking about going up to 64GB RAM, however, I was thinking, since SSD's are solid-state like RAM, can't my extra space be used as RAM?

If I do this, will the extra RAM (from disk space) be significantly less efficient than DDR3 RAM?

psusi
  • 8,122
Jenny
  • 891

8 Answers8

57

Firstly, RAM is still significantly faster than both your regular 6gb/s SATA or even the newer PCI-e based solutions. RAM is also designed to be written and erased repeatedly, at the cost of volatility. RAM generally doesn't wear out due to regular use - though, of course, it can fail like any component.

While the lifespans of SSDs have gotten much better, SSDs do wear out. They're absolutely brilliant for nonvolatile use, but if you wrote and overwrote NAND (which SSDs contain) like you do RAM, it would wear out.

Both are really optimised for different things, and you're better off having enough RAM (and using SSDs or spinny hard drives for paging out) than compromising on enough RAM for the task.

Excellll
  • 12,847
Journeyman Geek
  • 133,878
52

Two years after the question was posed, the answer is changing from no to maybe.

Samsung SM951 is the current state of the art and, in RAID 0, has been shown in testing to achieve 4.5GB/s read and 3GB/s write. At a cost of $1/GB per disk this is significantly cheaper than RAM.

http://www.legitreviews.com/samsung-sm951-m2-pcie-ssds-raid0-performance_161753/5

DDR4 data transfer rate:
DDR4 2133:17 GB/s
DDR4 2400:19.2 GB/s
DDR4 2666:21.3 GB/s
DDR4 3200:25.6 GB/s

http://www.transcend-info.com/Support/FAQ-292

Further, the short lifespans of SSDs have been greatly exaggerated with tests showing that the 250GB Samsung 840 Pro sustains 2.4PB of writes.

http://techreport.com/review/27909/the-ssd-endurance-experiment-theyre-all-dead/4

Depends on the application. If speed is more important than space then RAM, otherwise (maybe) look at SSD.

Andrew
  • 1,050
41

As grawity suggested you already have the swap/page file performing this task. Now even a SSD is much more slower compared to DDR3. SSDs can deliver up to about 654MB/s while 1333MHz DDR3 in dual-channel mode can deliver up to 21.3GB/s (21 332MB/s).

user555
  • 757
27

Yes, it will be significantly less efficient than DDR3 RAM.

  1. SSD will wear off quickly if used as RAM (frequent writes). So it will only be effective for 2 months or so, after that it will surely die. (So instead of 10 years of life ... it will live for about 10 weeks.)
  2. SSD is a disk device. CPUs can only pre-load data into its cache from RAM. If it will be on an SSD, it must be first loaded into RAM... Accessing the disk (even very-fast SSD) is around 100 times slower than accessing RAM. See benchmarks of HDD, SSD and RAMDISK (ramdisks on DDR3 have more than 3000 MB / sec , and less than 0.1 milisecond wait time for access. So, clearly: SSD cannot compete with speed of RAM).
21

The key reason why you can not use an SSD as RAM is because it is connected to the computer as if it were a disk drive, rather than RAM. That is to say, that the processor can not directly address the memory in the SSD but instead has to hand a block of RAM to the SATA controller and ask it to transfer data between that ram and an area in the drive.

The new NVM Express interface is poised to change this. It allows the CPU to map swaths of the SSD directly into its memory space and use it like RAM instead of issuing IO requests to transfer between RAM and the SSD. This has the potential significantly speed up access to the SSD while using less RAM as it is no longer required to cache the data while the CPU accesses it. This is currently an area of active development in the Linux kernel.

phuclv
  • 30,396
  • 15
  • 136
  • 260
psusi
  • 8,122
6

First, I have to say that swap/pagefile isn't RAM or virtual RAM. It's a BIG misconception that lots of people have. Pagefile is simply a place to store "unused" memory pages. If a program touch a page that's not available in memory then the memory controller will throw an exception that the OS will catch and load that page from any kind of memory like hard disk, SSD, network or zram, zcache... or simply kill the process away. That no way means pagefile is RAM

Now back to the main question


Indeed SSDs are always slower than RAM in the same era, but...

The reason isn't speed!!!

Even if SSD is faster than RAM we still can't use it as RAM, because the SSDs you can buy nowadays doesn't have the capability to address individual bytes like RAM. They're block devices which means you can only work on blocks. Under the hood they're comprised of NAND flash modules which can only read/write single pages. You can't edit a single byte without reading and rewriting the whole page. Each page is far bigger than the CPU's cache line

That means unlike what psusi said in the second paragraph, an NVMe or M.2 SSD can't work as RAM even if you can map it to the CPU's address space!!!

There are some kinds of non-volatile memory that's byte-addressable though, for example NOR flash. That's why small microcontrollers for embedded devices occasionally use NOR flash as an execute in place (XIP) medium to avoid the need for separate RAM and EEPROM/flash chips. But that doesn't work for large computers because of the speed and cost, just like how some small MCUs use SRAM directly as RAM instead of DRAM like normal CPUs

Additionally, to be able to work as RAM you not only need the ability to read/write single bytes but also the support from the memory controller/MMU. Mapping the address space doesn't work if the memory controller doesn't know how to interact with the device. Currently memory controllers all deal with RAM modules directly, so you need to use the same RAM interface for anything intended to be used as RAM regardless of the memory type

That's what Intel® Optane™ A.K.A 3D XPoint is currently doing. It's currently the closest to "using SSD as RAM" because it's the only thing that's fast enough and also byte-addressable. Note that only the Intel® Optane™ Persistent Memory comes in the DDR4 form factor and can be used as RAM. You still need some special hardware and OS support though, otherwise they still assume data in RAM are always volatile

Optane memory in comparison with DDR4

The other form factors, Intel® Optane™ SSD, can't be used as RAM due to the reasons I said

Intel® Optane™ memory comes in the M.2 form factor and will not be used in the DIMM/ DRAM memory slots. As such, it will not replace the current RAM that you have in place.

Can Intel® Optane™ Memory be used as RAM?

The price isn't cheap though, as expected: Intel Optane DIMM Pricing: $695 for 128GB, $2595 for 256GB, $7816 for 512GB (April 07, 2019)

See also

phuclv
  • 30,396
  • 15
  • 136
  • 260
0

I have a laptop with maximum RAM of 4GB installed. I thought that using SSD for swap space would speed up my system. I have 250 GB Samsung drive, and allocated 32 GB for swap space. My PC runs much slower! I'm running Windows 10 Pro 1709 on a Lenovo 3000 N200 laptop. I have recently read that Microsoft recommends minimum of 8 GB RAM for Windows 10. I now have an 8 GB laptop, and its performance is much, much better.

0

I think the answers to the OP have got it covered - RAM is fast, volatile and not cycle limited, NAND is less fast, non volatile and wears out. BUT I'd like to mention another angle on this that has been in my mind for years.

A mechanical disk is a sequential R/W write device, that is, you start reading or writing at a particular spot, and keep going along the stream of bits until another spot where you stop. If you want to swap locations, you need to navigate the R/W head to the place where the new data is. Memory, by its nature, is random access - you can read/write each cycle to a completely different place in memory with no performance penalty.

Now, current SSDs are engineered to look like sequential R/W devices, simply because that's the known paradigm they are replacing. But they're really not sequential - they are memory. So what if we had a new kind of interface that allowed memory-style random access to the memory in an SSD, while being able to distinguish it from RAM.

I'm mainly thinking of databases here - they are traditionally based on disk, but the bottleneck has always been the sequential media - in fact, a lot of database servers actually have a map relating data directly to disk sectors in order to increase speed. If we could create a database server that mapped data directly to random access SSD-style nonvolatile memory, it could be a game changer for database speed.

Perhaps I'm dreaming and the SSD interface approaches the speed of direct random access, since that's what it's doing internally (plus it offers other services such as write cycle distribution).

I've just never heard this concept stated directly before, so I thought it was worth mentioning.

(edit: whoops, I see @psusi already mentioned this. I'll leave the answer here as an elaboration anyway)