Home » Questions » Computers [ Ask a new question ]

Should I keep my swap file on an SSD drive?

Should I keep my swap file on an SSD drive?

I'm considering getting an SSD drive to run as the primary OS partition. As I understand, this should provide a substantial improvement in performance.

Asked by: Guest | Views: 63
Total answers/comments: 5
Guest [Entry]

If possible, you might want to use a secondary platter hard drive as the location for virtual memory. If you don't have one, it's still recommended to have a page file, but you might want to disable it for extra disk space. It's all up to you whether to decrease memory load or more disk space is important...
Guest [Entry]

"Here is some S.M.A.R.T. data from an OCZ-AGILITY SSD that I have used in a Linux laptop for around two years.

I have a swap partition on the disk, and the only ""tweak"" I've made is to set swappiness = 0 in Linux. The windows swap profile is more or less like Linux swappiness = 0.

It's my personal laptop, so it's not used 8 hours a day (more like 1.5 hours), but I do quite a lot of development on it, so there is a lot of file creation going on.

9 Power_On_Hours 1199
12 Power_Cycle_Count 2753
184 Initial_Bad_Block_Coun 0
195 Program_Failure_Blk_Ct 0
196 Erase_Failure_Blk_Ct 0
197 Read_Failure_Blk_Ct 0
198 Read_Sectors_Tot_Ct 1311815826
199 Write_Sectors_Tot_Ct 1546123387
200 Read_Commands_Tot_Ct 22347850
201 Write_Commands_Tot_Ct 31599623
202 Error_Bits_Flash_Tot_Ct 55136
203 Corr_Read_Errors_Tot_Ct 54890
204 Bad_Block_Full_Flag 0
205 Max_PE_Count_Spec 10000
206 Min_Erase_Count 266
207 Max_Erase_Count 2166
208 Average_Erase_Count 842
209 Remaining_Lifetime_Perc 92

The interesting parts are:

Power_On_Hours (I spend too much time in front of a computer.)
Max_PE_Count_Spec is 10000, which is the minimum number of reflashes a block can cope with.
Min, Max and Average Erase count tells a little bit about the robustness of the wear-leveling algorithm. I suppose it's quite OK that the worst block has been flashed about two times more often than average.
The remaining lifetime percentage, which is 92%.

So... I think it's safe to assume that the disk should last until I retire it for other reasons. (*touch wood) It's already too small...

Assuming the numbers scale, 40 hour/week would give a life time of at least 3-4 years - probably more, since I suspect I am more efficient at wearing out my disk at home... Fewer meetings... So, I think it's quite OK for a work machine, given the benefits.

100% / (40h/(1199/(2*52w)) * 8% = 3.6 // Did I get that right, eh...

So, my advice is: Get rid of the noisy mechanical drives and enjoy the silence :-)

It's awesome with an absolutely quiet laptop.

I retired the drive some time ago, after more than 5 years in service. I needed a bigger drive, and it was also nice to get a faster one. Some blocks have definitely died, but it looks like it could hold together a few more years.

By the way, it certainly survived the laptop it was originally installed in.

9 Power_On_Hours 3965
12 Power_Cycle_Count 8755
184 Initial_Bad_Block_Count 0
195 Program_Failure_Blk_Ct 0
196 Erase_Failure_Blk_Ct 0
197 Read_Failure_Blk_Ct 0
198 Read_Sectors_Tot_Ct 5438181603
199 Write_Sectors_Tot_Ct 4223860468
200 Read_Commands_Tot_Ct 108147770
201 Write_Commands_Tot_Ct 87443515
202 Error_Bits_Flash_Tot_Ct 364621
203 Corr_Read_Errors_Tot_Ct 350922
204 Bad_Block_Full_Flag 0
205 Max_PE_Count_Spec 10000
206 Min_Erase_Count 940
207 Max_Erase_Count 7808
208 Average_Erase_Count 3119
209 Remaining_Lifetime_Perc 69
211 SATA_Error_Ct_CRC 0
212 SATA_Error_Ct_Handshake 0
213 Indilinx_Internal 0"
Guest [Entry]

"Patrick Regan's answer about ""swappiness"" is pretty spot on: Depending on your usage, it might be fine, and if you're using Linux you can tweak ""vm.swappiness"" in sysctl (as described in an earlier question) for your use.

So I'm tempted to say yes, as long as you give lots of disk to your swap. I've been hearing lots about the internal controllers on SSD drives having super-tweaked algorithms to combat write wear, so in theory this would help -- give it lots of space, and set the kernel swappiness level low, and the SSD controller can spread the writes out and prevent any wear trouble.

So that got me to wondering what the largest swap partition could be. I locked onto your mention of ""swap partition"" and thought ""Linux"", so I looked into the maximums there.

It turns out you can create ridiculous things like 16 TB swap partitions, at least based on the kernel math. mkswap might not be able to actually initialize that partition, but the kernel supports it. However, the kernel can't use it. According to this, 16 GB is about the biggest swap partition you can make and use in a modern Linux kernel.

So yes, you can, if your usage is going to be fairly swap-free. If you'll be swap-heavy, though, maybe a cheapo USB key for ReadyBoost (or the Unix equivalent) would be a better fit -- that way when your swapping destroys the device from overwriting, it'll be cheap to replace and won't cost you the price of another SSD."
Guest [Entry]

"2016 Update

Performance

Some more fresh data about SSDs nowadays. They typically read, write 500 MB/s. A normal decent RAM's I/O is around 10-20 GB/s. However PCI-e SSD exist; they do have a good I/O rate (1-2 GB/s), but still they do perform like RAM in early-mid 2000s.

Performance ratios are:

If RAM is 100%
PCI-e SSD is around 10%
SSD is around 2,5-5%
HDD is around 0,25-1%

If you did have an HDD, your virtual memory might get a good increase in performance.

Price

Regular SSD became cheap, but PCIe SSD with good I/O is not really cheap yet. Just do the math; out of PCI-e SSD price you can buy a new motherboard with new RAM, and voila, problem solved.

On the other hand, since SSD became more affordable, they are very much available for low money, and actually I will reuse my old 96 GB SSD as virtual memory. I can't really sell it, so I can use it for virtual memory. Well, why not? It is still better than an HDD. If you have to have a page file, put it on a legacy drive.

Reliability

The following test shows that many of them fail after a while.

100-600 terabytes are really a lot of I/O, and if you have let's say 48 GB virtual memory, if you read and write all in and out, it means at least 2000 iteration before the first bad sectors, but if you have a reliable disk, it is more like 10000 or more. I would assume it is more than two or three years of usage.

Sum

I would use it as a virtual drive if I really need it, but if it is an available option, just expand your RAM as far as you can in necessity. Use this virtual memory only if you run out of options. On the other hand, you can use your older SSD for this purpose, and you can replace it for 30-40 USD any time if fails (probably won't for a long while), it can be useful.

PCI-e SSD for virtual memory: if you want to burn money, or if you have absolutely no other choice.

One last sidenote: if you now have only HDD, go and get an SSD, migrate your operating system, you will feel like you bought a new computer."
Guest [Entry]

"Although the random read of SSD drives is very good, the random write performance can be very bad. Apparently some SSDs only provide 12 write IOPS, which is only a tenth of what a standard rotational disk provides(~120 IOPS), and even faster SSDs like the Super Talent SSD may only provide 50 random write IOPS.

On the other hand, it is possible for an SSD to perform thousands of operations per second, for example the Intel X25-M 160 GB 34 nm MLC G2 can perform 86001 (according to the Intel specification sheet) or even 153342 random write IOPS of 4k blocks.

So in conclusion, the swap performance of your SSD may well be better, but do not assume that this will be the case until you have checked the number of random write IOPS your SSD can achieve.

[1]: http://download.intel.com/design/flash/nand/mainstream/322208.pdf

[2]: http://www.legitreviews.com/article/1022/6/"