Sunday, August 04, 2013

TRIM

Every now and then my propeller beanie comes out.


This is one of those times.

This time the recent announcement of Android 4.3 triggered it. AnandTech discovered that buried deep in the code was TRIM. And that the lack of TRIM was the cause of various Android devices getting slower as they get older.

Stop and think about that. How many Android devices have you had that you felt like got slower as they got older? And you thought you were just crazy?

NO!

They really were getting slower as they got older.

Here's the story in a nutshell.

Remember that Android smartphones use the same technology as SSD devices for internal memory. SSD devices read fast. They write to an empty block fast. Writing to a used block is slow. Really slow.

So when all the unused blocks in an SSD device get written to subsequent writes get really slow and the device slows down.

Why don't SSD drives in PCs and laptops exhibit this phenomenon?

One word: TRIM

Do you have an SSD in your PC? Try this.

Run Command Prompt (cmd) as an administrator and type: "fsutil behavior query DisableDeleteNotify".

I'll bet you got a "0." I did. That means your device and operating system support TRIM.


So what does TRIM do? Watch out for the spinning propeller.

SSDs are smart enough to know that they are slow writing to a used block. So the SSD will write to all the unused blocks first. Eventually it will have written to all the blocks. From that point forward, all writes will be slow.

But wait you say. My SSD isn't full. I've deleted lots of files. But when an operating system deletes a file, it doesn't really erase the data. It just nullifies the pointer to the file. So the blocks on the disk (SSD in this case) retain the data. Remember DOS Undelete programs?

So deleting files doesn't fix the write problem.

What to do?

TRIM enabled disks and operating systems have a protocol where periodically the operating system passes a list of blocks that were contained in deleted files to the SSD. Then in the background the SSD goes and clears those blocks.

Problem solved.

Crucial has a deeper discussion here.

Remember the ThinkPad X40 that I put an SSD in? It was so fast. At first.

Then it slowed to a crawl. My thread on the ThinkPad forums is here.

Now think about your Android tablet having that problem.

The solution? Get to Android 4.3 as fast as you can.

No comments: