SSD Defragmentation

Debates have raged over whether defragmenting a solid state drive is beneficial, necessary, or even detrimental to the drive.  Originally, defragmentation was thought to be detrimental to the drive because of the limited number of erase-write cycles.  Defragmentation is also thought to be unnecessary due to the nature of a hard drive versus a solid state drive.  In a hard drive, most of the time spent when retrieving a piece of information comes from seeking.  As the drive fills up, and files are moved, deleted, and created, fragmentation occurs.  This causes file reads to require multiple seeks to obtain an entire file, greatly reducing performance of a hard drive over time.

Since solid-state drives do not have moving parts, they have no seek-time, so solid-state drives will always retain the constant latency of the read-time regardless of fragmentation.  Defragmentation is unnecessary in order to preserve read-times.  Write-times are a different story however.  Pages in a block of memory can almost always only be written to once each.  If a page in that block of memory is going to be reused, the entire block first needs to be erased.  Write fragmentation itself is not an issue however.  The issue comes when all the blocks have been written to, so blocks must be reused.  Erase times are typically much higher than write times, and rewrites first require a read, an erase, and a write.  This can cause a rewrite on some drives to cost upwards of 2-3ms (compared to 0.1 to 0.2ms write).  Some new drives have a TRIM command, which helps to alleviate this problem when files are deleted by actually deleting them from the drive.  However, it doesn’t remove the problem entirely, because when files are re-written, TRIM does nothing.

This is where defragmentation would give a benefit.  If files are distributed evenly across blocks, then the amount of free space in each block is reduced.  This means that writes will fill blocks sooner, increasing the frequency that blocks need to be erased and rewritten.  The more files there are on the drive, the more this becomes a problem.   If most of the files are compacted into complete blocks (the blocks do not need to be contiguous) then the percentage of blocks that are completely free will be higher, resulting in less frequent erases-write cycles, increasing performance.  The performance gained and the time performance degradation takes are of course directly dependent on the free space on the drive and the frequency of file modifications.

As long as your drive has a reasonable amount of free space (probably about 40-60% free) you shouldn’t see average write-times higher than 0.5ms on a higher end drive with fragmentation.  Without fragmentation, the drives will likely stay around 0.2ms for an average write.  The performance loss is high when you look at just the solid-state drive, but when you put the times in perspective of traditional hard drives, you are still seeing an 8-10x average speedup with the fragmented solid-state drive over a defragmented hard drive.

The verdict: although fragmentation does affect solid-state drives, compared to traditional hard-drives performance remains good.  The effect may be noticeable in extreme cases, but unless you are trying to squeeze every ounce of performance out of your drive, defragmentation probably isn’t necessary.

Post a Comment

Your email is never shared. Required fields are marked *

*
*

Proudly Made in the USA
© Copyright 1996 - 2017, Sealevel Systems, Inc. All rights reserved.