• Welcome to TechPowerUp Forums, Guest! Please check out our forum guidelines for info related to our community.
  • The forums have been upgraded with support for dark mode. By default it will follow the setting on your system/browser. You may override it by scrolling to the end of the page and clicking the gears icon.

SSD Defragging: The safe way

Mussels

Freshwater Moderator
Joined
Oct 6, 2004
Messages
58,412 (7.75/day)
Location
Oystralia
System Name Rainbow Sparkles (Power efficient, <350W gaming load)
Processor Ryzen R7 5800x3D (Undervolted, 4.45GHz all core)
Motherboard Asus x570-F (BIOS Modded)
Cooling Alphacool Apex UV - Alphacool Eisblock XPX Aurora + EK Quantum ARGB 3090 w/ active backplate
Memory 2x32GB DDR4 3600 Corsair Vengeance RGB @3866 C18-22-22-22-42 TRFC704 (1.4V Hynix MJR - SoC 1.15V)
Video Card(s) Galax RTX 3090 SG 24GB: Underclocked to 1700Mhz 0.750v (375W down to 250W))
Storage 2TB WD SN850 NVME + 1TB Sasmsung 970 Pro NVME + 1TB Intel 6000P NVME USB 3.2
Display(s) Phillips 32 32M1N5800A (4k144), LG 32" (4K60) | Gigabyte G32QC (2k165) | Phillips 328m6fjrmb (2K144)
Case Fractal Design R6
Audio Device(s) Logitech G560 | Corsair Void pro RGB |Blue Yeti mic
Power Supply Fractal Ion+ 2 860W (Platinum) (This thing is God-tier. Silent and TINY)
Mouse Logitech G Pro wireless + Steelseries Prisma XL
Keyboard Razer Huntsman TE ( Sexy white keycaps)
VR HMD Oculus Rift S + Quest 2
Software Windows 11 pro x64 (Yes, it's genuinely a good OS) OpenRGB - ditch the branded bloatware!
Benchmark Scores Nyooom.
Yes, we all know defragmenting an SSD as a whole is a terrible idea. Don't do it.
If you don't know, it's because flash memory has near infinite reads, but limited writes - and cheaper drives can have very very low write values.

The exception to this is modern defragging tools that can defragment individual *files* - I use defraggler for this task every 6 months to hunt down just the worst files.

Is it worth it? Yes. You get much faster read speeds on those files in throughput and latency, as well as lower CPU usage while it has to process the thousands of scattered locations as it loads them into RAM.
Heres an older thread on another forum on the topic, on a plain old SATA SSD. The difference could be from that 150MB/s (or worse) to the 15GB/s a modern NVME drive can do.
Yes, file system fragmentation DOES affect SSD read speed | Overclock.net
1693374398630.png


Another user in the thread tested a 250MB file, but with ever greater amounts of fragments.
1693374794300.png


The bigger a file the less of it can sit in your RAM - if you cant fit the entire file in RAM (large game files) it'll be far worse than smaller files that loaded once, can stay in memory.

The files that get fragmented tend to be ones updated regularly on drives that are mostly full - windows or game files that have been patched or updated but have no empty space next to the existing parts of the file, so new fragments get added to the next free space over and over again.
This is normally not an issue or builds up very slowly but it's worth defragmenting the worst of the worst.
A video or logfile? skip it! The content for a game you run every day? absolutely worth it.


This is my C: drive with a 15-month-old install, sorted by number of fragments.

1692848640344.png


Somewhere around 8,000 fragments there, that would run at 4K random performance of the SSD instead of sequential.
Yet the actual size of those files is just a hair over a single gigabyte - so defragging them won't use much of that drive lifespan at all.

I'll defrag every file with 100 fragments or more now:

Before and after:
1692848778938.png
1692848917582.png


Spending 1GB of the limited writes on the drive (My 970 Pro 2TB has 1,200 Terabytes writable as it's lifespan (known as TBW) to remove 7,000 fragments is worthwhile since that's barely a drop of water in the ocean - especially if it's in programs or games you run regularly.

I ran a disk cleanup as well and emptied the recycle bin, and suddenly the value plummeted. A good example of why it's not worth defragmenting the entire drive - I'd have defragged files that should have been deleted instead.
1692849716004.png



I sarcastically wonder if 7 days to die would load faster, if it was a single contiguous file instead 4,482 pieces?
Considering the second worst file on the disk has only 230 fragments, it stands out as a single file worth fixing.
1692849123091.png
 
Last edited:
You do realize that SSD has a strong chance of seeing order of magnitude larger than stated TBW? The numbers behind what size of writes per hour are needed in a year to even begin getting concerned are rather unlikely. Per year, not single. :)
 
@Mussels
you need to keep in mind we are "enthusiast" users, not you common pc user/gamer.

i have not seen any improvement from tweaking os/ or using tools like ssdfresh/ssd tweaker (response, not talking about seq),
then again all my drives are doing +5GB/s.
all you really have to do is using win "defrag" to trim once a week.

@nomdeplume
heard of TLC or even QLC drives?
non 3D-nand QLC does about 100 writes...

ignoring that any numbers are on the "perfect condition" side, rather than worst case scenario, so the brands can "look good" on paper.

my msi 470 1TB game (only) drive is barely a year old, everything installed just once (~500gb),
yet i have 3 times the amount of writes vs read (800gb vs 300)..
 
Last edited:
The file system address is not the same on the physical block address on the ssd. Controller decides what data goes to which physical blocks, you cant force it to defragment. What you see as fragments in windows file system is totally different on the controller/flash side.
Wear leveling cause this.
If you want to speed up an ssd just use the trim command. (with at least 5-10% free space)

cmd with admin rights:

defrag /o C:
 
I sarcastically wonder if 7 days to die would load faster, if it was a single contiguous file instead 4,482 pieces?
I think file fragmentation is the least of that game's problems...

The file system address is not the same on the physical block address on the ssd. Controller decides what data goes to which physical blocks, you cant force it to defragment. What you see as fragments in windows file system is totally different on the controller/flash side.
Wear leveling cause this.
Exactly. I don't know how whatever tool this is determines file fragmentation, but I'm pretty sure that it's just reading what NTFS tells it - and $diety$ only knows how the SSD driver maps the underlying physical state of the flash to NTFS's concept of "file fragments".
 
This is pointless. You don't even have any guarantee that the ssd controller place the "concurrent" file fragments in the same place on the physical drive. Let Windows run the optimisation routine according to schedule, then leave it the frack alone.
 
Jesus Christ the man was trying to be helpful and y'all just dunked on him.
 
@Mussels
you need to keep in mind we are "enthusiast" users, not you common pc user/gamer.
If he isn't from the enthusiast side of this forum, then I'm not sure who really is. And
all you really have to do is using win "defrag" to trim once a week.
So enthusiastic. :D And I tend to disable scheduler service on most of my OS setups. Dear Lord, how many nice MS features I'm skipping... Scheduled defrag is one of them. And a broken win search functionality is the only one that I grief.

To stay on topic, @Mussels I had a thought once upon a time, that installing a game on a HDD, defragging it, and then moving it on the SSD would net a lot less fragments than installing it straight on an SSD. Any thoughts?
 
@Veseleil
was meant for the part that most here dont defrag, and know why.

nope, as every drive has a small amount of use, and will always write to the least written cells first,
and thats not in "sequence" like on a hdd.
one reason why defrag doesn't do much, your just moving data from one cell, to the next (least) used cell,
and all cells have the "same" speed reading them, so it wont matter much.
but regularly deleting files and doing trim should help with write speeds not degrading.
 
Didn't mean to be rude, I genuinely wanted to know why one might want to defragment an SSD (is the speed penalty so high?)
Windows auto defrags an SSD infrequently if volume snapshots are active on the drive. Its related to meta data fragmentation. So there is a reason for it on Windows at least.
 
Mind you, this information I read was 10 years ago when SSDs were 120GB max.

"Defrag" was unnecessary because no matter where the data was accesses form the drive, the latency was the same throughout. All defrag does is move files around and uses up cell writes. Now if you don't have good trim firmware it can help because all the data cells are randomly used up causing very slow writes. Defrag would move all the data to the same cell groups making them full leaving the others blank, like a new drive would be.

However, in the 10 years since, we got consumer drives with massive improvements to trim firmware, extra flash nand for level wear, making "defrag" absolutely pointless.

Only benefit is if the read access latency decreases from putting all the data together. Might be per brand basis.

I forgot to mention that a lot of these SSD defrag programs are actually simply telling trim to activate instead it usually running in the background when the computer is idle over a period of time.

For example Intel Toolbox "SSD optimization" button is just manually activating Trim". Though the description makes it sound like it's defragging.

True defrag will move the files around which is not good for SSDs as far as wear cycles. But if it's just activating trim there's no harm in using it.
 
Last edited:
Jesus Christ the man was trying to be helpful and y'all just dunked on him.
I guess we're not allowed to be skeptical anymore, huh?
 
I guess we're not allowed to be skeptical anymore, huh?
Or read the forum rules. If you can't post anything contributing to the thread or if you're going to be an arse, then don't post. This forum has gotten so toxic lately that I feel bad for the mods having to babysit more than what's realistic.
 
What if the fragmentation is fractal fragmentation.......?? Leave it?? :)

All kidding aside, is that W11? 3rd party program or windows?

I got this on W10 and I can't even select Analyze.

1692915878319.png
 
@Mussels
Defragging a modern SSD is useless because the internal trimming methods.
The SSD will move data between blocks on it's own to spare the integrity of the NAND flash
 
i think its now getting to the point where the better question would be: whats "your" (the program) definition of "defragging".
as long as it doesnt try to move data around, and is just running trim cmd, its ok.



@mechtech
lol.
highlight all drives, then try.
 
Last edited:
@mechtech
lol.
highlight all drives, then try.
thanks

lol wth microsoft

Have to highlight at least two of them..........even though they are all independant drives and not partitioned.
 
Hard Drives are slow enough that people can analyze their behavior with microphones and sound, as well as the latency to move the head between places.

SSDs however are getting more complex every year. Its getting more-and-more difficult for me to keep a mental model of all the layers of abstraction: static wear leveling, dynamic wear leveling, TRIM, OS-optimizations and the like. And that's before we add filesystem specific issues (NTFS) like what might be happening in this post.

Skepticism is warranted. I feel like this topic is one of the high-wizard topics.
 
You do realize that SSD has a strong chance of seeing order of magnitude larger than stated TBW? The numbers behind what size of writes per hour are needed in a year to even begin getting concerned are rather unlikely. Per year, not single. :)
Oh no, TBW are not 'per year' - it's that value total for the life of the drive.
I've had to console a lot of people who've killed their shitty budget SSD's like WD Green SATAs in far less than 6 months of purchase because they'd torrent anime until the drives filled up completely

You're meant to get the TBW (That they often hide, on the worst drives) and average it over the warranty period
1693373602767.png

With these (far from the worst) you get 40TB over 3 years so about 13TB a year. If you use things more rapidly or have the drives full most of the time, they'll die long before that.
There have been far worse drives in previous years, i'll see if i can find an example.

(Keep in mind Samsungs best drives like the 970 series had 1200TBW on 1TB drives - 1200 fills of the drive. That WD green maths to 333, so its about a third the lifespan)

Why defragment an SSD?
Wasn't that clearly covered already? In plain simple language?

@Mussels
you need to keep in mind we are "enthusiast" users, not you common pc user/gamer.
This forum has tens of thousands of visitors per day.
These threads show up in google.
And uhh... it seems like these enthusiast users don't understand how SSD's work, let alone file systems.

1693372228867.png


The file system address is not the same on the physical block address on the ssd. Controller decides what data goes to which physical blocks, you cant force it to defragment. What you see as fragments in windows file system is totally different on the controller/flash side.
80% correct
The files are indeed spread out over the NAND flash invisibly, but fragmented files are still spread out more.
If a file is fragmented into more pieces, it's going to use more of those sectors.

Only benefit is if the read access latency decreases from putting all the data together. Might be per brand basis.
This. It also uses less CPU power.
NTFS has not just character lengths, but maximum fragment sizes too
A heavily fragmented file in an NTFS volume may not grow beyond a certain size - Microsoft Support
(The link is for a specific bug in SQL, but covers the topic at hand about the file system limitations)


It's the difference between your file reading at sequential speeds or 4K random - because when it's scattered all over the drive in random fragments, it's going to be read at those random speeds.
Somewhere around 8,000 fragments there, that would run at 4K random performance of the SSD instead of sequential.
I tried to put this information as clear as possible in the post, but seriously it feels like everyone's arguing over things already explained.


There was information in a microsoft block about at what point the built in derfragger will defrag individual files on an SSD, but googling no longer finds it as you get hundreds of AI generated trash articles instead.
I had a 90GB file reading at 5MB/s from a SATA SSD to an external NVME SSD at a LAN party where i needed to share the files so other people could stop trying to download it off the internet (well before steam had it's new sharing feature), and when I looked it had some ridiculous value well over 10,000 fragments, I vaguely recall around 80,000 - it's in some thread here on TPU from a year or two back.
I had to waiit for the external copy, delete the local copy, delete a lot of other files, run TRIM, defrag and move the scattered crap to the end of the drive and copy it back to get that game loading correctly.

NTFS has limits. People just ignore them by saying "uninstall and reinstall the game!" which i dunno, deletes the files and makes a new copy with less fragments? or formatting their entire drive and starting fresh and chalking it up to mysteries of the universe.

Found one of the references i was looking for on this, it's a lot harder now with google results spammed with AI generated crap.
I'll add this to the OP, to save people having to look for it.

Yes, file system fragmentation DOES affect SSD read speed | Overclock.net
This was a SATA SSD, same file going from 159MB/s read to 506MB/s
1693374279403.png


Smaller files are just as affected.
The fragment numbers are down the bottom
150MB file
2 fragments - 499MB/s (limit of his SSD)
1000 fragments, 396MB/s
37,200 fragments (Jesus christ) down to 87MB/s

the total time went from 305ms to 1741ms, and that extra time has increased CPU and RAM usage for that extra duration while it loads the fragments into something readable in memory - they don't get processed by nothing.
1693374587384.png
 
Last edited:
Oh no, TBW are not 'per year' - it's that value total for the life of the drive.

You know what I meant. Move along to the next poster in your riposte. :)
 
I think file fragmentation is the least of that game's problems...


Exactly. I don't know how whatever tool this is determines file fragmentation, but I'm pretty sure that it's just reading what NTFS tells it - and $diety$ only knows how the SSD driver maps the underlying physical state of the flash to NTFS's concept of "file fragments".
Does it even matter how? It matters that it makes a measurable performance difference, as tests done suggest.
 
@Mussels
while you seem to be correct on the "enthusiast" part of the ppl here, your talking about sata.

not sure how many ppl are still buying those for new systems/upgrades,
but i havent seen slow speeds on any of the pcie drives i have (6 total), even on backup drives (and 3/4 full),
incl my game drive, which until about 6 month ago was almost full, games between 40-120GB each.

then again, i do tweak hdd related stuff (os), and trim regularly, especially before copying larger files,
and the backup drive with most amount of data/files is the fastest (while not the fastest by specs).
even my external does +1GB/s, only slows below for personal files/docs stuff that's less than 300MB,
all on drives never defragged by anything.
 
Last edited:
@Mussels
while you seem to be correct on the "enthusiast" part of the ppl here, your talking about sata.

not sure how many ppl are still buying those for new systems/upgrades,
but i havent seen slow speeds on any of the pcie drives i have (6 total), even on backup drives (and 3/4 full),
incl my game drive, which until about 6 month ago was almost full, games between 40-120GB each.

then again, i do tweak hdd related stuff (os), and trim regularly, especially before copying larger files,
and the backup drive with most amount of data/files is the fastest (while not the fastest by specs).
even my external does +1GB/s, only slows below for personal files/docs stuff that's less than 300MB,
all on drives never defragged by anything.
Just because those tests were done on sata doesn't mean a thing - NVME drives slow down just the same.

That test was a linux based one, or i'd run my own results, but it seems people really are opposed to learning something new on this topic.

You know what I meant. Move along to the next poster in your riposte. :)
Bonus like for the word riposte, excellent use.
 
I’d be curious to see your results with nvme. For science!
 
Back
Top