Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,743,150 Members 44,344 Now Online
XDA Developers Android and Mobile Development Forum

[REF] Startup script speed tweaks

Tip us?
 
hardcore
Old
(Last edited by hardcore; 17th February 2011 at 07:58 PM.)
#1  
Senior Member - OP
Thanks Meter 8144
Posts: 3,435
Join Date: Sep 2006

 
DONATE TO ME
Default [REF] Startup script speed tweaks

Hi guys,

UPDATE: Over time, I've modified some of these values in my SpeedMod kernel. The values here may not be the best ones.

NOTE: These tweaks are now included in kernels based on sztupy's Universal Lagfix, for example:
http://forum.xda-developers.com/showthread.php?t=822756
But they must be manually activated from the recovery menu.

I've been using Linux kernel tweaks in a startup script to make the phone smoother.

With these tweaks, the phone is quite smooth and fast even without using the filesystem lagfixes.

These settings are only useful for you if you know how to create and modify a startup script. I use the old playlogos hack myself, but I'm sure there are many new ways to do it now.

Code:
Select Code
# Tweak cfq io scheduler
for i in $(ls -1 /sys/block/stl*) $(ls -1 /sys/block/mmc*) $(ls -1 /sys/block/bml*) $(ls -1 /sys/block/tfsr*)
do echo "0" > $i/queue/rotational
echo "1" > $i/queue/iosched/low_latency
echo "1" > $i/queue/iosched/back_seek_penalty
echo "1000000000" > $i/queue/iosched/back_seek_max
echo "3" > $i/queue/iosched/slice_idle
done
# Remount all partitions with noatime
for k in $(busybox mount | grep relatime | cut -d " " -f3)
do
sync
busybox mount -o remount,noatime $k
done

# Tweak kernel VM management
echo "0" > /proc/sys/vm/swappiness
#echo "10" > /proc/sys/vm/dirty_ratio
#echo "4096" > /proc/sys/vm/min_free_kbytes

# Tweak kernel scheduler, less aggressive settings
echo "18000000" > /proc/sys/kernel/sched_latency_ns
echo "3000000" > /proc/sys/kernel/sched_wakeup_granularity_ns
echo "1500000" > /proc/sys/kernel/sched_min_granularity_ns

# Misc tweaks for battery life
echo "2000" > /proc/sys/vm/dirty_writeback_centisecs
echo "1000" > /proc/sys/vm/dirty_expire_centisecs
EDIT: Explanations:

# Remount all partitions with noatime
atime is a setting where the filesystem updates the access time of a file. This creates a write-after-every-read which slows things down. By default all partitions are mounted with relatime, which is an optimized version of atime. noatime is the fastest, and afaik we don't need atime.

# Tweak cfq io scheduler
Tweaked settings of the disk io scheduler more for flash memory. Defaults are optimized for spinning harddisks. Lowered the idle wait, re-enable the low latency mode of cfq, removed the penalty for back-seeks and explicitly tell the kernel the storage is not a spinning disk.

# Tweak kernel VM management
Set tendency of kernel to swap to minimum, since we don't use swap anyway.
Lower the amount of unwritten write cache to reduce lags when a huge write is required.
Increase tendency of kernel to keep block-cache to help with slower RFS filesystem.
Increase minimum free memory, in theory this should make the kernel less likely to suddenly run out of memory.

# Tweak kernel scheduler
Make the task scheduler more 'fair' when multiple tasks are running. This has a huge effect on UI and App responsiveness. These values (less aggressive settings) are 20% of the Linux defaults, and about half of the Android defaults.

# Miscellaneous tweaks
Increase the write flush timeouts to save some battery life.

___________________________________

EDIT: How to create/use a startup script:

You need root and busybox for this.

This procedure is adapted from the old OCLF which used this method to create a startup script in /system/userinit.sh

Check if the file /system/userinit.sh exists. If it does, u should just edit that file as the startup script and DO NOT do the procedure below.

Here's how to do it manually. Do this only if some other lagfix/patch has not already done the playlogos hack, otherwise u might overwrite the other script!

Create the startup script on your PC. Use adb to push it to /sdcard/userinit.sh

adb push userinit.sh /sdcard/userinit.sh

On your PC, create a file called playlogos1 with this content:

#!/system/bin/sh
sh /data/userinit.sh
playlogosnow

Use adb to push the playlogos1 file to /sdcard/playlogos1

adb push playlogos1 /sdcard/playlogos1

Now use adb shell, su and do this:

busybox mount -o remount,rw /system;
busybox cp /sdcard/userinit.sh /data/userinit.sh;
busybox mv /system/bin/playlogos1 /system/bin/playlogosnow;
busybox cp /sdcard/playlogos1 /system/bin/playlogos1;

chmod 755 /system/bin/playlogos1;
chmod 755 /data/userinit.sh;

The startup script will be /data/userinit.sh

The reason I put the startup script in /data is so that if you mess up the startup script and get stuck during boot, you can do a "clear data" from recovery, and the startup script will be erased.
The Following 17 Users Say Thank You to hardcore For This Useful Post: [ Click to Expand ]
 
EarlZ
Old
#2  
Senior Member
Thanks Meter 272
Posts: 5,697
Join Date: Jun 2010
Could you explain what this actually does for the non linux savvy, also maybe you could make a script/app for this so everyone else can try it ?
 
kalpik
Old
#3  
Recognized Contributor
Thanks Meter 1389
Posts: 3,578
Join Date: May 2010
Location: Delhi
Quote:
Originally Posted by hardcore View Post
Hi guys,

I've been using Linux kernel tweaks in a startup script to make the phone smoother.

With these tweaks, the phone is quite smooth and fast even without using the filesystem lagfixes.

These settings are only useful for you if you know how to create and modify a startup script. I use the old playlogos hack myself, but I'm sure there are many new ways to do it now.

Code:
Select Code
# Remount all partitions with noatime
for k in $(mount | cut -d " " -f3)
do
	sync
	mount -o remount,noatime $k
done

# Tweak cfq io scheduler
for i in $(ls -1 /sys/block/stl*) $(ls -1 /sys/block/mmc*) $(ls -1 /sys/block/bml*) $(ls -1 /sys/block/tfsr*)
do echo "0" > $i/queue/rotational
echo "1" > $i/queue/iosched/low_latency
echo "1" > $i/queue/iosched/back_seek_penalty
echo "1000000000" > $i/queue/iosched/back_seek_max
echo "3" > $i/queue/iosched/slice_idle
done

# Tweak kernel VM management
echo "0" > /proc/sys/vm/swappiness
echo "10" > /proc/sys/vm/dirty_ratio
echo "1000" > /proc/sys/vm/vfs_cache_pressure
echo "4096" > /proc/sys/vm/min_free_kbytes

# Tweak kernel scheduler
echo "2000000" > /proc/sys/kernel/sched_latency_ns
echo "500000" > /proc/sys/kernel/sched_wakeup_granularity_ns
echo "400000" > /proc/sys/kernel/sched_min_granularity_ns

# Miscellaneous tweaks
setprop dalvik.vm.startheapsize 8m
setprop wifi.supplicant_scan_interval 90
setprop windowsmgr.max_events_per_sec 68
VERY interesting
 
INeedYourHelp
Old
(Last edited by INeedYourHelp; 19th October 2010 at 08:05 PM.)
#4  
Senior Member
Thanks Meter 6
Posts: 553
Join Date: Mar 2010
Quote:
Originally Posted by EarlZ View Post
you could make a script/app for this so everyone else can try it ?
+1, pretty plz, also, is this compatible with voodoo?
The Following User Says Thank You to INeedYourHelp For This Useful Post: [ Click to Expand ]
 
hardcore
Old
#5  
Senior Member - OP
Thanks Meter 8144
Posts: 3,435
Join Date: Sep 2006

 
DONATE TO ME
Quote:
Originally Posted by INeedYourHelp View Post
+1, pretty plz, also, is this compatible with voodoo?
Should be compatible, although u need to know how to add it into voodoo's startup script.
 
supercurio
Old
#6  
supercurio's Avatar
Senior Recognized Developer
Thanks Meter 5070
Posts: 3,529
Join Date: May 2010
Location: Chambéry

 
DONATE TO ME
Hello

Values description for each one and why is welcome
The Following User Says Thank You to supercurio For This Useful Post: [ Click to Expand ]
 
hardcore
Old
(Last edited by hardcore; 19th October 2010 at 08:54 PM.)
#7  
Senior Member - OP
Thanks Meter 8144
Posts: 3,435
Join Date: Sep 2006

 
DONATE TO ME
Quote:
Originally Posted by supercurio View Post
Hello

Values description for each one and why is welcome
Hey supercurio! Great job on Voodoo, I am particularly keen on the Sharpness, Video and future Sound fixes. I think its very cool that you found out how to modify the sharpness (S-AMOLED's PenTile matrix software algorithms?).

Edited the starting post with explanations. Most of them should be documented somewhere in the Linux sources / documents.

I've been using them for a while, tweaking values here n there. I think I've finally reached a stage where I'm confident enough to recommend them to others to try. There could be more optimum values with further testing, but these work well for me with Froyo.
 
supercurio
Old
#8  
supercurio's Avatar
Senior Recognized Developer
Thanks Meter 5070
Posts: 3,529
Join Date: May 2010
Location: Chambéry

 
DONATE TO ME
Quote:
Originally Posted by hardcore View Post
Hey supercurio! Great job on Voodoo, I am particularly keen on the Sharpness, Video and future Sound fixes. I think its very cool that you found out how to modify the sharpness (S-AMOLED's PenTile matrix software algorithms?).

Edited the starting post with explanations. Most of them should be documented somewhere in the Linux sources / documents.

I've been using them for a while, tweaking values here n there. I think I've finally reached a stage where I'm confident enough to recommend them to others to try. There could be more optimum values with further testing, but these work good for me so far with Froyo.
Yeah thank you so much for taking the time and sharing, i'll integrate them after a bit of testing

About the sharpness filter yes this is the main difference between S-AMOLED and AMOLED panel wise.
It's a hardware sharpness filter which is here to fight the fuzziness introduced by the pentile pattern but.. they overdid it a bit.

The "perfect" values are of course closer than the one with the same radius that the one of the blur introduced itself with the pixel pattern.
I feel it can maybe be improved a hair
I'll soon publish a version that allow write to the mDNIe register so you'll be able to play *live* with it too
 
xan
Old
#9  
xan's Avatar
Recognized Developer
Thanks Meter 455
Posts: 1,399
Join Date: May 2006
Location: Crack-ow

 
DONATE TO ME
Nice, could these be modified post-startup? like I go adb and copy paste some of them for testing?

I've tested setprop windowsmgr.max_events_per_sec 68, no difference. Set it to
setprop windowsmgr.max_events_per_sec 10 and still, no difference.
Feeling like translating something? here you go
Voltage Control Lite/Extreme 4.9.8 *Siyah support + Profiles + Widget + CPU history*: -> Take control of your OC/UV for Galaxy S OC kernels. Android Market / YAAM
ExTweaks / ExTweaks Plus 0.20 *Universal Tweaks Interface frontend for Siyah kernel*

14apr: [Froyo]Insane OC/UV kernel K13E
What is your OC result?
 
supercurio
Old
#10  
supercurio's Avatar
Senior Recognized Developer
Thanks Meter 5070
Posts: 3,529
Join Date: May 2010
Location: Chambéry

 
DONATE TO ME
Quote:
Originally Posted by xan View Post
Nice, could these be modified post-startup? like I go adb and copy paste some of them for testing?

I've tested setprop windowsmgr.max_events_per_sec 68, no difference. Set it to
setprop windowsmgr.max_events_per_sec 10 and still, no difference.
hey xan, you made me remember to add run-parts support.
i'll do that and you'll be able to set it without special hack very soon with voodoo

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes