[TWEAKS][UPDATED 1/05/2011 - Flashable .zips] Performance and battery tweaks

Status
Not open for further replies.

franciscofranco

Recognized Developer
Dec 9, 2010
24,725
136,397
0
Carcavelos
In this thread you'll find a compilations of tweaks and settings to improve your phone's performance and battery.

It isn't a walk in the park, I'll strongly advise against trying these tweaks if you don't know what you're doing. I'm not responsible for any bricked device or any kinds of problems you may have when applying the following changes. If you don't know what you're doing then simply DON'T.


Changelog 1/05/2011:
  • Reverted few changes, and everything should work correctly and easily. Instructions how to delete the previous version below.
  • Fixed the files permissions. Now you don't have to do it manually for it to work.

Download:
Tweaks .zip

Patched libsqlite .zip:
(don't use this on andy's 2.3.3 and latest CM7 from mik 6.3 roms or you'll end in a bootloop or your phone will drain a lot of battery according to some users)
libsqlite.so

Data2ext: http://forum.xda-developers.com/showthread.php?t=1042828 (thanks ungaze).

Very important:
libsqlite.so is a patched sqlite library file to turn sync off. With that change I/O should be waaay faster during db writes and reads. It only works with 2.3.x ROMs, don't bother flashing if you're with Froyo or you'll end up with a boot loop.

Instructions:

To delete the previous versions (thanks 32bits):

If you've installed any of the previously tweaks then you'll have to roll back. You have to do the following steps (this includes every possible locations):
1. Remove /system/etc/tweaks.sh
2. Remove /system/etc/init.d/00script
3. Remove /system/etc/init.d/99a
4. Remove /system/etc/init.d/99tweaks
5. Remove /data/local.prop
6. Reboot your phone.


For the .zips:
1. Download the .zips.
2. Enter recovery.
3. Flash them.
4. Reboot.
5. Done.

Prop settings, you can add them to your build.prop or local.prop:
Code:
wifi.supplicant_scan_interval=300
windowsmgr.max_events_per_sec=260
ro.lge.proximity.delay=25
mot.proximity.delay=25
net.tcp.buffersize.default=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.wifi=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.umts=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.gprs=4096,87380,256960,4096,16384,256960
net.tcp.buffersize.edge=4096,87380,256960,4096,16384,256960
ro.HOME_APP_ADJ=1
ro.mot.eri.losalert.delay=1000
video.accelerate.hw=1
ro.ril.disable.power.collapse=0
pm.sleep_mode=1
Don't forget to nand backup first in case something goes wrong. I'm not responsible for any problem from your part.

Thank you for your donation:
- Momaro



franciscofranco said:
Battery life increase for Dummies

Do you want some extra juice in your battery life? Does it seem that you lose your battery too fast? Then you came to the right
place.

Over the time I've gathered some information about our battery and while this isn't 100% proof (because all of us use the phone for different purposes)
I think it's most accurate:

The myth of having the lowest possible frequency on your CPU while it's asleep:

Having the lowest frequencies (122 or 248) set up, it's not good. Our phone doesn't change voltages while underclocking or overclocking (as far as I know overclocking
doesn't change voltages as well) so, and only talking about underclocking, having such a low frequency is bad for your phones battery and performance. For the battery
that's because it takes longer to wake up from sleep and the time that the cpu takes to scale from 122/248 to maximum instead of using it for processing power eats
your battery away. About the performance hit, well that's pretty obvious and it takes longer to idle up, so again, more battery drain.
Having read about this the last few days actually running in Performance Governor is pretty beneficial to your battery: it wakes up faster, it performs every task faster,
then it idles up faster. Yeah during "sleep" time having 122 frequency or 806 it's the same thing because it's not using its power for anything, it's just there idling.
In any case what I always suggest is TEST it up and see for yourself. If you don't want to run with Performance governor at least run with 480 minimum frequency, it really helps.

---

Why do you run with auto-sync, gps, wifi, 3G, firewalls, anti-virus, background apps killing your battery? That's bullshit. Most of you complain that your battery doesn't last as long
as it should...well that's not ROMs fault, I've been running with CM7 buils since the first builds and I never, ever, ever had battery problems even when everyone complained. Why?
Because I'm careful. If you don't need auto-sync at that time, disable it...if you don't need gps, disable it and so on. I don't know why people leave this stuff on even when they are not
using them. Firewalls? That's bullshit as well along with anti-viruses. They eat up your resources for nothing. Same goes for background apps that eat it up. Google Maps = bullshit. If
you used it go kill it after you're done with it. Same with Music app. Kill it after you've listened to your 1315618 songs. But DON'T use task killers. I can't repeat this enough, just
DON'T use them for your own sake. Same goes for 3G...just don't enable it all time if you're not using it.

No Live Wallpapers as well, nor 3D app drawers, these blow your battery away easily without you knowing how or why. Don't bother tuning your brightness down...you have a device, and
that's to be used. Why buying a mobile for 200€ and not using it's screen propely? It's there to be used, full brightness looks better, it's not by decreasing it down and hurting your
eyes that you'll get 21564561 more battery hours.

---

Do you want even more battery? Flash my tweaks along with local.prop. I'm running 2.3.3 without any modification except my tweaks + local.prop + libsqlite + LauncherPro as a launcher
(this is where most of the performance comes from).

So these are my "secrets". As you can see this is not really secret and I can easily run my device without charging for 1 day and a half, 2 days max with moderate usage.
AH there's something important. After flashing a ROM be sure to charge it to 100%, enter recovery and wipe battery stats, then reboot and only when the phone is up and running you then
unplug it.

Have fun reading, I laughed a lot while writting it ;)
---------------------------------------------------------------------------------------

Different method to apply the tweaks. Make sure you thank ungaze for this script ;)
Visit this thread for a completely new method to apply these tweaks: SD Tweakz

Code:
What does it do?

-mounts SD
-checks if "scriptz" folder exists
-copies scripts from "scriptz" folder to /data partition
-sets permission to scripts
-runs all the scripts
-deletes "scriptz" folder from /data partition
-unmounts SD
-done

P.S.- Everything is pretty clear, I won't be answering anything that is specifically stated above in my post or in the following ones.
 
Last edited:

sarfaraz1989

Senior Member
Jan 19, 2011
655
62
0
New Delhi
in case u dont have root explorer

1. mount -t yaffs2 -o remount,rw /dev/block/mtdblock1 /system
2. echo 4096 > /sys/devices/virtual/bdi/179:0/read_ahead_kb


PS: u cud have integrated that read_ahead_kb in your script too..and dont u have to mount /system rw first ???

EDIT: found something !!! busybox has crontab ..Guess we can schedule the above script to execute like every half and hour or so !!!
 
Last edited:

sarfaraz1989

Senior Member
Jan 19, 2011
655
62
0
New Delhi
" ls -1 /sys/block/mtdblock* " u need to use cut and tr with it..DOesnt work


Here's My script :

mount -t yaffs2 -o remount,rw /dev/block/mtdblock1 /system
echo 4096 > /sys/devices/virtual/bdi/179:0/read_ahead_kb
for i in `ls -l /sys/block/mtdblock* | tr -s " "| cut -d " " -f 6`
do
echo "noop" > /sys/block/$i/queue/scheduler
done
echo "noop" > /sys/block/mmcblk0/queue/scheduler
 
Last edited:

franciscofranco

Recognized Developer
Dec 9, 2010
24,725
136,397
0
Carcavelos
" ls -1 /sys/block/mtdblock* " u need to use cut and tr with it..DOesnt work


Here's My script :

mount -t yaffs2 -o remount,rw /dev/block/mtdblock1 /system
echo 4096 > /sys/devices/virtual/bdi/179:0/read_ahead_kb
for i in `ls -l /sys/block/mtdblock* | tr -s " "| cut -d " " -f 6`
do
echo "noop" > /sys/block/$i/queue/scheduler
done
echo "noop" > /sys/block/mmcblk0/queue/scheduler
That's a variation, but my script works as well, been using it for a good while, but thanks anyway :)
 

xciton

Senior Member
Feb 3, 2008
61
12
0
Some observations:

If you want to use "-1" option with ls, you'll need to use busybox's version. The stock ls doesn't support it.

The Linux sysfs file system (as mounted in /sys) is by design a read-write virtual file system. No need to do anything extra to play with it, other than be root.

These commands shouldn't be run from cron, they belong in some init script, perhaps /init.rc or other appropriate startup location.
 

ungaze

Senior Member
Jul 27, 2010
401
158
0
manila
My class 4 Kingston can achieve something like 40 mb/s with this tweak, but it may vary from card to card, this is just my experience.
with which benchmarking tool/app? Using SD tools but no apparent change.

@franciscofranco

sent you a PM
 

bluviper

Senior Member
Oct 6, 2010
918
124
73
MKTICBD
SD Tools indeed :)

First post updated with new tweaks.
so we just add the new scripts from Ungaze?
and let the previous one as is....

using GScript, these folders are missing?
silly question but, do we need to create this folders?

-----------
and also, will this work in general for all android devices regardless of ROM?
 
Last edited:

Omnichron

Senior Member
Dec 1, 2010
932
117
0
East Highland, CA
This thread contains some tweaks that I've found and tested myself to improve performance and battery of your ROM.

It isn't a walk in the park, I'll strongly advise you to try these tweaks if you don't know what you're doing. I'm not responsible for any bricked device or any kinds of problems you may have when applying the following changes, if you don't know what you're doing then simply DON'T.

build.prop edit:

wifi.supplicant_scan_interval=200 // interval of seconds that wifi scans for another networks

mot.proximity.delay=25 // proximity sensor tweak to make it more responsive

windowsmgr.max_events_per_sec=60 // makes the ui more fluid and snappy

debug.sf.hw=1 // activates hardware acceleration


System files tweaks using Root Explorer (paid app from the Market):

Change /sys/devices/virtual/bdi/179:0/read_ahead_kb value to 4096, it improves the reading speed from the SD card. My class 4 Kingston can achieve something like 40 mb/s with this tweak, but it may vary from card to card, this is just my experience.

I/O schedulers:

To check which scheduler is used:

Code:
adb shell

~ # cat /sys/block/mtdblock0/queue/scheduler

[noop] cfq // in this case noop scheduler was selected
To select a different scheduler:

Code:
adb shell

~ # echo "noop" > /sys/block/mtdblock0/queue/scheduler 
// you can change the schedulers for all your blocks, which, more likely will be mtdblock1,2,3,4,5,6,7,8 and 9. then mmcblk0 for the SD card.
This settings won't last through reboots, so either you create a shell script to run it every reboot or you change then manually. Same applies when changing read_ahead_kb file, it resets on reboot.

This is the script I'm using to run every reboot to change the scheduler:

Code:
for i in `ls -1 /sys/block/mtdblock*`

do

    echo “noop” > $i/queue/scheduler

done

echo “noop” > /sys/block/mmcblk0/queue/scheduler
#[b]new line[/b] echo "noop" > /sys/block/dm-0/queue/scheduler
EDIT: ungaze kindly sent me a bunch of shell scripts and after researching, modifying them, and testing I'll suggest you to run them to increase general performance:

Code:
DM=`ls -d /sys/block/dm*`;
MTD=`ls -d /sys/block/mtd*`;
LOOP=`ls -d /sys/block/loop*`;
RAM=`ls -d /sys/block/ram*`;

for j in $DM $MTD $LOOP $RAM;
do
	echo 0 > $j/queue/rotational;
done
This one tells the kernel that all those devices are not "spinning disks" to it treats them as flash memory, because that's exactly what they are.

Code:
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;
These are tweaks to kernel Virtual Memory management.



Use GScript Lite from the market, it works fine.

If you want to know about the i/o schedulers I suggest you google it.

P.S.- Everything is pretty clear, I won't be answering anything that is specifically stated above in my post.
Thanks. any chance of making it flashable for us troglodytes...:D
 

franciscofranco

Recognized Developer
Dec 9, 2010
24,725
136,397
0
Carcavelos
so we just add the new scripts from Ungaze?
and let the previous one as is....

using GScript, these folders are missing?
silly question but, do we need to create this folders?

-----------
and also, will this work in general for all android devices regardless of ROM?
Yes just add the scripts, don't need to mess with the previous ones.
If it says a directory was not been found don't worry about it, sometimes dm-0 is mounted, sometimes it is not, I still haven't found out when.
 

bluviper

Senior Member
Oct 6, 2010
918
124
73
MKTICBD
to tell my experience, after installing the scripts, screen transitions is now snappy.
not like before that youll have to wait half a sec or something near that... now its instant and snappy, its cool to look at. returning to homescreen is abit faster now.

opening files on my ES explorer, unzipping etc etc. works faster now.
exploring and changing files on Root Explorer is quite faster than before.

im using LG Optimus P500....

so again my question goes... will this also work with other android phones under different ROMS?
 

franciscofranco

Recognized Developer
Dec 9, 2010
24,725
136,397
0
Carcavelos
to tell my experience, after installing the scripts, screen transitions is now snappy.
not like before that youll have to wait half a sec or something near that... now its instant and snappy, its cool to look at. returning to homescreen is abit faster now.

opening files on my ES explorer, unzipping etc etc. works faster now.
exploring and changing files on Root Explorer is quite faster than before.

im using LG Optimus P500....

so again my question goes... will this also work with other android phones under different ROMS?
Awesome :)
It will probably work on most devices but most likely with some adjustments, nothing I can really predict unless taking a look over the phone and it's filesystems.
 
  • Like
Reactions: dislplin01
Status
Not open for further replies.