Wednesday, 29 December 2010

Never Defragment an SSD

Filed under: Hardware & Gadgets — Jan Goyvaerts @ 10:16

When a traditional hard disk with spinning platters and moving heads needs to read a (very large) file, it can do so much faster if the file is stored in an unbroken sequence of blocks on the drive. If different pieces of the file are spread around the drive, the hard disk’s heads need to physically move between those pieces. The time it takes is indicated as the seek time in drive specifications.

Defragmentation software rearranges all the files on the drive so they are all stored in unbroken sequences. In Windows you can find it under Start, All Programs, Accessories, System Tools, Disk Defragmenter. Defragmenting mechanical hard disks is a good idea. It’ll noticably speed up your PC if your system drive is a heavily fragmented hard disk. Hard disks are the slowest component in modern PCs. They can use all the help they can get. (That’s also the reason why it makes a lot of sense to replace your system drive with an SSD.) Because defragmentation is so helpful, Windows actually does it automatically when your PC is idle. You may have noticed the HDD drive light on your PC flickering furiously when coming back from lunch, only to stop instantly as you touch the mouse.

Defragmenting an SSD is a terrible idea, for several reasons:

The key benefit to SSDs is that they have virtually no seek time. Reading adjacent blocks of data is no faster than reading blocks that are spread out over the drive. Fragmentation does not affect SSD drive speed.

As I discussed in my SSD Remaining Drive Life article, SSD drives physically wear out as you write to them. Defragmentation software moves around all the files on your drive. Thus, defragmenting an SSD reduces its life span without giving you any benefits.

SSD drives deal with the limited lifespan of their memory cells by using wear-leveling algorithms. These algorithms take advantage of the fact that fragmentation does not affect the drive’s speed. They purposely fragment the drive so that its cells wear out evenly, even if you’re constantly overwriting a small set of files (e.g. database fiels) and never overwriting other files (e.g. operating system files).

Modern SSDs even lie to the operating system. If the operating system tells the drive to save a file in blocks 728, 729, and 730, the drive may decide to write it to blocks 17, 7829, and 78918 instead, if it determines that those blocks haven’t been worn out as much yet. The drive keeps a lookup table of all its blocks, so that when the OS wants to read blocks 728 through 730, the drive reads blocks 17, 7829, and 78918. With such drives, defragmentation software can’t possibly work. The software will think and tell the user that file X was nicely defragmented and stored in blocks 728, 729, and 730, while it actually has no idea where the data is stored physically on the drive.

Conclusion: don’t waste your time and your SSD’s life expectancy by defragmenting it. The automatic defragmentation in Windows 7 skips SSDs automatically. In Vista, you can disable it via the Performance Information and Tools item in the Control Panel. I do strongly recommend you upgrade to Windows 7 if you have an SSD, so you get TRIM support.

Tuesday, 21 December 2010

SSD Remaining Drive Life

Filed under: Hardware & Gadgets — Jan Goyvaerts @ 10:47

One (potential) disadvantage of solid state drives versus traditional hard disk drives is that the memory cells in SSDs are subject to physical wear. Before a cell can be written to, it needs to be erased. That can be done only so many times before the cell stops accepting a new charge. Affordable SSDs use multi-level cells (MLC) that are typically specified with a maximum PE count of 10,000. That means each cell can (in theory) be overwritten 10,000 times before it fails. Wear-leveling algorithms in the drive’s controller try to make sure that the cells are worn out evenly. If you overwite the same file over and over again, it’ll be moved around the drive so it’s not always the same cells being erased and rewritten.

SSD drives keep track of how many times each block of cells has been erased (overwritten). They report basic statistics on this via the S.M.A.R.T. parameters. You can read them with a tool such as CrystalDiskInfo. This free software is a must-have for all SSD owners.

I got my own SSD in November 2010. That means it turned 13 months this month. I blogged about my SSD drive in February.

Right now CrystalDiskInfo tells me the drive reports the following (among other less interesting statistics):

Program failure block count: 0
Erase failure block count: 0
Read failure block count: 0
Minimum erase count: 2
Maximum erase count: 112,138
Average erase count: 1,315
Remaining drive life: 87%

I’ve been checking these numbers a couple of times per month over the past year. Zero failures in programming (writing), erasing, and reading means the drive is in perfect condition. The minimum and maximum erase counts are probably quite meaningless, because they may refer to just one block. At least one block saw ten times the action that it was rated for. When the drive was new, the maximum erase count shot up from almost nothing to about 20,000 in the first month, and then shot up again to over 100,000 a months or two after that. After that the maximum count has remained unchanged.

The remaining drive life seems to be calculated directly from the average number of times each block was erased. 100% – (1,315 / 100,000) = 87%. This number has been steadily dropping by 1% each month. So my drive is going to last for a total of about 8 years.

I certainly haven’t tried to minimize the amount of data being written to the drive. I bought it for its speed and that’s what I’m using it for! At one point the drive was completely full, but now I have about 60 GB out of 256 GB free. I’ve done several complete OS restores the past year and I work quite a bit with virtual machine snapshots. I’m sure I’ve written (and overwritten) several terabytes of data to the drive already.

For a desktop drive in a developer’s workstation, SSD drive life is largely irrelevant. The drive will be obsolete before it wears out. It’s already obsolete. The link to my M255 drive on Crucial’s website results in an error page. Curcial now only sells the RealSSD C300. This drive did not exist when I bought mine. The available capacities are the same: 64, 128, and 256 GB. The prices are a bit lower: $599 for the 256 GB instead of $699. The speed, according to independent tests, is significantly higher.

Eventually I’ll replace the drive because I want a bigger and faster drive, not because it wore out. I’m not using any 8-year-old hard disk drives for the same reason.