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

  • doobydoo - Sunday, August 25, 2013 - link

    Retina is an Apple marketing term but the science behind it is not Apple's to change.

    Put simply, a retina device is a device which, when used at a normal viewing distance (11 inches for smartphones, for example) does not have discernible pixels for people with 20/20 vision.

    That's the definition, period.

    Whether it's useful to you or not depends on whether you have 20/20 vision, or perhaps whether you hold your device closer or not.

    The iPad 4 is retina because it would typically be held further away from your eyes than a smartphone, whereas the Nexus 7 with its significantly smaller screen would be held closer (but also still qualifies as retina).

    For perfect vision, the absolute best you can find in anyone, ever, at 12 inches you'd be looking at a possible perception of 700 PPI.
  • Fri13 - Thursday, November 14, 2013 - link

    Now after a longer time when both has been released, a Nexus 7 (the 2013 model) and iPad Mini (with Retina display) there is no actual difference.

    Nexus 7 has 323 PPI while iPad Mini has 326 PPI so the difference is only a 3 pixels what is nothing even if other would have only 150 PPI. As that is small enough to offer a sharp text and pictures and in this case both are over 320 PPI what is over twice needed to offer sharp text and pictures. The first gen iPad mini was 163 PPI what was enough, but for many it isn't "enough" because they want specs to be updated no matter if there are no reasons to do so.

    And you don't want to compare operating systems, it is useless as you don't want to compare filesystems, process schedulers, filesystem schedulers, memory management efficiency, network protocols stacks like TCP/IP or process threading etc etc. You want to compare only the graphical user interfaces like what user see, how they are designed (logic) and what functions does device offer for developers so users can post-install wanted software from different sources than just manufacturer own (so you can be in control of your device) and most important thing, how well does the devices work in ecosystem (== how well can all devices share data between each other no matter who is manufacturer or what software is used. Every device belongs to one and the same "ecosystem").
  • darwinosx - Thursday, August 22, 2013 - link

    Android tablet apps are not close to iOS tablet apps in selection and quality. Anyone who owns a Nexus 10 knows this if they are truthful.
    There will be a new iPad Mini in a few weeks and Apple will settle all family business. The old iPad Mini sold dramatically better than the old Nexus 7 and this will be no different.
    What you and Anand don't mention is that Nexus devices are sold at cost.
    As I said earlier I have bought three of these as gifts in the last month or so. But the screen is too small for me and app quality and election is lacking. A retina iPad Mini is going to blow the doors off the Nexus 7 in sales. Watch.
  • smartypnt4 - Thursday, August 22, 2013 - link

    Well, no one ever argued that...

    The iPad mini will sell more, regardless of how the specs compare. That's simply because there's a lot of people in this world that want something they already know how to use, and iOS is what the learned at the beginning of the smartphone race.

    Now, that app selection thing: the advantage of the 7" form factor is that the apps built for phones aren't completely useless on this screen. After owning a N10 and now a 2013 N7 (with an iPad in between, mind you), I can say that the situation on the N10 was terrible. So many apps just didn't come close to being usable. The other bit is, I really don't use that many apps any more, so there may be some people in that camp. I can't say for sure due to my relatively small sample size (me and a few friends who care).

    All in all, Apple has no excuse if they don't show up with a retina-fied iPad mini this fall. Last year, it was argued that the mini doesn't have an awesome screen due to cost, availability, and the power drain it'd suffer. The 2013 N7 shows that it's completely possible to do in today's world, regardless of what was possible last year. I really do hope Apple shows up with a good competitor specs-wise, because I'd hate to not have a choice as far as small tablets are concerned. We hardly have a choice on the large tablet side as it is.
  • mmarafie - Friday, August 23, 2013 - link

    Agreed
  • WarpGuN - Friday, August 23, 2013 - link

    crap apple will never compete spec-wise with Nexus they will always be behind. Overpriced crap designed for the non-geek, Android is dominating with smartphones and tablets Apple is losing market shares everyday
  • akdj - Friday, August 23, 2013 - link

    WarpGun....what? Are you six years old? That's your offering to the discussion? Good grief....grow up a bit, then come back and join us for a real discussion. The two companies go back and forth every year beating each other in 'specs'. Just take a look at last years gear vs this years. Ridiculous comment, as the iPad (both mini and regular) are at the end of their cycle. And with this in mind, the iPad 4 still fairs pretty well against current competition even being a year old.
    The article hasn't anything to do with market share...but Apple has never 'lost' market share. Each iteration if iOS device has outsold the last. In fact, this past quarter the iPhone outsold YoY itself by an extra 5mil units. Get out of your basement, get a job, and try to contribute to the discussion at hand rather than spread your personal agenda
    The new nexus 7 is one helluva tablet. An excellent review from a legitimate reviewer to boot. Isn't that enough to make you 'happy' to be an Android fan?
  • Miggleness - Friday, August 23, 2013 - link

    This is the first time I paid attention to the size difference between the Nexus and iPad Mini. That's another big factor in my next purchase and the Nexus just feels too small.

    Thanks for the review Anand. This is the reason I keep coming back to your site.... twice daily!
  • ESC2000 - Sunday, August 25, 2013 - link

    Actually the nexus displays more on its screen than the mini because of how many more pixels the nexus has even though the mini's screen real estate is about a third bigger. I've messed with the two next to each other and the nexus looks way better. Of course the nexus is much newer. Still I expect the new mini to be either overpriced or underspecced... or both like the first mini.
  • doobydoo - Monday, August 26, 2013 - link

    Actually, no it doesn't, because despite the increase in resolution, the Nexus doesn't shrink everything compared to its predecessor. It still displays less than the iPad Mini, because if it didn't everything would be too small.

    I also now don't believe that you've compared the two side by side because if you had, you would know this.

Log in

Don't have an account? Sign up now