Will Verduzco · Jul 31, 2013 at 08:30 am

Yet Another Reason to Update to Android 4.3: TRIM Support

Android 4.3’s launch last week has been nothing short of an almost resounding success. Why “almost?” Well, aside from a few issues with copy/paste, most users seem to be quite happy with the latest iteration of Jelly Bean. This level of user satisfaction is to be expected, as the latest flavor of Jelly Bean brings added performance, improved API support, additional functionality, and a few other features. One of these “other features,” however, is quite important for those of us who frequently transfer massive amounts of data to our devices such as media content and other large files.

Of course, as you might expect, I’m talking about how 4.3 also brings TRIM support to all Nexus devices. Anyone who has ever experienced a massive device slowdown after transferring large quantities of data to and from a NAND device knows what I’m talking about. For a very practical example, one need only look at Google’s original Nexus 7. Back when it first came out, reviews for the popular device nearly unanimously praised it for its high level of performance. However as time went on, most users seemed to notice a rather sharp I/O performance decline. This lead to an overall feeling of sluggishness when using the device, making the once fast tablet almost unusably slow for some. This issue seemed to affect those with lower capacity models more severely, or at least more quickly, than those with the 32 GB model. As you would expect, this was largely due to TRIM not being enabled in previous builds. This then prevented the scheduling of NAND blocks for garbage collection, making rewriting data to these blocks significantly slower. (Note: Traces of TRIM were added back in the Nexus 7 4.1.2 builds, but the current consensus is that it wasn’t actually enabled until 4.3.)

Looking into the Android Git, one can readily find the modifications to Android’s volume daemon (VOLD) to enable fstrim. The next step is determining when exactly fstrim runs. As exposed by some detective work by Brian Klug over at Anandtech:

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.

In other words, if your device is idle and plugged in for over an hour, it will run the “start idle maintenance window” event. However, this will only take place if the “start idle maintenance window” event hasn’t been sent in the past 24 hours, and if your battery level is either greater than 80% or you are plugged in and have greater than 30% battery. Another way to invoke TRIM is to use a frontend for the fstrim utility and force TRIM to be executed using an app such as XDA Senior Member AuxLV‘s Lagfix application.

All of this is unimportant without tangible performance gains. So what can you expect from 4.3 in terms of I/O performance? Over the next couple of days, I set to find out on two daily use devices. I’m going to be running tests using Androbench Storage Benchmark before and after upgrading from official JDQ39 (4.2.2) to official JWR66V (4.3) on my personal Nexus 7 (8 GB) and Nexus 10 (16 GB). Both devices have received heavy usage, with much data being transferred to and from the devices, and about as many deletions. After the “after” tests are run, I will then root the devices and use the LagFix fstrim frontend to force TRIM manually and rerun the benchmarks. Stay tuned and keep checking the Portal for updates!


_________
Want something on the XDA Portal? Send us a tip!
Jimmy McGee · Mar 2, 2015 at 06:00 am · no comments

HTC One M9 & Samsung Galaxy S6 Unveiled – XDA TV

The HTC One M9 and the Samsung Galaxy S6 were unveiled at Mobile World Congress! That and much more news is covered by Jordan when he reviews all the important stories from this weekend. Included in this weekend's news is the announcement of the Huawei Watch Android Wear device and be sure to check out the article talking about IKEA selling Qi enabled furniture. That's not all that's covered in today's video! Be sure to check out the other videos...

XDA NEWS
Aamir Siddiqui · Mar 2, 2015 at 03:10 am · 2 comments

Sony Xperia Z4 Tablet, The Thinnest 10″ Tablet, Now Official

While the likes of Samsung and HTC were busy announcing their next big things in the mobile market at their Mobile World Congress events, Sony was turning up the heat in the tablet market with the launch of its latest offering, the Xperia Z4 Tablet. Coming with a 10.1" IPS display offering 2560 x 1600 pixel resolution, the Xperia Z4 tablet is the successor to the successful Z2 tablet released in 2014. As a true successor, the Z4 Tablet offers everything...

XDA NEWS
Emil Kako · Mar 1, 2015 at 04:12 pm · no comments

Samsung Galaxy S6 VS HTC One M9: Which Do You Prefer?

After months of anticipation, both the Samsung Galaxy S6 and HTC One M9 have finally been unveiled. Now that we have all seen both of the devices in all their glory, many of us have some decisions to make. Which of the two beasts do you prefer: the Galaxy S6 or the One M9? Let us know which device you plan on buying and why!

DISCUSS
Share This