One of the common complaints late in the life of the original Nexus 7 was slow storage I/O performance, leading to an inconsistent user experience. After a fresh flash, the Nexus 7 was speedy and performant, but after months of installing applications and using the tablet, things began slowing down. This was a friction point that many hoped would be fixed in the new Nexus 7 (2013) model, which it was. There’s even more to the story though, it turns out Google has fixed that storage I/O aging problem on all Nexus devices with the Android 4.3 update.

In our Nexus 7 (2013) review, I talked about how I had confirmed that Android 4.3 onboard the device had enabled support for fstrim, an application which TRIMs blocks not in used by the filesystem. TRIM is essentially the paging channel through which the OS tells an SSD or eMMC controller that a block is no longer in use, and thus ready for garbage collection. This is critical for maintaining performance on the controllers in use across smartphones and tablets and preventing aging-related I/O performance slowdown.

Remember that deleting a file in software isn't actually communicated to solid state storage (whether SSD or eMMC). The space is freed up from the user's perspective, but the eMMC controller in this case still treats the pages in NAND as having valid data. Let's say you copy a 3GB movie to your internal storage, watch the movie and later delete it. You'd have 3GB free to re-use, but until you re-write those blocks the eMMC controller would treat all 3GB as valid data. There's a data structure used by the eMMC controller that tracks mapping logical locations to physical locations in NAND. I won't go into great detail here but the more complex that mapping becomes, and the more locations that have to be tracked, the slower internal NAND management works.
 
TRIM (and its equivalents) establishes that communication between file system and eMMC/NAND controller. When unused blocks are TRIMed at the OS level, a signal is sent to the eMMC controller telling it that it no longer has to track that data. A good controller will then schedule those NAND pages/blocks for garbage collection/recycling, thus improving performance. Note the use of the phrase "good controller". Enabling TRIM support is most definitely the first step though.

Although I had searched for direct confirmation before posting the Nexus 7 (2013) review, and had found some references to it, a reader of ours found fstrim inside vold (the volume daemon) and the notes essentially describe what I’ve said already.

I’ve learned a bit more on the conditions underlying when Android 4.3 will TRIM filesystems, as it wasn’t completely clear before. The Android framework will send out a “start idle maintenance window” event that the MountService listens for, and then invokes vold to fstrim filesystems when a few conditions have been met – the device hasn’t been touched for over an hour, no idle maintenance window event has been sent in 24 hours, and the device is either off-charger with 80% battery or on-charger with 30% battery. The goal is to have fstrim run roughly once every 24 hours if you’re in the habit of plugging the device in to charge every night.

Fstrim sends the FITRIM ioctl() command to all writable filesystems when invoked, which discards (TRIMs) blocks on the eMMC not used by the filesystem. Without TRIM the controller will track blocks that have data deleted by the filesystem, but the controller still believes has data it needs to track. TRIM is the signaling pathway through which the filesystem and OS can tell the controller that it can now consider those blocks unused and for garbage collection – different controllers will behave differently since it’s their prerogative to decide what happens next however.

It’s also easy to check and see that fstrim is running on devices over adb, by running and looking for it:

adb logcat -d | grep -i fstrim

Example output from a few Nexus devices I have handy which have been on for over 24 hours and have the Android 4.3 update installed.

Nexus 7 (2013)

┌─[brianklug@MBP] - [~/Downloads/APKs] - [Mon Jul 29, 03:30]
└─[$] <> ./adb  logcat -d | grep -i fstrim
I/fstrim  (  172): Starting fstrim work...
I/fstrim  (  172): Invoking FITRIM ioctl on /cache
I/fstrim  (  172): Trimmed 564789248 bytes on /cache
I/fstrim  (  172): Invoking FITRIM ioctl on /data
I/fstrim  (  172): Trimmed 25105637376 bytes on /data
I/fstrim  (  172): Invoking FITRIM ioctl on /persist
I/fstrim  (  172): Trimmed 0 bytes on /persist
I/fstrim  (  172): Finished fstrim work.
I/fstrim  (  172): Starting fstrim work...
I/fstrim  (  172): Invoking FITRIM ioctl on /cache
I/fstrim  (  172): Trimmed 0 bytes on /cache
I/fstrim  (  172): Invoking FITRIM ioctl on /data
I/fstrim  (  172): Trimmed 1045696512 bytes on /data
I/fstrim  (  172): Invoking FITRIM ioctl on /persist
I/fstrim  (  172): Trimmed 0 bytes on /persist
I/fstrim  (  172): Finished fstrim work.

Nexus 7 (2012)

┌─[brianklug@MBP] - [~/Downloads/APKs] - [Mon Jul 29, 03:46]
└─[$] <> ./adb  logcat -d | grep -i fstrim
I/fstrim  (  122): Starting fstrim work...
I/fstrim  (  122): Invoking FITRIM ioctl on /cache
I/fstrim  (  122): Trimmed 122961920 bytes on /cache
I/fstrim  (  122): Invoking FITRIM ioctl on /data
I/fstrim  (  122): Trimmed 1087574016 bytes on /data
E/fstrim  (  122): Cannot stat mount point /radio
I/fstrim  (  122): Finished fstrim work.
I/fstrim  (  122): Starting fstrim work...
I/fstrim  (  122): Invoking FITRIM ioctl on /cache
I/fstrim  (  122): Trimmed 118923264 bytes on /cache
I/fstrim  (  122): Invoking FITRIM ioctl on /data
I/fstrim  (  122): Trimmed 782077952 bytes on /data
E/fstrim  (  122): Cannot stat mount point /radio
I/fstrim  (  122): Finished fstrim work.
 

Nexus 4

┌─[brianklug@MBP] - [~/Downloads/APKs] - [Mon Jul 29, 03:47]
└─[$] <> ./adb  logcat -d | grep -i fstrim
- waiting for device -
I/fstrim  (  169): Starting fstrim work...
I/fstrim  (  169): Invoking FITRIM ioctl on /cache
I/fstrim  (  169): Trimmed 115343360 bytes on /cache
I/fstrim  (  169): Invoking FITRIM ioctl on /data
I/fstrim  (  169): Trimmed 888254464 bytes on /data
I/fstrim  (  169): Invoking FITRIM ioctl on /persist
I/fstrim  (  169): Trimmed 0 bytes on /persist
I/fstrim  (  169): Finished fstrim work.
I/fstrim  (  169): Starting fstrim work...
I/fstrim  (  169): Invoking FITRIM ioctl on /cache
I/fstrim  (  169): Trimmed 113246208 bytes on /cache
I/fstrim  (  169): Invoking FITRIM ioctl on /data
I/fstrim  (  169): Trimmed 1431195648 bytes on /data
I/fstrim  (  169): Invoking FITRIM ioctl on /persist
I/fstrim  (  169): Trimmed 0 bytes on /persist
I/fstrim  (  169): Finished fstrim work.

Users who have been experiencing slow I/O performance should see an improvement after getting the Android 4.3 update and letting fstrim run in the background a few times. Anand (the resident king of SSD and TRIM) is running some tests to investigate how much I/O performance can vary after an fstrim run. 

Comments Locked

46 Comments

View All Comments

  • GuniGuGu - Monday, July 29, 2013 - link

    This was a great find in your N7 review.. I'm really curious how this affects performance. I sold my n10 already, but I will say it was even slower than my n7 (2012) in certain operations.
  • Brian Klug - Monday, July 29, 2013 - link

    The Nexus 10 I had started slowing down as well. I wiped it, but I think if I had let it get this OTA I would've seen performance improve as a result, since I filled that device with videos and deleted them to add more quite often (great for watching stuff on a plane).

    -Brian
  • jt122333221 - Monday, July 29, 2013 - link

    Now you are making me NOT want to sell mine. I picked up the new N7 for portability (I had the old one and used it much more than my N10) and was planning to sell mine to pick up the cost of the new one.
  • Flunk - Monday, July 29, 2013 - link

    They also seem to have done something to improve graphics acceleration in chrome and in the launcher even more. That's my first perception upon installing the update on my Nexus 10. It really feels like a high-end device now.
  • MadMan007 - Tuesday, July 30, 2013 - link

    I felt like Chrome was much faster loading pages over WiFi on my Nexus 4 immediately after getting the update as well, especially in a spot where my WiFi signal is very weak (outside at home.)
  • darwinosx - Tuesday, July 30, 2013 - link

    Get an iPad 4 then. GPU is four times faster, much better color and contrast, build quality, service and support, LTE capable.
  • djebel - Wednesday, July 31, 2013 - link

    moo cow. MOO!
  • MrPhilo - Monday, August 5, 2013 - link

    Only a dumb ass would say iPad 4 GPU is 4x faster.
  • Ikefu - Monday, July 29, 2013 - link

    I'm very curious to try this on my galaxy nexus. I've done a lot of adding and deleting datasheets and cad drawings to it and its started to slow down considerably in the last 6 months. Have any recommendations for a benchmark to run before and after the upgrade to 4.3 to test for improvement?
  • geemaan - Tuesday, July 30, 2013 - link

    I checked the logcat and there's no sign of fstrim.

Log in

Don't have an account? Sign up now