eMMC and FSTRIM

The new Nexus 7 obviously ships with the latest version of Android (4.3), which happens to add a major feature for keeping storage performance high: fstrim. Modern smartphones and tablets fundamentally use a very similar storage architecture to what we see in modern SSDs (solid state drives) in PCs. Instead of a drive featuring a discrete controller, DRAM and NAND flash, these ultra mobile devices typically feature one or two NAND devices with an integrated controller - typically eMMC. To keep costs (and power consumption) low there's also no DRAM cache, which definitely harms performance.

Since the underlying architectures are quite similar, the pitfalls are the same as well. The biggest issue? Performance when operating in a full or near-full state. With tons of files on your internal storage, the data structures that have to track all of those files and where they're located in NAND space get pretty complex, and traversing those structures takes a considerable amount of time. The part that many seem to forget is that once you delete a file in Android, it's not immediately removed from internal storage. The space is freed up in the OS, but the eMMC controller still tracks all of the data as valid bits. It's only when that data is overwritten that the controller knows the previous data didn't matter.

In other words, it's possible to have tons of free space on your internal storage, but have the drive appear full to the eMMC controller (and thus enjoy all of the terrible performance that goes along with it). To make matters worse, you never even have to fill your drive to get it into this state. In order to maintain even wear across all NAND cells (to extend the lifespan of the NAND flash), the eMMC controller will write to new/empty blocks in NAND as much as possible. Let's say you have 10GB of storage and Android writes 1GB of data to new addresses every month and deletes the previous 1GB each time. As long as the addresses being written to never overlap, your drive will be full in 10 months (from the eMMC controller's perspective) but Android will still report 9GB of free space.

fstrim establishes communication between the OS and the eMMC controller to address this problem - and it's enabled in Android 4.3.

Unlike TRIM on standard SSDs, FS_TRIM works more like the manual/scheduled TRIM tools from the early days of consumer SSDs. From Brian's original Android 4.3/TRIM article:

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.

Personally I feel like the rules are a bit excessive and I'd love to see us get to active TRIM on these devices, but I guess it's a bit too early for that. Basically if your device has enough charge and you're not using it, Android 4.3 will issue an fstrim command to the eMMC controller. The command passes along a list of all unallocated addresses in the filesystem, which the eMMC controller can then use to purge its logical to physical mapping table/list/datastructure. The process should complete relatively quickly as no new data has to be written, the controller just needs to do some cleanup of internal structures and add a bunch of addresses to the unused block pool. Keep in mind that this simply addresses the issue of your storage getting slower over time. fstrim does nothing to keep performance high if you actually fill your storage to capacity. Given how bad these eMMC solutions are, my recommendation is to try and keep at least 20% of your internal storage unused/as free space.

To showcase just how bad things can get I actually dusted off last year's Nexus 7 and treated it like an SSD. I first filled the device with sequential data, leaving only 300MB free. I then performed back to back random writes across the remaining free space and the performance reduction:

Nexus 7 (2012) Storage Performance
  Sequential Read Sequential Write Random Read Random Write
New After Factory Reset 25.18 MB/s 10.63 MB/s 7.08 MB/s 0.45 MB/s
1st Run After Fill 22.25 MB/s 1.21 MB/s 7.62 MB/s 0.14 MB/s
2nd Run After Fill 26.00 MB/s 1.97 MB/s 7.8 MB/s 0.11 MB/s
3rd Run After Fill 24.57 MB/s 3.18 MB/s 7.96 MB/s 0.16 MB/s
After ~24 hours Idle Time 27.03 MB/s 11.21 MB/s 7.65 MB/s 0.46 MB/s

The columns to pay the most attention to are the write columns (read performance shouldn't change over time). Note that sequential write speed drops by almost an order of magnitude. This incredible drop in performance manifests itself as pauses or stutters. Even when you're just performing simple tasks on your tablet, there are usually tons of background operations going on (e.g. updating system logs). If you look at random write performance here, we see performance drop down to 0.11MB/s - or roughly 27 IO operations per second. If you have more than that amount of IO coming in at the same time, what you'll get are long pauses while the eMMC controller works through its IO queue. Although I didn't include it in the table above, I spent a full day torturing the eMMC on this Nexus 7 and managed to get random write performance as low as 0.02MB/s or 5 IOPS. Sequential write performance in that case was 0.81MB/s, equally disheartening. My point here is that worst case storage performance can get very bad, but looking at the last line of the table you see the incredible impact fstrim has on restoring performance.

I/fstrim ( 118): Starting fstrim work...
I/fstrim ( 118): Invoking FITRIM ioctl on /cache
I/fstrim ( 118): Trimmed 445079552 bytes on /cache
I/fstrim ( 118): Invoking FITRIM ioctl on /data
I/fstrim ( 118): Trimmed 13637656576 bytes on /data
I/fstrim ( 118): Finished fstrim work.

Anyone who had issues with their Nexus 7 slowing down over time will want to upgrade to Android 4.3. Those users considering upgrading to the new Nexus 7 should be fine thanks to fstrim. The only situation where you should see tremendous decrease in storage performance, resulting in IO latency enduced pausing/stuttering is if you physically fill the internal storage close to capacity. Again - my recommendation here is to try and leave at least 20% of your internal storage free. Note that this recommendation applies across Android and iOS.

With all of that out of the way, how does the eMMC solution in the new Nexus 7 stack up? Sequential read performance continues to be quite good for such a small/lower power device. Sequential write speed isn't terrible either. Even random read performance looks solid. It's random write performance that just needs work across the industry. We realistically need to probably be at 10x where we are today in random write performance, perhaps a bit lower if the storage makers can focus on IO consistency/minimum sustained IOPS.

Storage solutions in these tablets are often sourced from multiple vendors, and we can see dramatic differences in performance between them. Brian's review sample was a 32GB model, while the tablet I reviewed had 16GB. The two solutions performed pretty similarly, although my 16GB model did have appreciably better random write performance. Ultimately if you need the space, the 32GB model will be the better performer (you're better off using 45% of a 32GB model than 90% of a 16GB model).

Storage Performance - 256KB Sequential Reads

Storage Performance - 256KB Sequential Writes

Storage Performance - 4KB Random Reads

Storage Performance - 4KB Random Writes

 

CPU & GPU Performance WiFi, GPS & Camera
Comments Locked

202 Comments

View All Comments

  • ESC2000 - Thursday, August 29, 2013 - link

    I agree with everyone who is perplexed that you object to paying less. Also remember though that Asus manufactured these tablets and they certainly aren't working for no profit. I think I read somewhere that Asus gets $4 per nexus 7.... certainly not the $150 or whatever that Apple makes on each mini (not to mention the extra $100 for each storage upgrade) but it adds up.

    Of course they may be selling at or below cost and Google might just be paying Asus. Hopefully we won't all end up working as slaves to Google... -written from my happily-obtained at cost nexus 7 2013
  • jl0329 - Wednesday, October 9, 2013 - link

    You are wrong on so many levels, I don't know where to begin...
  • Arbie - Thursday, August 22, 2013 - link


    Well, I may have to get used to it, but I don't want to. Hence the comment. And in what way does SD "suck"? Micro and standard SD work perfectly for me in about eight different devices, and have done so for years.

    Wait - I just figured it out: you're putting the chip in backwards. Google for some help with that.
  • Arbie - Thursday, August 22, 2013 - link

    You simply prove my point. Without a micro/SD slot you have to spend hours grinding your videos down just to fit the hardware AND keep a computer available (!!) to reload your tablet memory. That whole scenario is so infinitely more difficult than just snapping tiny chips in and out that it doesn't even parse. People - we should be bitching more about this, or we *will* have to get used to no SD.
  • Arbie - Thursday, August 22, 2013 - link

    Yeah, at about 1000x the size, weight, hassle, and fragility of a microSD card, it's not as elegant... That's exactly why we need micro/SD.
  • BMNify - Thursday, August 22, 2013 - link

    Anand will you please point out that Nexus devices are sold at-cost to the consumers, Google subsidised prices can't be compared with the other hardware manufacturers.
  • sherlockwing - Thursday, August 22, 2013 - link

    I guess Amazon doesn't count as "other hardware manufactuers" with their Kindle Fire Tablets?
  • BMNify - Thursday, August 22, 2013 - link

    Nope, Amazon doesn't count, now they can easily exit the market too if they want as their objective of cheap tablets as their delivery vehicle is achieved as mentioned by Brian Klug in one of the podcasts but they will still stay in the market so that they are not totally dependent on other ecosystems.
  • sherlockwing - Friday, August 23, 2013 - link

    If "cheap tablets as content delivery vehicle" is the Amazon model, it is the same as the Google model (use N7 to expand Android App user base, especially those that use Google Apps). If you declare "Amazon doesn't count" then Google doesn't count either by the same logic of yours.
  • akdj - Sunday, August 25, 2013 - link

    'especially those that use Google Apps'. That's the nail on the head. Google doesn't care about the 'Play Store"...in the sense of it being a money maker. Google is first and foremost an advertising company. The biggest in the world. The 'google apps' are exactly and precisely why they're selling these and their phones @ cost. It's also the same reason they release excellent iOS apps. For Google, your info...that's their gold mine. Nothing more, nothing less. Apple on the other hand IS a hardware manufacturer. Just so happens the App Store is extremely lucrative and would qualify as a Fortune 500 company on its own. As is iTunes. They make real, hard cash for those endeavors.
    Two completely different philosophies and goals
    Amazon on the other hand...again, offering the Kindle @ cost allows for a quick and easy portal to purchase everything from diapers and peanut butter to the latest Stephen King novel or Tom Petty's new album. They're selling you a shopping bag that'll fit anything from the store (and your credit card) you'd like to buy
    Just so happens...other vendors are now involving themselves attempting to compete with these two (3) different ways of thinking and running Android with their OEMs skin. Competition is good. These tablets in their current, usable and consumer available format have only been around for three years! As a 42 year old enjoyer of all things tech related, I find it a very exciting time to be involved with and 'into' technology. It's amazing what's happened in only 36 months....we've got more software available at our fingertips (with smartphones included) than any other time in history. 800,000+ apps on each platform....obviously with some parity. But just five years ago a decent game on a handheld gaming device was $59 on release! When I was a kid...my Mattell handheld football game cost my folks a good $30 bill for Christmas!
    It's funny how 'religious' these OS debates have become. I own both Android and iOS devices....Work in Windows and Mac PCs...and I'm excited for everyone's press conference. How most of us that frequent Anand's site don't feel the same is beyond me. I'm just thankful the staff here is as passionate AND as objective as any human could ever be when it comes to technology review.
    And to think....you don't pay a dime, most of you...to come enjoy their articles and in depth reviews anytime you choose???
    Why such animosity? And why complain or argue? Debate is good...but so many of these tangent conversations seem to just 'not get it'. Seems ignorance has run rampant since the invention of the 'smart phone'....turned all of us into 'dumb people'
    Just my cent and a half (I bought the new Nex7 myself...don't have a full two cents, I'm saving for the new 'mini' this fall;))

Log in

Don't have an account? Sign up now