FORUMS
Remove All Ads from XDA

[Mod]Change read ahead values of various partitions

151 posts
Thanks Meter: 139
 
By Wooaarr, Senior Member on 2nd December 2013, 04:55 PM
Post Reply Email Thread
Changing read ahead values

Hello there,

i was a bit shocked when i checked the diskstats from my Cm 7.2 and saw, that only about 5 - 10% of the readings from the /system /cache partition are actuallly merged.
Now i asked myself why was that?
Linux has a function called read ahead, which tells the system to read further then it actually needs. Not a bad thing, considering it is very likely that you will need object B, once you called object A.
The problem with a too high value for read ahead is once you red object A, the one that you were looking for, the system is going to call for object B, C, D, E, F, G, and so on... Now you might also need object B, maybe even C, but it gets more unlikely that you will need all the following data as well...
This information will just be flushed from the memory, hence only 5 - 10% of the readings are actually merged.

Digging a bit deeper reveals read ahead values of 768kb for the /system and /cache partition, which seems a bit pointless to me, especially on the cache partition. (Bear in mind, linux default is 4kb)

So i called:

Code:
proc/self/mountinfo
to get a detailed info about the partitions. (Importent part in bold)
Code:
C:\adb>adb shell cat /proc/self/mountinfo
1 1 0:1 / / rw,relatime - rootfs rootfs rw
11 1 0:11 / /dev rw,relatime - tmpfs tmpfs rw,mode=755
12 11 0:9 / /dev/pts rw,relatime - devpts devpts rw,mode=600
13 1 0:3 / /proc rw,relatime - proc proc rw
14 1 0:12 / /sys rw,relatime - sysfs sysfs rw
15 1 0:13 / /acct rw,relatime - cgroup none rw,cpuacct
16 1 0:14 / /mnt/asec rw,relatime - tmpfs tmpfs rw,mode=755,gid=1000
17 1 0:15 / /mnt/obb rw,relatime - tmpfs tmpfs rw,mode=755,gid=1000
18 11 0:16 / /dev/cpuctl rw,relatime - cgroup none rw,cpu
19 1 138:12 / /system rw,relatime - ext4 /dev/block/stl12 rw,barrier=1,data=ordered
20 1 138:13 / /data rw,nosuid,nodev,relatime - ext4 /dev/block/stl13 rw,barrier=1,data=ordered
21 1 138:14 / /cache rw,nosuid,nodev,relatime - ext4 /dev/block/stl14 rw,barrier=1,data=ordered
22 21 138:13 /local/download /cache/download rw,nosuid,nodev,relatime - ext4 /dev/block/stl13 rw,barrier=1,data=ordered
23 20 179:2 / /data/sdext2 rw,relatime - ext4 /dev/block/mmcblk0p2 rw,barrier=1,data=ordered
24 1 179:1 / /mnt/sdcard rw,nosuid,nodev,noexec,relatime - vfat /dev/block/vold/179:1 rw,dirsync,uid=1000,gid=1015,fmask=0602,dmask=0602,allow_utime=0020,codepage=cp437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro
25 1 179:1 /.android_secure /mnt/secure/asec rw,nosuid,nodev,noexec,relatime - vfat /dev/block/vold/179:1rw,dirsync,uid=1000,gid=1015,fmask=0602,dmask=0602,allow_utime=0020,codepage=cp437,iocharset=iso88591,shortname=mixed,utf8,errors=remount-ro
26 24 0:17 / /mnt/sdcard/.android_secure ro,relatime - tmpfs tmpfs ro,size=0k,mode=000
Adding the following lines to init.gt-s5570.rc in the kernel ramdisk, changes the default read ahead value (768 ) to smaller ones.

Code:
# Read Ahead
        write /sys/block/mmcblk0/bdi/read_ahead_kb 512
        write /sys/block/mmcblk0p2/bdi/read_ahead_kb 512
    	write /sys/block/stl12/queue/read_ahead_kb 4
	write /sys/block/stl13/queue/read_ahead_kb 4
	write /sys/block/stl14/queue/read_ahead_kb 4
	write /sys/devices/virtual/block/stl12/queue/read_ahead_kb 4
	write /sys/devices/virtual/block/stl13/queue/read_ahead_kb 4
	write /sys/devices/virtual/block/stl14/queue/read_ahead_kb 4
/sdcard (including sdext) 512kb (Maybe not optimal if you use a swap file)
/system 4kb
/cache 4kb
/data 4kb

I now have about 30% of my readings actually merged and i guess that is way better.

If you want to confirm, that you have done everything right, browse to:
sys/devices/virtual/bdi/x:x

where x:x should be replaced by:
Code:
179:1 / 179:2 / 179:0 for the sdcard
138:12 for the /system partition
138:13 for the /data partition
138:14 for the /cache partition
Now look for the read_ahead_kb file, open it and confirm the value.


I do have the feeling, that my phone is a lot snappier then before... Also my battery seems to last longer... All this might of course be a placebo, also it does make sense (Less readings should result in less battery consumption and of course free up some ressources).

If someone knows a bit more on that topic (And why the values were 768kb in the first place anyway...) i would be happy to learn more about it.

Take care

Wooaarr

Edit: I included this in the Badass Kernel for Gingerbread from alin.p (Just the Kernel, not the keylayout!)

This is not my work, but alin.p's!
Attached Files
File Type: zip Badass Gingerbread.zip - [Click for QR Code] (3.82 MB, 154 views)
The Following 5 Users Say Thank You to Wooaarr For This Useful Post: [ View ] Gift Wooaarr Ad-Free
 
 
2nd December 2013, 08:41 PM |#2  
Masrepus's Avatar
Senior Member
Thanks Meter: 100
 
More
If i use sd with sd-ext and swap, which readahead value would u set?

---------------------------------
Phone : Samsung Galaxy Mini S5570
OS:
•AOSP ICS Touchwiz V5 by A_U
•Android 4.0.4
•Baseband XWKS2
•Kernel: 2.6.37.6 Badass v1.9 by alin.p
•Recovery CWM v4.0.0.5
Mods:
PureAudio, Mounts2SD, ODEX through Universal ODEX script, AdBlock by AdAway
---------------------------------

Gesendet von Tapatalk
2nd December 2013, 08:58 PM |#3  
OP Senior Member
Thanks Meter: 139
 
More
Quote:
Originally Posted by Masrepus

If i use sd with sd-ext and swap, which readahead value would u set?

I have to be honest with you, that is a bit tricky.
For the sd-ext i would set it to 512kb.

Do have a a swap file, or do you use a swap partition? If you use a swap partition you should be able to give it a seperate read_ahead value.

Anyway i wouldn't know which value would be good, as swap is kind of a Ram exchange, so i don't know what data lies in there (Probably similiar to /data?). From my guts i would say 512, but just experiment a little bit=)

Maybe someone else could help out.
The Following User Says Thank You to Wooaarr For This Useful Post: [ View ] Gift Wooaarr Ad-Free
2nd December 2013, 09:01 PM |#4  
Masrepus's Avatar
Senior Member
Thanks Meter: 100
 
More
Ya, i have a partition
Ok, i will try that with 512

---------------------------------
Phone : Samsung Galaxy Mini S5570
OS:
•AOSP ICS Touchwiz V5 by A_U
•Android 4.0.4
•Baseband XWKS2
•Kernel: 2.6.37.6 Badass v1.9 by alin.p
•Recovery CWM v4.0.0.5
Mods:
PureAudio, Mounts2SD, ODEX through Universal ODEX script, AdBlock by AdAway
---------------------------------

Gesendet von Tapatalk
8th December 2013, 09:48 AM |#5  
OP Senior Member
Thanks Meter: 139
 
More
For those who are interested in the topic, it seems I'm not the only one who thinks that high values are not always a good idea. This thread is from 2011.

Click...

A nice quote from this thread:
Quote:

....the reason the mainline kernel tree doesn't have a higher readahead value isn't because some kernel "developers" here are smarter than Linus and everyone else, but because it is generally a bad idea...

I'm a bit sad, that no one else knows something about this. Are the values just as high in Cm 9.2 and Cm 10.1?

Take care
10th December 2013, 09:26 AM |#6  
Senior Member
Flag Iasi
Thanks Meter: 1,818
 
More
Quote:
Originally Posted by Wooaarr

For those who are interested in the topic, it seems I'm not the only one who thinks that high values are not always a good idea. This thread is from 2011.

Click...

A nice quote from this thread:


I'm a bit sad, that no one else knows something about this. Are the values just as high in Cm 9.2 and Cm 10.1?

Take care

Nice work. :d I'll be including these in all my kernels from now on.
10th December 2013, 10:18 AM |#7  
arpitkh96's Avatar
Senior Member
Flag panipat
Thanks Meter: 646
 
Donate to Me
More
Quote:
Originally Posted by alin.p

Nice work. :d I'll be including these in all my kernels from now on.

U can use these int.d scripts made by me using google
https://www.dropbox.com/s/or0id80nei...sdcardspeedfix
https://www.dropbox.com/s/l84w9lrjdvir099/88datafix

Sent from my GT-S5570 using XDA Premium 4 mobile app
10th December 2013, 02:48 PM |#8  
OP Senior Member
Thanks Meter: 139
 
More
Quote:

Nice work. :d I'll be including these in all my kernels from now on.

I suppose that means the values are just as high in Cm 9.2 & 10.1?

Quote:

U can use these int.d scripts made by me using google

I did not even think about making a init.d script. That is of course the easier option

But all your scripts do is set
/data
/sdcard

to 512kb read ahead.

You still leave /system & /cache at 768kb and don't set it to 4kb.
10th December 2013, 03:50 PM |#9  
arpitkh96's Avatar
Senior Member
Flag panipat
Thanks Meter: 646
 
Donate to Me
More
They were initially at 4 kb in cm9.2.but it is easy to make.just to change the path.

Sent from my GT-S5570 using XDA Premium 4 mobile app
11th December 2013, 02:26 PM |#10  
OP Senior Member
Thanks Meter: 139
 
More
Just to make it a bit easier I made a script that sets

/cache to 4 kb
/system to 4 kb
/data to 512 kb
/sdcard to 512 kb
/sdcard android.secure to 512 kb
/sd ext to 512 kb


Just download the script:

1. Rename it from 99readahead.txt to 99readahead
2. Push 99readahead to /system/etc/init.d
3. Set the permissions to -rwxr-x----

Take care
Attached Files
File Type: txt 99readahead.txt - [Click for QR Code] (937 Bytes, 217 views)
The Following User Says Thank You to Wooaarr For This Useful Post: [ View ] Gift Wooaarr Ad-Free
11th December 2013, 02:44 PM |#11  
arpitkh96's Avatar
Senior Member
Flag panipat
Thanks Meter: 646
 
Donate to Me
More
Quote:
Originally Posted by Wooaarr

Just to make it a bit easier I made a script that sets

/cache to 4 kb
/system to 4 kb
/data to 512 kb
/sdcard to 512 kb
/sdcard android.secure to 512 kb
/sd ext to 512 kb


Just download the script:

1. Rename it from 99readahead.txt to 99readahead
2. Push 99readahead to /system/etc/init.d
3. Set the permissions to -rwxr-x----

Take care

What if sdext is mounted as data partition?

Sent from my GT-S5570 using XDA Premium 4 mobile app
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes