Friday 2 May 2014

Why _does_ a full hard disk result in slow or badly behaved OS? And does defragmentation help with SSD disks?

Answer:
* More disk i/o done due to fragmented files in the small disk area.
* ALSO more cpu+memory work managing more seperate pointers in the fragmented file-allocation table.
* Defragmentation doesn't help and doesn't make sense with SSD disks.

In Windows and Linux as well as other OSs a full main disk will result in OS behaving slowly/badly in my experience. 

It makes sense that when your main disk has limited space then things flail around a bit more. But I had not ever thought _why_ _PROPERLY_. It seems obvious that all processes have to do more work and file fragmentation causes things to go slow and this causes bottlenecks on disk as well as memory/bus and cpu load. What I realised today after a brief google + think was that with increased disk fragmentation comes more memory usage (a bit but in important part where disk drivers manage disk file-allocation-table) and more cpu work managing pointers to each fragment and more disk work (more (but smaller) i/o operations) writing smaller file fragments to disk.

Laptop and computer at home sometimes go without maintenance until there is a noticable problem. So have encountered and recovered from this problem several times on linux+windows. 

Thoughts about this triggered by this question.

http://superuser.com/questions/747528/why-is-my-disk-at-99-usage-here/748892?noredirect=1#comment966699_748892

Why? Fragmentation on disk (and resulting increase of processing fragments in memory as well as number of disk read/writes). The remaining small area will be fragmented on disk, probably spread over different areas on disk. There is no space spare so de-fragmentation will not be able to help much until more space is freed up. All processes need to write temporary files (e.g. internet browser cache). These files will be fragmented. For magnetic disks the disk heads have to travel further which means slower file read/writes. For SSD disks I was not sure, this is a little bit boring but explains it well:
http://www.youtube.com/watch?v=VfYkJoqfG-k "Why Fragmentation is Still a Problem with SSDs". In memory (in file-allocation-table in memory) fragmented files take up more space and result in more cpu and bus activity dealing with different fragments. On the video he ends up with a sell for diskkeeper which is claims to improve the problem for SSDs. BUT allowing enough spare space on disk would probably be the best strategy.

This is good: Investigation into effect of de-fragging SSD.http://www.pcworld.com/article/2047513/fragging-wonderful-the-truth-about-defragging-your-ssd.htmlConclusion: There is no point in running a de-frag tool with SSD.

http://en.wikipedia.org/wiki/Solid-state_drive
"There is limited benefit to reading data sequentially (beyond typical FS block sizes, say 4kB), making fragmentation negligible for SSDs.[100] Defragmentation would cause wear by making additional writes of the NAND flash cells, which have a limited cycle life.[101][102]"

http://arstechnica.com/information-technology/2012/06/inside-the-ssd-revolution-how-solid-state-disks-really-work/

NOR and NAND Flash Memory Floating Gate
http://www.cse.scu.edu/~tschwarz/coen180/LN/flash.html