Go Back   xda-developers > HTC Dream: G1 > G1 Android Development


Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 8th June 2009, 10:42 AM
defconoi's Avatar
defconoi defconoi is offline
Senior Member
 
Join Date: Oct 2008
Location: Phoenix, AZ
Posts: 214
Talking Tweak Android for Performance, and increase battery by Saving Power Usage with Sysctl

Here I will post tweaks as I find them to optimize Android.

When echoing in the following sysctl settings they do not remain after reboot, so we can adb remount then create a sysctl.conf file on our pc's with these settings, then ./adb push sysctl.conf /etc/ then the kernel should apply the settings every reboot

For examples of a sysctl.conf use google: Sysctl.conf Examples

Open a Terminal and Execute these commands as root

Tweak virtual memory to conserve power when running on battery:
Code:
echo 0 > /proc/sys/vm/swappiness #can be ignored if you dont use swap
echo 0 > /proc/sys/vm/dirty_expire_centisecs #can be ignored if you dont use swap
echo 0 > /proc/sys/vm/dirty_writeback_centisecs #can be ignored if you dont use swap
echo 60 > /proc/sys/vm/dirty_background_ratio
echo 95 > /proc/sys/vm/dirty_ratio
Tweak virtual memory for running on Charger

Code:
echo 0 > /proc/sys/vm/swappiness #can be ignored if you dont use swap
echo 3000 > /proc/sys/vm/dirty_expire_centisecs #can be ignored if you dont use swap
echo 500  > /proc/sys/vm/dirty_writeback_centisecs #can be ignored if you dont use swap
echo 10   > /proc/sys/vm/dirty_background_ratio
echo 40   > /proc/sys/vm/dirty_ratio
Detecting apps/services that hog the battery/cpu:
Also while on battery, you should stop all applications that don't really stay idle when you're not using them, if you want to find which apps arent really staying idle you can:
Code:
strace -p $(pidof yourapp) # for all your running applications 
ps aux | awk '{print$10,$11}' | sort -n # will list all running softs sorted by used cpu time
By default when Linux runs out of memory it goes through the process list and starts killing off processes that it thinks are using too much memory. This sysctl makes Linux kill the runaway process that made the system run out of memory instead, which is usually what you want.(this will also reduce cpu time and increase battery usage).
Code:
sysctl -w vm.oom_kill_allocating_task=1
Credit: ccpp0
vfs_cache_pressure to 10 , gives more mem to cache fs dentry and inode to save cpu
At the default value of vfs_cache_pressure = 100 the kernel will attempt to reclaim dentries and inodes at a "fair" rate with respect to pagecache and swapcache reclaim. Decreasing vfs_cache_pressure causes the kernel to prefer to retain dentry and inode caches. Increasing vfs_cache_pressure beyond 100 causes the kernel to prefer to reclaim dentries and inodes.
Code:
sysctl -w vm.vfs_cache_pressure=10

I'll be adding more tweaks for sysctl and basic cmd line tweaks as I find them, also these tweaks would be good integrated into roms, apps, and a power-save widget if anyone wants to get creative.
__________________
G1 - I switch Rom's Daily lol - RA-dream-v1.5.2
Buy me a beer
Follow me on Friendfeed
Visit my Ubuntu Site:
Visit my Newly Redesigned Android Site(optimized for mobile)Android-Unleashed.com!
Follow me on Twitter

Last edited by defconoi; 9th June 2009 at 04:24 PM.. Reason: update
Reply With Quote
Sponsored Links

  #2  
Old 8th June 2009, 10:46 AM
david1171 david1171 is offline
Senior Member
 
Join Date: Apr 2009
Posts: 2,326
Default a few questions

do i enter this into the terminal emulator? also does this only need to be entered in one time? thank you in advance for any help.
Reply With Quote

  #3  
Old 8th June 2009, 10:50 AM
robpet2's Avatar
robpet2 robpet2 is offline
Senior Member
 
Join Date: Sep 2006
Location: Virginia
Posts: 1,929
Default

great find.. will keep my eye on this thread
__________________
Tmobile G1 - Cyanogen 4.2.5
100+apps 70mb free
8gb MicroSd Class 6 (FINALLY )
8gb MicroSd Class 4 *for dual boot
gtalk: kaysesoze
Follow Me on Twitter
Myspace page
MY Blog
G1 files
Donate
Change Build.prop
Reply With Quote

  #4  
Old 8th June 2009, 12:01 PM
defconoi's Avatar
defconoi defconoi is offline
Senior Member
 
Join Date: Oct 2008
Location: Phoenix, AZ
Posts: 214
Smile

Quote:
Originally Posted by david1171 View Post
do i enter this into the terminal emulator? also does this only need to be entered in one time? thank you in advance for any help.
yes you can enter it in via terminal emulator or ./adb shell, the echo'd settings are not permanent and will reset after reboot, so use the settings to test, then follow the directions to create a /etc/sysctl.conf file to make the settings permanent after you feel comfortable with the settings(if you notice improvement)
defcon
__________________
G1 - I switch Rom's Daily lol - RA-dream-v1.5.2
Buy me a beer
Follow me on Friendfeed
Visit my Ubuntu Site:
Visit my Newly Redesigned Android Site(optimized for mobile)Android-Unleashed.com!
Follow me on Twitter
Reply With Quote

  #5  
Old 8th June 2009, 12:32 PM
free-sidux's Avatar
free-sidux free-sidux is offline
Senior Member
 
Join Date: Feb 2009
Posts: 117
Default

Wow, this is cool, thank you!

Could you maybe add some more comments, I don't really understand what the single commands do. Or some place, where the function of e.g. "dirty_expire_centisecs" is explained?

One more precise question though: If I don't have a swap file on sd, does the tweaking of the swappiness still change anything?

Greetings!
__________________
my distro-histo:

stock 1.0 - stock 1.1 - JF-uk-r9
Dudes 0.93 - JF-adp-1.5 - JF-uk-1.5 - JF-uk-1.51 - JF-cyano-1.51 - Dudes 1.2a/b
Haykuros Hero - Twisted Hero - JACHero - Drizzies NewVision - Drizzies Champion - Drizzy Elite - JACsky 1.7r2 - 2.0 - Some drizzy stuff
CM 4.0.x -- 4.2.5
Reply With Quote

  #6  
Old 8th June 2009, 12:36 PM
ccpp0 ccpp0 is offline
Junior Member
 
Join Date: Nov 2008
Posts: 14
Default

Quote:
Originally Posted by free-sidux View Post
Wow, this is cool, thank you!

Could you maybe add some more comments, I don't really understand what the single commands do. Or some place, where the function of e.g. "dirty_expire_centisecs" is explained?

One more precise question though: If I don't have a swap file on sd, does the tweaking of the swappiness still change anything?

Greetings!

there is no swap space on G1, so settings related to the swap can be ignored.

echo 0 > /proc/sys/vm/dirty_expire_centisecs
echo 0 > /proc/sys/vm/dirty_writeback_centisecs

never writes out dirty pages ?

Last edited by ccpp0; 8th June 2009 at 12:40 PM..
Reply With Quote

  #7  
Old 8th June 2009, 12:46 PM
defconoi's Avatar
defconoi defconoi is offline
Senior Member
 
Join Date: Oct 2008
Location: Phoenix, AZ
Posts: 214
Default

Quote:
Originally Posted by free-sidux View Post
Wow, this is cool, thank you!

Could you maybe add some more comments, I don't really understand what the single commands do. Or some place, where the function of e.g. "dirty_expire_centisecs" is explained?

One more precise question though: If I don't have a swap file on sd, does the tweaking of the swappiness still change anything?

Greetings!
http://tinyurl.com/nlb9ws

Note: The value of vm.swappiness=0 states that no swap space will be used at all, basically it can be ignored if you dont use swap though
__________________
G1 - I switch Rom's Daily lol - RA-dream-v1.5.2
Buy me a beer
Follow me on Friendfeed
Visit my Ubuntu Site:
Visit my Newly Redesigned Android Site(optimized for mobile)Android-Unleashed.com!
Follow me on Twitter

Last edited by defconoi; 8th June 2009 at 12:48 PM..
Reply With Quote

  #8  
Old 8th June 2009, 12:52 PM
ccpp0 ccpp0 is offline
Junior Member
 
Join Date: Nov 2008
Posts: 14
Default

Quote:
Originally Posted by defconoi View Post
http://tinyurl.com/nlb9ws

Note: The value of vm.swappiness=0 states that no swap space will be used at all, basically it can be ignored if you dont use swap though

set vfs_cache_pressure to 10 , gives more mem to cache fs dentry and inode to save cpu "wa".
Reply With Quote

  #9  
Old 9th June 2009, 12:16 PM
tshizzle tshizzle is offline
Member
 
Join Date: Jun 2007
Posts: 69
Default

how do i create a Sysctl.conf file with this script?
i tried the link of examples but all i could find was info about it.

everything else works but when i try
sysctl vm.block_dump=1

i get sysctl: error: 'vm.block_dump=1' is an unknown key

any ideas?
__________________
Phone: T-mobile G1(White) / HTC HD2 (Leo)
Network: T-mobile UK
Rom: I probably dont even know

Follow Me Twitter

Want a new phone? MobileXpress
Reply With Quote

  #10  
Old 9th June 2009, 04:04 PM
defconoi's Avatar
defconoi defconoi is offline
Senior Member
 
Join Date: Oct 2008
Location: Phoenix, AZ
Posts: 214
Default

actually ya know what I think we can just disable sysctl all together in menuconfig->Filesystems->Pseudo Filesystems->Proc->Sysctl Support when compiling a new kernel and setting these tweaks right in the kernel.
Says in menuconfig"As it is generally a good thing, you should say Y here unless
building a kernel for install/rescue disks or your system is very
limited in memory
."
So I think we can gain some memory disabling this since we dont really need it
__________________
G1 - I switch Rom's Daily lol - RA-dream-v1.5.2
Buy me a beer
Follow me on Friendfeed
Visit my Ubuntu Site:
Visit my Newly Redesigned Android Site(optimized for mobile)Android-Unleashed.com!
Follow me on Twitter

Last edited by defconoi; 9th June 2009 at 04:08 PM..
Reply With Quote

Reply

Tags
hacks, sysctl, tweaks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:09 AM.


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.