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

  • solipsism - Friday, August 23, 2013 - link

    1) I'd rather take 30 seconds to enable a hotspot on my smartphone for the occasional use then pay excessive fees every month paying for a service I will rarely ever use, not to mention the HW and licensing costs associated for cellular connectivity.

    2) A cable? Have you ever seen an iPhone connected to an iPad to tether it? It's done via BT or WiFi. Now what happens if you have a half dozen devices using your 42Mbps cellular connection on your phone as a hotspot? Do you think they all get a constant 54Mbps connection with 802.11g? If so, you still don't WiFi works.
  • ShieTar - Friday, August 23, 2013 - link

    There no cable, it is done via WiFi. And yes it "requires" me to carry my phone around, but so far I have not been in a situation where I left home with the tablet but without the phone.

    And its not like I only use this solution for the tablet, I also use the phone as mobile hotspot for my Kindle and my Laptop. And when I am on a business-travel to a foreign country with a few colleagues (which happens often enough if you work for a European company), we usually only get a single prepaid card, let one phone use it to connect to the net, and act as the mobile hotspot for everybody else.
  • max1001 - Friday, August 23, 2013 - link

    It takes 2 secs to turn on hotspot on my nexus 4. Just unlock the phone and tap on the hotspot widget and you are done. The tablet automatically connects to it within 5-10 secs.
  • akdj - Sunday, August 25, 2013 - link

    Yep...Easy Peezy! Then, about 54 minutes later, your Nex 4's battery life is history. It's ubiquitous. Doesn't matter which OS or phone you're tethering to...tethering EATS battery life. Anand often shows battery life while tethering. It's often less than half that of actually using the phone itself to surf, check email or update your Facebook status. If both devices decide to sleep....bummer! Time to turn em both back on, reconnect and you're back up n running. Not sure what other carriers charge, but AT&T is $10 a month to add to your bucket data plan. IMHO, that up front hardware charge is a bargain when it comes down to connectivity and efficiency. I don't think I'm alone in this thought process and the last wifi only tablet I bought, I returned and 'upgraded' to the LTE version. The extra CNote was quickly forgotten
  • ESC2000 - Tuesday, September 10, 2013 - link

    Tethering stays on for me even if the devices go into sleep mode. I actually need to be careful to ensure that I remember to turn tethering off because otherwise it'd just stay on allowing freeloaders to use it. I have unlimited data but still...

    Also I've never noticed decreased battery from tethering. I haven't paid close attention but my note II's battery has never died before the end of the day whether I tethered or not, so I'm not too worried about tethering's impact on my battery.... esp since I can easily change the battery out-_-
  • joos2000 - Friday, August 23, 2013 - link

    I have. I got a basic "Wireless Internet" plan for my slate. It gives me more gigabytes per month than my "high usage phone plan" did. So, I've now been able to step down to a cheaper cellular plan for my phone. My cost has been status quo, but my gigabytes per month while on the go has increased.

    I'm in Australia though, I'm unsure how that compares to in the states.
  • Impulses - Saturday, August 24, 2013 - link

    If you're trying to save money in the US you go with Sprint/Tmo or one of the smaller prepaid/regional carriers, and in those cases I think it's usually cheaper to pay for one of the high GB phone plans (all unlimited in Sprint's case, also available for Tmo) and run a hotspot than to go to an AT&T/VZW plan and pay extra for a tablet. I don't know if Tmo even offers a data only plan... It's all kinda backwards here, but we generally get pretty good coverage (and no roaming) across a huge swath of a continent, which people totally take for granted.
  • max1001 - Friday, August 23, 2013 - link

    .........
    They have an LTE version coming out very soon so how is that a major omission?
  • Thomaspin - Thursday, August 22, 2013 - link

    I wrote a four part review based on my exepriences (my primary focus is that of a photographer and movie buff) from the perspective of someone who has never used Android before, so apologies for the relatively naïve Android content, which reflects my learning curve.

    My interest was in using the N7 with my existing iCloud data and so successful was the experience, and so stellar the performance of the N7, that I just sold my iPad Mini and bought a second N7 for my son.

    I realize that a fairer comparison will be with the 2013 iPad, but the N7 made it unrealistic to wait, given the iCloud functionality.

    My link, below, is not commercially motivated. My site carries no advertising and has no click-thorugh payment sources. Stated differently, I make exactly $zero from it. Nor do I try to compare with a dozen other tablets as, until now, my tablet world has been iPad only (iPad 1, iPad 3 and iPad Mini), and there's no way I am in competition with AT, which is my definitive source for test data.

    Here it is: http://pindelski.org/Photography/2013/08/06/nexus-...

    I hope it is of interest.

    I am a long time AT reader, first time commentator.
  • max1001 - Friday, August 23, 2013 - link

    If you want to be taken seriously. Keep the whole company x is evil bit out of the review. You can write the best review in the world and readers will stop taking you seriously when you start ranting.

Log in

Don't have an account? Sign up now