04
Apr
image

Poor SD Card performance can definitely have a negative effect on overall experience with your device, especially when considering apps that rely on speedy SD Card access, like the Gallery, or features, like Apps2SD.

XDA forum member brainmaster has been hard at work on tweaking some settings in Android to improve the situation in this very department. By adjusting a certain SD card cache value, he, along with many others on xda who tried this out, were able to significantly improve read speeds, usually at least doubling or tripling them, and in certain cases going even higher.

I thought it was a pretty interesting concept, so I decided to give it a run on my OG Moto Droid and outline my results here. It is worth noting that this process only focuses on the read speed of the SD Card and has no effect whatsoever on the write speed.

You must have root access with write permissions to /sys in order to modify any of the following values.

The basic idea behind this fix is to modify the amount of available read-ahead cache for reading SD Card data. By default, most ROMs will have anywhere from 4KB (for example, on the EVO 4G running Fresh) up to 128KB set aside for this task. In order to find the cache size on your device, fire up Root Explorer and navigate to:

/sys/devices/virtual/bdi/179:0/read_ahead_kb

If you plan on running this test yourself, you can simply modify the value in this file, save, and test away. However, know that upon reboot, it will return to default unless you make it permanent (more on that later).

I am currently running Project Elite 4.2 (Froyo base), which provides 128KB of cache by default. For the initial test, I did not make any modification to the cache value. I ran the test three times at the stock value and each of the modified values to ensure proper readings.

To run these tests, I am using an app called SD Tools which you can grab for free in the Android Market.

First Run: 128KB

128KB-1 128KB-2 128KB-3

As you can see, my card is quite slow, with the highest read speed at a mere 5.5 MB/s. The lowest was 5.4 MB/s, making the average speed 5.43 MB/s.

For the next run, I have modified the value to 1024KB and will increase by 1024KB for each subsequent test.

Second Run: 1024KB

1024KB-1 1024KB-2 1024KB-3

The average speed for this run comes out to 7.8 MB/s which is an average speed increase of +2.37 MB/s. That's nothing to brag about, but I'll take any speed boost that I can get.

Third Run: 2048KB

2048KB-1 2048KB-2 2048KB-3

According to the XDA thread, this is the setting in which most users achieved the best performance. My results were more sporadic than the previous tests, but the average speed for this run was 7.867 MB/s, giving a very slight +0.067 MB/s advantage over the 1024KB cache size.

Fourth Run: 3072KB

3072KB-1 3072KB-2 3072KB-3

Again, my results lacked consistency. Even though the second test provided the fastest speed I've seen yet, the average speed of this run was only 7.83 MB/s, which is -0.0369 MB/s over the previous run.

Fifth Run (Final): 4096KB

 

4096KB-1 4096KB-2 4096KB-3

This run produced the best results, but still not a whole lot different than the previous numbers. The average speed this go was 8.167 MB/s, which translates to +0.337 MB/s over the previous run and +0.3 MB/s over 2048KB cache, which was the fastest run prior to this one.

Conclusion

After applying the SD card cache fix, I saw a decent increase in read speed from about 5.4MB/s to 8.2MB/s. I urge everyone to give these tests a run for themselves - you may be very pleasantly surprised, especially if you original cache value was 4KB.

Once you find the value that works best for you, can you make it permanent by flashing the appropriate file found in the source thread through ClockworkMod Recovery (there are also instructions for setting the values with RA recovery or manually for those who do not want to flash or don't have CWM/RA).

If you decide to give this a go, let us know what value worked best for you along with your phone model in the comments.

Source: XDA

Cameron Summerson
Cameron is a self-made geek, Android enthusiast, horror movie fanatic, and musician. When he's not pounding keys here at AP, you can find him spending time with his wife and kids, plucking away on the 6- or 7-string, or watching The Texas Chainsaw Massacre on repeat.

  • mo

    you mean .../virtual/BDI/179:0...

  • http://twitter.com/sumyunguy sumyunguy

    Is there any way this could damage your SD card?

    • http://www.AndroidPolice.com Artem Russakovskii

      Not really, I don't see a way this could damage anything.

  • Matt

    Since there are no moving parts it shouldn't be able to damage anything but it might use more processor and battery.

  • andr0id23

    Not to be nitpicky, but just to clarify if some users are concerned, it should be
    virtual/bdi/179:0
    I'm sure people could figure this out, but when I was new to the whole hacking scene, discrepancies like this would throw me off...

    • Cameron Summerson

      Thanks for pointing that out. We'll get it fixed right away.

  • David

    Ok, with my HTC EVO and have a 8GB Class 6 card. I did the 3048 zip, and started with 4.5 MB/s write and 15.0 MB/s read, after flashing the zip I went to 5.0 MB/s write and 60.0 MB/s read!!!!

    • Cameron Summerson

      That's what I'm talking about. I wish I would've gotten that kind of results, but I'm still using the card that came with my Droid.

    • http://www.AndroidPolice.com Artem Russakovskii

      Do you notice a significant difference while loading your pictures in the Gallery now?

    • Donatom3

      I'm having similar results on my evo. I went from 16.6mb's read to 68.2 using 3072. I have a Transcend class 6 16gb and I'm running CM7 on my EVO. Will have to load more pics in the gallery, but the ones there load pretty fast, and I have most of my apps on my sd card so this will be a welcome speed boost.
      As a note I had only 55.5mb/s using 4096
      Edit: I've hit as high as 82.3 mb/s and I'm averaging around 65 mb/s

    • andr0id23

      Nice. I tried on my OG Droid with only a class 2 8GB and went from 5.3MB read to about 10MB by upping the prefetch to 1024. I tried higher, but so no noticable increase from 1024 > 2048 > 3072. I got a 16GB class 6 and 16GB class 4 in my DX and D2 and am curious to see what I can get outa that.

      • andr0id23

        Ok didn't see as big am increase on my D1 or DInc as I did on my DX & D2. D1 went from about 5mb/s to 10mb/s. DInc stayrd solid at about 16mb/s from stock 128kb to anything I changed it to. Both my DX & D2 went from stock 128kb at about 11mb/s to a peak of around 36mb/s. Both seemed to find the sweet spot at 2048kb I believe.

  • Christian

    Just ran SD Tools on my Galaxy Tab. The program showed that I had over 11GBs of space left. That's not my micro-SD card, that's that internal memory that came with the Tab. How do I run the test with my micro-SD?

    • Kevin

      Ummm...the 11GB free (of 16GB) is the SD card. Pop the card out and you'll see....16GB Samsung card. The Tab doesnt come with 16GB of internal RAM.

  • mo

    i got the best results with 2048kb

  • rootnewb

    I have the PnK CM7 rom on my DHD... Apparently my reading speed is at 118.6MB/s... I might not need this fix. lol

  • http://iandouglas.com Ian Douglas

    Wish these kinds of cache values were available for non-rooted devices. I'd love to see if an increased cache would perform any better on the Nexus S, even though technically it's not external SD storage.

    • Coldman

      You have to wonder, since both ROM and SD card are flash memory, can you not perform the same tweaks to the ROM? Is it a matter of finding the right device id?

    • Donatom3

      I just modified the tweak to work with the internal memory on my G-Tablet, it caused an increase from 13mb/s to 60mb/s.

      • http://www.AndroidPolice.com Artem Russakovskii

        Details?

  • Al

    HTC EVO 4G
    CM 7 RC4
    Savaged Zen Kernel 1.0.1 (2.6.38.2)
    16 GB Class 4 SD card
    Value that was best for me was 3072

    Original: R: 14 MB/s, W: 4.7 MB/s
    With Fix: R: 62 MB/s, W: 4.6 MB/s

    • Coldman

      Damn, that's boss.

  • Chris Ponciano

    Holy crap man, I'm hitting just a notch below 80MB/s now.

  • Bobbi

    what does a novice like me do about no memory on my phone. Everything that can be moved to the sd card is moved, old e-mails, text messages and photos are deleted and I only have a few apps..

    • Coldman

      This is way offtopic here.

    • Simon Belmont

      Try going into your settings, then applications, then manage applications. In there you can order your applications by size.

      Once you do that, delete the cache for the top offenders of space usage. Mind you, this is really only a temporary fix but it works in a pinch if you want to squeeze in another app or two.

  • http://www.geeknik.com/ geeknik

    Why was your fifth run using 4096MB?

    Why would I need a 4GB cache?

    • Stunt Dr1ver

      That was clearly a typo.... It should be 4096KB, i.e. going from 128KB to 1MB, 2MB, then 4MB. Hard pressed to have 4GB of cache when even the kickass phones are only coming with 1GB of RAM.

    • ari-free

      heh that's probably in KB just like the others

  • John J

    HTC Aria, CM7, stock 2gb C2.

    My Read went from 9 to 33 using 3024. Definite speed increase when using things like Gallery.

    I have an 8gb C6 coming in tomorrow, interested to compare them.

  • Logan

    I tested my Desire HD w/MIUI 2.3.3 (without modifying the cache) and got 4.6MB write and 133.2MB read.

    The read number is so high that I suspect there's a compatibility problem with the SD Tools app. Is there another way to test the speed, just to be sure?

    • Jc

      Format your sd to 32k cluster size,
      you should get correct readings from there. Probably not a bad idea anyway for 720p recording.

  • http://linkedin.com/in/calcpereira CaLcPereira

    Motorola Milestone with mod ROM ShadowModBR 2.2.1
    stock was 128kb cache result was 11.6MB/s
    upped it to 1024 and got 20.1MB/s
    then upped it to 2048 and got 35.7MB/s

  • aLb3Rt

    Weird. I got 61W and 11R with only 512k - Thunderbolt

  • Chris Ponciano

    I went back and did some more tests, even jumping up to 8192 and the numbers started going down after 4mb of cache, i read the xda thread and they suggested the best setting seemed to be 3072 so i tried it and yep, it bumped me from ~80mb/s on 4mb of cache to 122.9MB/s with the 3mb setting.

    http://i.imgur.com/bxWkv.jpg

  • http://androidpolice.com aloha1973

    WOW!
    very cool: went
    from write 3.9, read 5.9 on 128 KB
    to write 5.2 read 20.1 on 2048 KB!!!
    thanks for sharing this!!!

  • Chuy

    holy crap mine was originally 4kb and out of all the tests i got the best results on 3072 my writing speed was 3.2 and reading speeds were always from 16 to 17.0

  • Pugz

    DInc running Athena 1.2.
    Just spent $4+ on Root Explorer for no immediate gain... Once I go back to CM ES File Explorer would've done the job again. Thx 15min return policy... Ah well, hopefully it went to a cool dev, I'm sure it did.

    16GB Class 4 Kingston
    Saw no difference from the default (4) up to 4096... :(
    10MBps write
    6MBps read

  • civil

    Wonder what this would do for rooted Nook Colors running off sd cards.

  • bhtoque

    Looks like 3072 does the trick for me. Great tip.

    @128 W5.4 R11.9
    @ 3072 W7.7 R43

    Evo w/Sandisc 32gb class 2
    Running Warm 2.2 release 5

  • http://none hash

    When I save the /sys/devices/virtual/bdi/179:0/read_ahead_kb file, it doesnt get saved. The value remains 128 when I open it again immediately.

    What could be wrong?
    HTC Aria running Liberated Aria (froyo) rom.

    • Kane

      Sounds like you don't have write access to your /sys directory. Is it mounted r/w in Root Explorer?

  • Leonid

    I'm not a big expert on this issue, so it would be great if someone explained -- what is the real-life impact of increasing the readahead. The article talks about a score in a synthetic test, which doesn't seem very useful.
    As far as I understand (and again, I'm no expert), there is no gain. The readahead should improve the performance in case of a big sequential read from the SD. Do we ever read the data sequentially? Do we ever read enough data to feel the improved readahead? When we do read data sequentially, does performance really matter? (The biggest sequential read I can think of is an mp3 file, and then I need to read ~10Mb in 5 minutes, orders of magnitude slower than the speed of an SD card.)
    I can't really understand how FAT32 (developed for the magnetic media, should improve the sequentiality of the reads), flash (inherently good for random I/O) and SD wear-leveling (which just confuses everything) influence the reasoning above.

  • Eggcake

    Also, you are measuring the speed of the cache and not of the SD itself.

    So I agree - unless there are some kind of "real world" tests, I don't think there is a big improvement.

    @Leonid
    The file doesn't need to be big in order to get a large sequential read. It can also be the case when opening applications or viewing pictures.

    • Leonid

      Sorry, I don't see how "the file doesn’t need to be big in order to get a large sequential read". How can you get a large sequential read from several different files? Statistically, they are scattered all over the filesystem.
      Again, it's hard to say if reading a large file actually results in a large sequential read (FAT32, wear-leveling, blah-blah), but the opposite is almost certainly not true.

  • Umut

    I have class 4 toshiba 16gb sd card.

    Read speed was 14.4 mbyte/sec at default setting.

    27.3 mbyte/sec at 2048kb
    33.2 mbyte/sec at 3072kb - sweet spot
    29.2 mbyte/sec at 4096kb

    Thanks for tip

  • crueztnick

    Hi Guys, I got the best result on samsung gt-5510 with stock ROM at 2048 with read speed 18.9 MB/s and write speed 5.7 MB/s. Note: not a significant change from 128 (the original).

    This is good. How to make this change permanent?

  • kelvin

    write 43.5 mb/s
    read 1129.9 mb/s
    what does this mean?
    galaxy s gingerbread

  • kelvin

    just download sdtool and test it that what it show. do I need to tweak?

  • http://www.linuxzone.se JasoX

    SE Xperia X8 With Jerpeleas CM7 2.3.3 RC4 007.

    Original read(128kb): 14.2 mb/s
    Modified(4096kb)read: 29.2 mb/s

    Awesome tip!!

  • Justin Case

    Read ahead is a kind of cache, right? Could this thing create a risk of a cache coherency issue (data corruption) in case of reset/reboot/program fault?

  • Zohan

    Nexus One CM7 RC4

    3072kb is the fastest for me

    Original write speed (128kb): 3.4
    Original read speed (128kb): 18.7

    Modified write speed (3072kb): 8.5
    Modified read speed (3072kb): 68.3 !!

    Thanks for the tip!

  • Timothy

    Wow. This is a great post. I'm surprised I missed that thread on xda, since I frequent it numerous times a day.

    Thanks for the heads up!

  • Ankur

    Is there something wrong with the SD tools app..

    with 128 kb read ahead cache

    i got 127 , 128 , 140 mb/s read speeds

    http://img853.imageshack.us/i/htcdesirehd201104051812.png/

    http://img543.imageshack.us/i/htcdesirehd201104051810.png/

    http://img18.imageshack.us/i/htcdesirehd201104051809.png/

  • John

    Also, if you're rooted & don't feel comfortable doing any of what is described, there's the sd tools card app that lets you toggle the cache value in-app:

    https://market.android.com/details?id=com.vaelek.sdspeedboost

    (tho it does cost .99)

  • http://xperiaminicyanogen.wordpress.com/ Devfrost

    I have tested it using the sd tool I use a class 6 sd card which would explain the higher speed.

    write speed : 16mb/s

    Read speed : 17mb/s

    Now I've checked by firing up the 3D gallery and oh my it's fast. It only took a second to load up all the albums and when I open it and slide through the end, it rarely show a blank grey screen and when I open one of them, it don't show a blank screen even for a second. That's a huge improvement.

  • http://androidized.com Lucian Armasu

    Won't this accelerate the life cycle of the SD card (make it reach its death sooner) by writing more cache data to the SD card every time?

  • http://www.cypher-sec.org thecolor

    wow, got a pretty good boost with the basic 2048kb change. from 4.5MB/s at 4kb to 32.2MB/s from the stock card on my HTC EVO. :D

  • http://www.gradweil.de alvinx

    Milestone CyanogenMod 6.1.2 @900MHz

    During my first few runs write speed were much too slow, W 1.1 or W 2.1, I didn't mentioned these runs below.
    But after running it multiple times, the write speeds were useful, just to mention it.
    Read speeds were already improved during the first runs.
    So you have to run this benchmark multiple times and see the average.
    The results vary from run to run.
    Sweet Spot: 3072

    I will test it in real life during the next days, especially curious if the crappy gallery performance will improve…?

    128 (Default)
    W 5.4 6.3 6.9
    R 15.0 16.7 15.8

    512
    W 6.4 6.8 4.4
    R 21.1 14.8 19.1

    1024
    W 6.8 7.1 6.8
    R 25.9 25.4 22.6

    2048
    W 6.5 6.8 7.0
    R 35.2 33.5 32.9

    3072 (Sweet Spot)
    W 6.4 6.8 7.5
    R 32.4 33.7 36.7

    4096
    W 6.1 5.9 4.9 6.4
    R 33.1 28.9 28.6 26.5

  • Jeff

    This did WONDERS for my Droid 1 performance. Boot up seems faster, Gallery app is way faster, transitions to desktop from apps are way faster.

    This hack kicks ass. Thank you so much for posting this.

  • Millhouse

    Has anyone tried running this again since the sd tools app was updated today (6th April)?

    I was trying it earlier and seeing major improvements originally 20mb/s read then up to 50-60mb/s read with cache set at 3072kb on my Desire

    now after updating the app it seems to be staying consistently around 20mb/s read with only a 1-2mb/s variation from adjusting the cache size?

    can anyone else confirm this or is it just me?

    • Millhouse

      ****NEVER MIND***

      just had a quick read through the XDA thread, it seems that the SD tools app was giving false reports of massive speed increases due to the way it measured the read speed.

      anyone noticing the speed increases in the gallery - this is because your phone now caches more pictures at once - hence the name "read-ahead cache" I suppose.

      while this is arguably still a benefit of adjusting the value. it is definitely NOT dramatically increasing the read speed of your sd card as advertised.....

      • John

        Yep...exactly :)

      • GraveUypo

        that's what i thought. i installed this and it benchmarked some pretty relevant numbers, but i couldn't notice any diference in pratice so i uninstalled it. didnt feel a diference still after uninstalling so never installed it again. waste of RAM.

    • Jeff

      My performance significantly improved after installing this fix. Whether or not it actually increases SD Card speeds is irrelevant to me…the improvement was noticeable.

      I have a Droid 1, so that might be part of it. Maybe the larger cache size is of more value to systems with less memory (RAM).

  • Peter T

    Fresh EVO Rom
    Kingston 32 class4
    4k - 5.0 avg w/ 5.5 avg r
    4096k - 5.0 avg w / 19 avg r

    Great work! Brainmaster and xda

  • Wynnded

    I gave this a try on my Thunderbolt. I get the same speeds before and after. 5 write / 20 read.

  • Jeff

    My performance significantly improved after installing this fix. Whether or not it actually increases SD Card speeds is irrelevant to me...the improvement was noticeable.

    I have a Droid 1, so that might be part of it. Maybe the larger cache size is of more value to systems with less memory (RAM).

  • Musa

    hmm.. on my galaxy S i9000 with darky rom 10rc4 i'm getting 9.0mb/s write and 15.0 mb/s read by default.

  • Jakkemakke

    I had a go at this on my stock rom HTC Desire. For me it was very noticeable. Gallery loads faster, programs start faster, text messages come up instantly now. Copilot startup is very quick now. Every bit of extra speed helps. Great tweak!

  • rockinggokul

    motorola atrix
    CM7 beta @1100MHz

    note: antutu benchmark used
    (too lazy to download sd tools :P)

    8GB CLASS II :

    original score : @ 128 -default
    W-4.3
    R->30

    @ 1024 :
    W-5.1
    R-18

    @2048 :
    W-7.8 !!!!
    R->30

    @3072 :
    W-6.2
    R->30

    definitely works!!!
    thanks for sharing this guys!!!

  • SteampunkDroid

    Tried it on:
    Samsung Galaxy Next S5570 (Mini or Pop as you wish).
    CyanogenMod 7.1 Android 2.3.5
    Result: no changes on all setting.

    (I've run Antutu bench)

  • https://plus.google.com/u/0/105825578682011837988/posts Scott W

    Samsung Epic Rooted and nothing else done to the system.

    %Change is referencing to the default

    128KB Default (Average of 3 tests)
    Write: 8.9
    Read: 15.67

    1024KB (3 test average)
    Write: 8.03 %Change -9.58
    Read: 22.43 %Change 43.54

    2048KB (3 test average)
    Write: 9.77 %Change 9.73
    Read: 21.9 %Change 40.62

    3072KB (3 test average)
    Write: 9.77 %Change 10.27
    Read: 22.53 %Change 44.49

    4096KB (3 test average)
    Write: 10.97 %Change 23.36
    Read: 22.77 %Change 46.36

    I found it a little weird that my write increased, didn't expect that to happen.

  • bob marley

    Does mucking with this system value correlate to sdcard mount changing to Read Only?

  • Naseer

    Phone Model: Samsung Galaxy Pro
    Original Cache : 128 R Speed: 11.0
    Cache : 2048 R Speed: 15.7
    Cache : 7168 R Speed: 16.1

  • Ryan S

    Weak, no matter what I only get about 16-18 read.

  • Atif

    very odd question, but i am new in this field and badly want to increase the speed. can you tell me how to edit "read_ahead_kb"? When i tap it ask me to choose application for completing action.

    Thanks in advance

    • Atif

      Got it. i was using CM7 default File Manager.

  • Swity0192

    Is their any apps like this available for windows or mac platforms? thanks.

  • Martin L

    No wonder, since SDCard transfers happen in blocks; the bigger the buffer, the faster the transfer. But don't forget the "buffer" is in memory, so as you increase it the memory consumption increases too...

    Martin

    • http://twitter.com/meejah meejah

      Not really; page-cached pages are freed as-needed by the kernel so although technically they're "in use" your apps won't really see that.

  • Jose

    Very nice, but one question.

    I'm using A2SD on my Desire with a 1GB ext3 partition. This hack will increase the read speed on ext3 partition as well?

    • http://coffeecone.com/ S. Surashu

      Don't you mean Link2SD?

  • http://coffeecone.com/ S. Surashu

    Mine seems to fare well with setting it to 4096. I already start to notice the speed difference when I rebooted my phone.

  • Masesaco

    Original was 128
    Best was the maximum value (4096)
    (I´m installing all apps on SD)

  • Lysander

    Samsung Galaxy Gio
    128 kb Cache

    SD: Sandisk Class 4 16GB
    Write: 4.08
    R:13.6 >>> This is totally wrong. It should be 3-4mb max.

    SD: Sandisk Extreme Pro 16GB 633x 95mb/s
    Write: 10.1
    R:22.2 >> This calculation did take about 1 sec

    And after this SD card, my phone never hangs, using custom rom with A2SD 2GB internal and 256mb swap.

    Thanks to developers...