[Script][CWM] Increase Read Cache for better SD Card access

Search This thread

Zeuszoos

Senior Member
Aug 9, 2012
1,091
211
Hi,

Thank you in advance for your time (Dev and/or others)!

I tried this by manually editing the file and it definitely works! :)

A question though; Does this affect just the Internal Storage? Or does it also affect the External SD Card as well?

Also, I would like to set the Scheduler to Deadline. There are many apps (SD, CPU, etc.) that will do that, but when I look at my setup (sys info app), it shows for every one of them, that it is only setting it for the Internal Storage, but not my External Storage. Who wants to run one (Internal) using Deadline and the other (External) using the Default CFQ? :)

Is there some way, editing a file, or an app (pay is fine) that can/will handle this? Does anyone have any type of solution for this issue, please?

To be 100% accurate, I should have said that JRummy's ROM ToolBox will do it, but it's an entire package of (great) apps/functions and I really don't want to install an entire suite of things that I already have covered with other apps individually, which is how I prefer it, so that I can purchase the best one there is for each function. And that method has worked well for me, so why change it now? :)

Thank You Again! :)

---------- Post added at 12:09 PM ---------- Previous post was at 11:49 AM ----------

Many people are wondering why higher read ahead cache sizes aren't used in stock ROMs since they show significantly higher read speeds in benchmarks. Well the reason is because a benchmark is just a benchmark. The benchmarks applied to test the SD card speeds tend to test SD cards under maximum pressure. However this is not usually the case. This means that in normal use, where the device is accessing a few small files, as opposed to one large file during a transfer or download, a smaller read ahead is better to reduce lag. A large read ahead means that even when accessing extremely small files, the read ahead size must be met, which creates wastefulness and reduces performance. This is the reason why just placing the read ahead size at maximum is not the best and shows slower speeds sometimes.
Hi,

I will state emphatically that under every day usage:

No Boost = Crawl
Boost = Big Boost!!!

TTYL

---------- Post added at 12:20 PM ---------- Previous post was at 12:09 PM ----------

Hello folks,

I just released SD-Booster 2.0 on Google Play.

Features:

-MMC detection framework to support any SD-Card and SD-Memory
-Speedup every external and internal SD-Memory
-Configure each SD-Card/SD-Memory separately (New!)
-Set on system start (boot) feature
-Device monitoring (New!)
-Notification system (New!)
-Color based suggestion terms of current cache size
-Multi-Language support (New!)

I want to show you the advantages of SD-Booster:

Well, every card is a different - Right! I'm not only talking about size or manufactor,
i'm talking about classes (2-10) and the filesystem which is used. Finally the content,
your data files are importent anyway.

So, there are a lot of possible constellations and each one needs a perfect cache size
for the best result. SD-Booster used for every single card a unique signature.
So, SD-Booster knows your setting for each single card. This feature together with
the "monitor" (insert/eject/mount card) feature makes SD-Booster very good for any
case of tuning.

However, i hope you'll test my little app and i have a open mind for any feedback. :eek:

Link: https://play.google.com/store/apps/details?id=de.mehrmann.sdbooster

Regards,
Akusari
Daniel,

I have used this/your app for years and loved it!

However, with the brand new (verified genuine) 64GB, exFAT, Class 10 External SD Card, SD-Booster sees it when I boot my Rooted, SG Mega 6.3", KitKat 4.4.4 on MegaKat ROM (tweaked Stock OEM).

But after a few minutes, it just loses it. It even disappears from the app when you open it and reading from my Ext SD Card slows WAY down!

I'd be happy to test any (install Apk's) for you if you so desire to see what's going on and report back quickly (same day!). Again, if you're so inclined. :)

Just FYI; Yes, I was using the latest version.

Thanks!

---------- Post added at 12:29 PM ---------- Previous post was at 12:20 PM ----------

Hi! :)

Just FYI for everyone, I use Philz Touch Recovery 6.48.4, which is based on CWM 6.0.5.0 (and even uses the same backup folders), so I figured I'd give flashing the 2048KB Zip a shot.

Unfortunately, the installation fails, so save yourself the time and just use the app referenced in the OP. :)

TTYL
 

Zeuszoos

Senior Member
Aug 9, 2012
1,091
211
Dev,

I have been using the app version (set at 2MB) and it definitely makes a huge difference! Much, much smoother!

Thanks! :)
 

Zeuszoos

Senior Member
Aug 9, 2012
1,091
211
BrainMaster,

I tried the Zip on my SGH-M819N Samsung Mega (MetroPCS), KK 4.4.4, Factory OEM ROM, with PhilZ Touch Recovery (CWM based).

It didn't work (error) and I don't even know what "RA 1.7" is, so I didn't try that one.

I'm not experienced with making scripts, but I did make my device init.d capable now. That way at least I could pretend I know what I'm doing. <lol>

What do you suggest for me? I'd like to be able to use a Zip to Flash it, but don't know what to change in the one you provided, or if it's because it won't work on a Samsung, or something?

I'm not a noob to Android, just to scripts (although I do know *what* they are).

I would be grateful for any help that you or anyone could give me!!!

THANK YOU!!!
 

Bosssirsi

New member
Nov 29, 2015
2
0
why you limit this cache storage 3072KB what happen if this value set 512000KB ?

official roms limit cache size 128KB for increase quick speed suggestion is this value set to 3072Kb
what happens if i set this value to more then 500MB (512000KB)
official roms Cache size limit to 128kb may be some reasons behind this for their limit
 

royitoroy

Member
Apr 7, 2009
20
0
hello well i have mi lg g4 stylus h630 loolipop 5.0.2 rooted stock firmware and would like to increase the sdcard speed so...
which way do u thinks its better, safer or stable?

the cwm way (i dont have it so i would install it if it need)
the script by root explorer
or the akusari (sdbooster) app

pd: my cache size in the file /sys/devices/virtual/bdi/179:0/read_ahead_kb its
512
 
Last edited:

LordAlberto

Senior Member
Nov 3, 2016
158
61
Manchester
Thanks for this. Just updated from CM14 to Lineage on Oppo R7S and had constant skips and jumps playing FLAC from usb, whereas CM13 was silky smooth. :good:
 

Sephiroth79

Senior Member
Jul 3, 2017
108
2
Hello.

I am trying to increase sd card read/write speed on a rooted Honor 6X with no luck.

I am using sd card as "adoptable storage".

I've tryed to flash appropriate file using TWRP but it does not work, sdbooster app won't run (starting and immediatly closing).

Any idea on how to fix it?

Thanks,

Andrea.
 

bhavtosh76

Senior Member
Feb 8, 2018
65
4
Hi,
I tried both solutions, Flashing via recovery & writing both files. After reboot 128 remains there. I have proper rooted phone Xperia C2305 5.1
 
For those who have no CWM and no init.d on their rooted phone, you may try Termux to run the script on boot. Learn more here: https://wiki.termux.com/wiki/Termux:Boot
Here is my Termux script:
#!/data/data/com.termux/files/usr/bin/sh
if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]
then
sudo -u root /system/bin/sh -c "/system/bin/echo '2048' > /sys/devices/virtual/bdi/179:0/read_ahead_kb"
fi
 

Top Liked Posts

  • There are no posts matching your filters.
  • 293
    Many of us are disappointed about the reading speed of the SD Cards on our Android Phones. It doesn't matter if you have fast 10 Class SD Card, it performs very poorly on the Phone comparing how it performs on the PC.

    The clue is the Cache size for reading from SD Card. It's set to 128 KB, on some ROM's even to 4 KB!


    You can check for yourself your Cache size by looking into this file:

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


    You can change it manually but it will be reverted to default on the reboot. The changes need to be done permanently by loading the script on the startup through the init.d.


    Or you can flash the CWM zip files that I made for you.

    For RA 1.7 Recovery zip look into this post. Many thanx to user laie1472 for making them.

    You must find which Cache size fits best for your SD Card. In my case its the 3072 KB Cache size.At best, use the Root Explorer to change the value, then run SD Tools Benchmark - finally flash the CWM zip file that fits your SD Card.

    Here are two screenshots - the first one shows the reading speeds with the default Cache 128 KB and the second one is with the 3072 KB Cache with my Class 4 SD Card on CM7 RC2 by Charnsingh.


    The Benchmark is made with the SD Tools program. Caution: The SD Tools developer states that his benchmark sometimes gives inaccurate readings.

    If you want to convince yourself of the speed improvement after applying the fix, just open your Gallery and see how fast it loads the photos!

    Suggestion: 2048 KB Cache size performs at best for most of the SD Cards!


    If you don't have CWM then you can do following:

    Make a file with this content:

    Version 1:
    #!/system/bin/sh
    if [ -e /sys/devices/virtual/bdi/179:0/read_ahead_kb ]
    then
    /system/xbin/echo "128" > /sys/devices/virtual/bdi/179:0/read_ahead_kb;
    fi;
    Version 2 (If the Version 1 is not working for your ROM - credit goes to rafpigna):
    # Tweak mmc read-ahead - rafpigna -
    mmcfolder="/sys/devices/platform/msm_sdcc.2/mmc_host/mmc1"
    cd $mmcfolder
    folderlist=`ls -1`
    mmcresult=`echo $folderlist | grep -o '\bmmc1:\w*' | sed 's/mmc1://'`
    echo 128 > /sys/devices/platform/msm_sdcc.2/mmc_host/mmc1/mmc1:$mmcresult/block/mmcblk0/queue/read_ahead_kb
    cd /
    Change the red marked number from 128 to what you need (example 2048) and save it as "99sdcardreadfix", copy it with the Root explorer or push it with ADB into /system/etc/init.d and set permissions to 777. Reboot.




    Some of the ROM chiefs have hardcoded this values in the init, that can't be changed - only by the chief himself.

    Some of the ROM's already contain this tweak in another script that is saved in the init.d folder. Probably it's tagged with the number 99 in the filename to be sure that it's executed at last. You have to change it there.

    Rafpigna - the HD2 Android chief - pointed that out over here.





    For ROM Cookers - add this line into init.rc file:

    # sd card read speed fix
    write /sys/block/mmcblk0/bdi/read_ahead_kb 2048
    UPDATE: There is now free app on the market that do this for you.


    htc%20htc%20hd2%202011-04-07%2002-39-44.png
    htc%20htc%20hd2%202011-04-07%2002-42-06.png
    20
    Great Mod All Results are from the sd/tools app posted in the op
    I took the zips from the op and made them flashable for those who want them and for those who are using RA1.7,1.6 etc also for those using CWM 2.5



    4069= w/s 5.6 r/s 13.7

    Download zip here For Ra.1.7
    http://db.tt/3Lvbazr


    2048= w/s 7.9 r/s 21.7

    Download Zip here For RA1.7
    http://db.tt/V3mAVyV


    3072= w/s 6.6 r/s 20.1

    Download Zip here For RA.1.7
    http://db.tt/WJDdgxB


    1024= w/s 7.1 r/s 17.5

    Download Zip For RA1.7 here
    http://db.tt/Oss3SKD


    Also if you try this mod and want to revert just flash the stock zip here

    http://db.tt/nW8SVWA



    The results posted from each zip are mine with with the setup posted below. Diffrent sd/cards will produce different results.

    Running this on a
    Class4 sd/card 16gb 1024ext2 partition


    @Brainmaster Great MOD BIG THANKS
    7
    Tasker - Apply Settings on Device Boot

    For those of you that use Tasker, I've knocked up a profile that will set your chosen value when the device boots and confirm it has successfully done so.

    You'll need the locale execute plugin.

    Edit action number #2 with your chosen cache size and a different file path if necessary.

    Job done...

    Edit: When testing for the best settings, 'apply' out of Tasker and go back into the application between each change - You may also have to give permission via the SuperUser application before the settings will stick. You can also variable clear %SDCACHE at the end of the task if you don't wish to use it anywhere else. Tidy files, tidy mind.
    5
    The Downside to Higher Reach Ahead Cache Sizes

    Many people are wondering why higher read ahead cache sizes aren't used in stock ROMs since they show significantly higher read speeds in benchmarks. Well the reason is because a benchmark is just a benchmark. The benchmarks applied to test the SD card speeds tend to test SD cards under maximum pressure. However this is not usually the case. This means that in normal use, where the device is accessing a few small files, as opposed to one large file during a transfer or download, a smaller read ahead is better to reduce lag. A large read ahead means that even when accessing extremely small files, the read ahead size must be met, which creates wastefulness and reduces performance. This is the reason why just placing the read ahead size at maximum is not the best and shows slower speeds sometimes.
    5
    Hello !

    I wrote a little App to do this at once!

    SD-Booster comes with a easy to understand UI and sets all stuff automaticly during the Android boot process. It's free. Just search on the market for "SD-Booster" by Akusari.

    Have fun!