[FIX][CWM] SD Card fix for reading speed

Search This thread

brainmaster

Inactive Recognized Developer
Dec 10, 2006
4,064
4,507
Huawei Watch
OnePlus 7T Pro
Many of us are disappointed about the reading speed of the SD Cards on our HD2. It doesn't matter if you have fast 10 Class SD Card, it performs very poorly on HD2 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 it's even set 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.


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
How to install the CWM zip files:

In the MAGLdr menu or in CWM menu you navigate with the Volume rocker buttons "Up" and "Down", Call button is for "O.K." or "Confirm", the EndCall button is for "Back".

If you have a CWM zip file (open the zip file, if it contains the METAInf folder then its a CWM zip file), copy it to your SD Card (I use a folder called Android Files on my SD Card).

Then power-off your Phone and start the MAGLdr menu by Holding the Power button until the MAGLdr menu comes.

Go down to AD Recovery and press the Call button to start the CWM.

In the CWM menu go to "Install zip from sdcard", then "choose zip from sdcard". Navigate to the folder where you copied your zip file and choose the zip file.

After the zip file is installed, restart your Phone.
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
 

Attachments

  • SDCardSpeedFixDefault128KB.zip
    155.7 KB · Views: 1,719
  • SDCardSpeedFix1024KB.zip
    155.7 KB · Views: 1,694
  • SDCardSpeedFix2048KB.zip
    155.7 KB · Views: 5,761
  • SDCardSpeedFix3072KB.zip
    155.7 KB · Views: 3,660
  • SDCardSpeedFix4096KB.zip
    155.7 KB · Views: 3,230
Last edited:

matmar

Senior Member
Aug 15, 2008
710
73
ram rom

Can it be used on RAM ROM ?
Imilka S vivo for example ?
thanks in advance
 

brainmaster

Inactive Recognized Developer
Dec 10, 2006
4,064
4,507
Huawei Watch
OnePlus 7T Pro
I ran it aagain and it reduced only by 1 but thank you very much anyway becuase the reading speed jumped from 20 mb to 88.5mb and just out of curiosity what does the reading speed speed up? faster launching of programs?or something else.

Thanks

Everything that is on SD reads and loads faster - you can notice the difference when looking the pictures in the gallery.
 
  • Like
Reactions: beston94

rikardo1979

Senior Member
Jan 29, 2009
1,736
245
Poole, UK
So I've tested all fixes to find out which is the best for me and here r the results

I running on JW3s MIUI 1.3.18
SD Card - Kingston 8GB Class 4

fix1024KB - 8.5 / 65.2 MBs
fix2048KB - 8.7 / 106.9 MBs
fix3072KB - 7.2 / 40.0 MBs
fix4096KB - 8.4 / 90.3 MBs

So if some1 have the same card the best fix for u is 2048Kb .;)
:cool:

Thanks again brainmaster, great job ;)
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 54
    Many of us are disappointed about the reading speed of the SD Cards on our HD2. It doesn't matter if you have fast 10 Class SD Card, it performs very poorly on HD2 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 it's even set 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.


    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
    How to install the CWM zip files:

    In the MAGLdr menu or in CWM menu you navigate with the Volume rocker buttons "Up" and "Down", Call button is for "O.K." or "Confirm", the EndCall button is for "Back".

    If you have a CWM zip file (open the zip file, if it contains the METAInf folder then its a CWM zip file), copy it to your SD Card (I use a folder called Android Files on my SD Card).

    Then power-off your Phone and start the MAGLdr menu by Holding the Power button until the MAGLdr menu comes.

    Go down to AD Recovery and press the Call button to start the CWM.

    In the CWM menu go to "Install zip from sdcard", then "choose zip from sdcard". Navigate to the folder where you copied your zip file and choose the zip file.

    After the zip file is installed, restart your Phone.
    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
    7
    I'm using the read-ahead "trick" in my roms from months.
    During my researches I found that yes, using an high values improve the read speed but only on BIG files. During daily use using an high value can give less performances.

    But I have to say also never tried with so high values

    The reason people using my roms are not able to change it using my roms is that the 128kb value is "hardcoded" in init.

    Anyway I'm changing the value in the "real" mmc device, not in the virtual one.

    This is my command

    # 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 /

    Needed because every sd use a different "identification code"
    This is contained in the 99complete file in /system/etc/init.d

    If some one want to try to experiment high values, change the "echo 128" in this file
    5
    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
    1
    is the reading the only thing that improves drastically?

    Yes, the writing speeds are not reduced or influenced by the Cache size.
    1
    thx very much

    Thank you very much, this solved my sleeping problems (of the phone :))
    people like you make the world a better place , at least the virtual world xD