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!

Will Verduzco

willverduzco is an editor on XDA-Developers, the largest community for Android users. Will Verduzco is the Portal Administrator for the XDA-Developers Portal. He has been addicted to mobile technology since the HTC Wizard. But starting with the Nexus One, his gadget love affair shifted to Google's little green robot. He is also a Johns Hopkins University graduate in neuroscience and is now currently studying to become a physician.
Emil Kako · Mar 29, 2015 at 06:47 pm · 3 comments

Has ART Made a Noticeable Jump in App Performance?

We've received mixed reports about switching to ART but it seems that the majority of users who make the jump see some type of improvement. But just how noticeable is this improvement in app performance? Let us know if switching to ART has brought noticeable changes to your device's performance.

DISCUSS
Aamir Siddiqui · Mar 29, 2015 at 06:02 pm · 2 comments

Samsung Galaxy S6 Edge Drop Test

The Samsung Galaxy S6 and Galaxy S6 Edge are already proving to be amongst the head turners of 2015. From favoring their inhouse Exynos 7 SoC over the Snapdragon 810 SoC (which ended up causing issues to its main rival); to ditching the removable battery and micro sd card slot in favor of a more "premium" device, the flagship duo have a lot going on for them at this stage. Regarding the premium redesign which replaced plastic with metal and glass,...

XDA NEWS
Mario Tomás Serrafero · Mar 29, 2015 at 12:02 pm · 1 comment

Sunday Debate: Corporate Cyanogen Good for Android?

Join us in a fun Sunday Debate on Cyanogen Inc. Come with your opinions and feel free to read some of our thoughts, then pick your side or play devil’s advocate to get your voice heard and engage in friendly discussion. You can read our food-for-thought or jump straight into the fray below!     CyanogenMod is widely recognized across XDA for its solid performance, great feature set and far-reaching (and also long-lasting) support for all sorts of devices, from...

XDA NEWS
Share This