Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,730,490 Members 41,163 Now Online
XDA Developers Android and Mobile Development Forum

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

Tip us?
 
brainmaster
Old
(Last edited by brainmaster; 7th April 2011 at 07:22 AM.)
#1  
brainmaster's Avatar
Recognized Developer - OP
Thanks Meter 4490
Posts: 3,898
Join Date: Dec 2006

 
DONATE TO ME
Default [Script][CWM] Increase Read Cache for better SD Card access

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:
Quote:
#!/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):
Quote:
# 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:

Quote:
# 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.


Attached Files
File Type: zip SDCardSpeedFixDefault128KB.zip - [Click for QR Code] (155.7 KB, 7360 views)
File Type: zip SDCardSpeedFix1024KB.zip - [Click for QR Code] (155.7 KB, 8053 views)
File Type: zip SDCardSpeedFix2048KB.zip - [Click for QR Code] (155.7 KB, 30134 views)
File Type: zip SDCardSpeedFix3072KB.zip - [Click for QR Code] (155.7 KB, 11622 views)
File Type: zip SDCardSpeedFix4096KB.zip - [Click for QR Code] (155.7 KB, 15804 views)


Buy me a Coffee - here for US and here for EU.
The Following 291 Users Say Thank You to brainmaster For This Useful Post: [ Click to Expand ]
 
opher50
Old
#2  
Senior Member
Thanks Meter 97
Posts: 555
Join Date: Nov 2010
Sounds great! I will wait for some more people to give they're thoughts about it ... does it matter which phone you use? or only the SD card class?
The Following 2 Users Say Thank You to opher50 For This Useful Post: [ Click to Expand ]
 
brainmaster
Old
#3  
brainmaster's Avatar
Recognized Developer - OP
Thanks Meter 4490
Posts: 3,898
Join Date: Dec 2006

 
DONATE TO ME
Quote:
Originally Posted by opher50 View Post
Sounds great! I will wait for some more people to give they're thoughts about it ... does it matter which phone you use? or only the SD card class?
You need to have that file on your Phone as the CWM is directory related. Find which one works best for your SD Card.

I already posted that in the HD2 section.


Buy me a Coffee - here for US and here for EU.
The Following User Says Thank You to brainmaster For This Useful Post: [ Click to Expand ]
 
Cuspide
Old
#4  
Senior Member
Thanks Meter 10
Posts: 130
Join Date: Jul 2007
You can flash with xrecovery?
1024 seems fine with my 32go sd card

Sent from my X10i using XDA App
 
brainmaster
Old
#5  
brainmaster's Avatar
Recognized Developer - OP
Thanks Meter 4490
Posts: 3,898
Join Date: Dec 2006

 
DONATE TO ME
Quote:
Originally Posted by Cuspide View Post
You can flash with xrecovery?
1024 seems fine with my 32go sd card

Sent from my X10i using XDA App
You can try it. If it doesn't work, then it wont be flashed.


Buy me a Coffee - here for US and here for EU.
 
Cuspide
Old
(Last edited by Cuspide; 27th March 2011 at 10:42 PM.)
#6  
Senior Member
Thanks Meter 10
Posts: 130
Join Date: Jul 2007
Not working with xrecovery, still 128 after reboot .. ;)

Sent from my X10i using XDA App
 
brainmaster
Old
#7  
brainmaster's Avatar
Recognized Developer - OP
Thanks Meter 4490
Posts: 3,898
Join Date: Dec 2006

 
DONATE TO ME
Quote:
Originally Posted by Cuspide View Post
Not working with xrecovery, still 128 after reboot .. ;)

Sent from my X10i using XDA App
If you don't have CWM then you can do following:

Make a file with this content:

Quote:
#!/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;
Change the red marked number from 128 to what you need (example 2048) and save it as "77sdcardreadfix", copy it with the Root explorer or push it with ADB into /system/etc/init.d and set permissions to 777. Reboot.


Buy me a Coffee - here for US and here for EU.
The Following User Says Thank You to brainmaster For This Useful Post: [ Click to Expand ]
 
skymera
Old
#8  
Senior Member
Thanks Meter 59
Posts: 452
Join Date: Mar 2010
Location: Bracknell
Not sure if this an error but the format it needed to be in ADB was

echo "2048" > /sys/devices/virtual/bdi/179\:0/read_ahead_kb
 
opher50
Old
#9  
Senior Member
Thanks Meter 97
Posts: 555
Join Date: Nov 2010
Does it really work? :S

Flashing with CWM means what? I do Install From Sd card? or ?
 
CallMeAria
Old
(Last edited by CallMeAria; 28th March 2011 at 07:42 AM.)
#10  
CallMeAria's Avatar
Senior Member
Thanks Meter 291
Posts: 1,460
Join Date: Aug 2010
Location: Murrieta, CA

 
DONATE TO ME
Quote:
Originally Posted by opher50 View Post
Does it really work? :S
Yes and no. For me it didnt affect write speeds what so ever. But thats not a big deal. It did however more than tripled my read speeds!

The Following User Says Thank You to CallMeAria For This Useful Post: [ Click to Expand ]
Tags
increase, sd card
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes