Increase Read Cache for better SD Card access
2011-05-13 00:29
609 查看
转自:http://forum.xda-developers.com/showthread.php?t=1010807
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
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
相关文章推荐
- android虚拟机sdcard操作出现mkdir failed for , Read-only file system的解决办法
- GEM5: Different cache latency for read and write access 设置不同的读写latency
- Android file canRead() is always false on SD card
- SD card boot and flashing tool for TI davinic DM368
- data_SDCard_ReadAndWrite
- 用android虚拟机,向sdcard导入文件时候报错 transfer error: Read-only file system
- How to Flash an SD Card for Raspberry Pi
- 文件存储之:File,Cache,Sdcard,三种存储方式
- Android sdcard之read-only
- 故障解决:Failure adding assembly to the cache: Access denied. You might not have administrative credentials to perform this task. Contact your system administrator for assistance.
- Unable to chmod sdcard: Read-onl…
- 用android虚拟机,向sdcard导入文件时候报错 transfer error: Read-only file system
- saving-the-android-webview-cache-on-the-sd-card
- SD Card Formatter for Mac Download
- Create a Bootable 8G MicroSD Card for e-puck with wifi+webcam
- Unable to chmod sdcard: Read-only file system
- 安卓 failed to copy to sdcard:read-only file system
- 备库重新编译导致的ora-16000 :database open for read-only access
- 文件导入sdcard下报错,Read-only file system
- arcgis for android: file:/mnt/sdcard/xxx.geodatabase does not exist.