Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,768,772 Members 52,189 Now Online
XDA Developers Android and Mobile Development Forum

[MOD] Improve your battery life

Tip us?
 
Alton (Halo 2)
Old
#41  
Alton (Halo 2)'s Avatar
Senior Member
Thanks Meter 90
Posts: 1,221
Join Date: Sep 2011
Location: rock island
Quote:
Originally Posted by PureMotive View Post
Do this in the terminal

Code:
sysctl -a| grep vm
After the a wat is that l ? Capital I ?

Sent from my HTC Droid Incredible using xda premium
 
ezeuba
Old
#42  
ezeuba's Avatar
Senior Member
Thanks Meter 67
Posts: 256
Join Date: Sep 2009
Location: Lagos
Quote:
Originally Posted by Alton (Halo 2) View Post
After the a wat is that l ? Capital I ?

Sent from my HTC Droid Incredible using xda premium
The | on terminal = VolUp+L
I have a MOTO X - XT1049 (GSM Unlocked) with talk, text and 3G data flashed to
And a Nokia Lumia 822 on MTN Nigeria
-----------------------------------------------------------------------------------------------------
Current Phones
MOTO X - XT1049 & Nokia Lumia 822
Current ROM
N5 Experience 4.4.4 & Windows Phone 8.1 Developer Preview
The Following User Says Thank You to ezeuba For This Useful Post: [ Click to Expand ]
 
khamsakamal48
Old
#43  
khamsakamal48's Avatar
Senior Member
Thanks Meter 480
Posts: 251
Join Date: Feb 2012
Location: Mumbai

 
DONATE TO ME
Could easily flash it on MIUI v 2.4.6 for HTC Incredible 2!
Cant confirm whether it is effective, anyway thanks!

Quote:
Originally Posted by PureMotive View Post
Okay guys, I just thought I'd give you my mod for achieving good-great battery life. This is the mod I use in Anthemô which has given me 50+ hours on a single charge. Feel free to include it in your own ROM or whatever. Giving credit would be nice
First: Here is a flashable .zip of the mod that may or may not work with your ROM. I'd still advise doing it manually.

Sysctl.conf
Step 1

Open up your ROM.zip (or whatever it's called) in 7zip (Windows) or Betterzip (OSX) and locate

sysctl.conf in /system/etc

If it's not in this directory, create it.

Step 2

In your sysctl.conf file, paste the following code and save it.

Code:
#sysctl.conf file
fs.nr_open=1053696;
fs.inotify.max_queued_events=32000;
fs.inotify.max_user_instances=256;
fs.inotify.max_user_watches=10240;
fs.lease-break-time=10;
fs.file-max=165164;
kernel.threads-max=525810;
kernel.random.write_wakeup_threshold=256;
kernel.random.read_wakeup_threshold=128;
kernel.panic=5;
kernel.sched_compat_yield=1;
kernel.panic=0;
kernel.panic_on_oops=1;
kernel.msgmni=2048;
kernel.msgmax=64000;
kernel.shmmni=4096;
kernel.shmall=2097152;
kernel.shmmax=268435456;
kernel.sem='500 512000 64 2048';
kernel.sched_features=24189;
kernel.hung_task_timeout_secs=30;
kernel.sched_latency_ns=18000000;
kernel.sched_min_granularity_ns=1500000;
kernel.sched_wakeup_granularity_ns=3000000;
kernel.sched_shares_ratelimit=256000;
kernel.sched_child_runs_first=0;
fs.lease-break-time=10;
fs.file-max=65536;
net.core.wmem_max=524288;
net.core.rmem_max=524288;
net.core.rmem_default=262144;
net.core.wmem_default=262144;
net.core.optmem_max=20480;
net.unix.max_dgram_qlen=50;
net.ipv4.tcp_keepalive_time=900;
net.ipv4.tcp_keepalive_probes=5;
net.ipv4.tcp_keepalive_intvl=156;
net.ipv4.tcp_timestamps=0;
net.ipv4.tcp_sack=1;
net.ipv4.tcp_fack=1;
net.ipv4.tcp_window_scaling=1;
net.ipv4.tcp_tw_recycle=1;
net.ipv4.tcp_tw_reuse=1;
net.ipv4.tcp_congestion_control=cubic;
net.ipv4.tcp_syncookies=1;
net.ipv4.conf.all.rp_filter=1;
net.ipv4.conf.default.rp_filter=1;
net.ipv4.tcp_synack_retries=2;
net.ipv4.tcp_syn_retries=2;
net.ipv4.tcp_max_syn_backlog=1024;
net.ipv4.tcp_max_tw_buckets=16384;
net.ipv4.icmp_echo_ignore_all=1;
net.ipv4.icmp_ignore_bogus_error_responses=1;
net.ipv4.tcp_no_metrics_save=1;
net.ipv4.tcp_fin_timeout=15;
net.ipv4.tcp_keepalive_intvl=30;
net.ipv4.tcp_keepalive_probes=5;
net.ipv4.tcp_keepalive_time=1800;
net.ipv4.ip_forward=0;
net.ipv4.conf.default.accept_source_route=0 ;
net.ipv4.conf.all.accept_source_route=0;
net.ipv4.conf.all.accept_redirects=0;
net.ipv4.conf.default.accept_redirects=0;
net.ipv4.conf.all.secure_redirects=0;
net.ipv4.conf.default.secure_redirects=0;
net.ipv4.udp_rmem_min=6144;
net.ipv4.udp_wmem_min=6144;
net.ipv4.tcp_rfc1337=1;
net.ipv4.ip_no_pmtu_disc=0;
net.ipv4.tcp_ecn=0;
net.ipv4.route.flush=1;
net.ipv4.tcp_rmem='6144 87380 524288';
net.ipv4.tcp_wmem='6144 87380 524288';
net.ipv6.conf.default.use_tempaddr=2;
net.ipv6.conf.all.use_tempaddr=2;
net.ipv6.conf.all.temp_prefered_lft=3600;
net.ipv6.conf.default.temp_prefered_lft=3600;
vm.dirty_ratio=90;
vm.dirty_background_ratio=80;
vm.oom_kill_allocating_task=1;
vm.overcommit_memory=1;
vm.page-cluster=3;
vm.drop_caches=3;
vm.min_free_kbytes=4096;
vm.panic_on_oom=0;
vm.dirty_expire_centisecs=1000;
vm.dirty_writeback_centisecs=2000;
vm.oom_kill_allocating_task=0;
vm.vfs_cache_pressure=10;
vm.min_free_order_shift=4;
vm.laptop_mode=0;
vm.block_dump=0;
Step 3

Now we need to enable it. So, navigate to /system/etc/init.d and create a file with the following code:

Code:
#!/system/bin/sh
# grep sysctl /etc/init.d/*
# Load /sys/etc/sysctl.conf
sysctl -p
sysctl -p is what initializes the code.
Just FYI: You don't actually need these lines:

Code:
# grep sysctl /etc/init.d/*
Code:
# Load /sys/etc/sysctl.conf
So this would have just sufficed.

Code:
#!/system/bin/sh
sysctl -p
If the above code does not work for any reason, try this:

Code:
#!/system/bin/sh
sysctl -p /system/etc/
Name your file something like this 10sysctl

Save your file.

NOTE: Your ROM must support init.d. You can do this by using dsixda's android kitchen

Step 4

Save your ROM and install it via recovery

OR

you could just push the files into your current ROM and try them out.

----------- For knowledge -----------


Credits to imoseyon for portions of the info

Ok, so what exactly is sysctl.conf?

The sysctl.conf is a configuration file for "sysctl" which is an interface for dynamically changing kernel parameters in the Linux OS. The configuration file contains the following elements, vm.min_free_kbytes, vm.dirty_ratio, vm.dirty_backgroud_ratio, vm.vfs_cache_pressure, vm.oom_kill_allocating_task. There are many other elements within the file, but we will be primarily focusing on these specifically (the vm prefix stands for virtual memory). The sysctl.conf file should be located in /etc (/system/etc) by default. To enable it you need your ROM to execute "sysctl -p" somewhere during the boot process (or shortly afterward). We will also be discussing how to enable it if it is not already done so. You can also run sysctl -p manually to enable it any time after the OS is started.

Now, letís get down to what sysctl.conf does and how it works.

min free kbytes (vm.min_free_kbytes)
This is used to force the Linux VM to keep a minimum number of kilobytes free. The VM uses this number to compute a pages_min value for each lowmem zone in the system. Each lowmem zone gets a number of reserved free pages based proportionally on its size. Default is 2048kb.

dirty ratio (vm.dirty_ratio) and dirty background ratio (vm.dirty_background_ratio)
This controls how often the kernel writes data to "disk" (in our case the internal microSD system card, not the removable microSD card). When your apps write data to disk, Linux actually doesn't write the data out to the disk right away, it actually writes the stuff to system memory and the kernel handles when and how the data is actually going to be flushed to the disk. These values represent a percentage, the higher the percentage, the longer it waits to flush, the lower the percentage, the more often flushes will occur. Now remember, we are dealing with solid state storage, not the traditional disk platter and spindle. So we are actually able to delay flushes a little longer with solid state versus a traditional hard drive disk.

VFS Cache Pressure
Now here is where it gets interesting! File system cache (dentry/inode) is really more important than the block cache above in dirty ratio and dirty background ratio, so we really want the kernel to use up much more of the RAM for file system cache, this will increas the performance of the system without sacrificing performance at the application level. The default value is 100, as a percentage, and what you want to do is lower the value to tell the kernel to favor the file system cache and not drop them aggressively.

oom allocating task (vm.oom_kill_allocating_task)(enable or disable, generally in Linux this value is either a "1" or a "0," representing as on or off.)
This enables or disables killing the OOM-triggering task in out-of-memory (oom) situations. If this is set to zero, or disabled, the OOM killer will scan through the entire task list and select a task based on heuristics to kill. This normally selects a rogue memory-hogging task that frees up a large amount of memory when killed. If this is set to non-zero, or enabled, the OOM killer simply kills the task that triggered the out-of-memory condition. This avoids the expensive task list scan, which can take mass amounts of time and "hang" or freeze the system.

block_dump (vm.block_dump)
This enables block I/O debugging when set to a nonzero value. If you want to find out which process caused the disk to spin up (see /proc/sys/vm/laptop_mode), you can gather information by setting the flag.

When this flag is set, Linux reports all disk read and write operations that take place, and all block dirtyings done to files. This makes it possible to debug why a disk needs to spin up, and to increase battery life even more. The output of block_dump is written to the kernel output, and it can be retrieved using "dmesg". When you use block_dump and your kernel logging level also includes kernel debugging messages, you probably want to turn off klogd, otherwise the output of block_dump will be logged, causing disk activity that is not normally there.

overcommit_memory (vm.overcommit_memory)
This controls overcommit of system memory, possibly allowing processes to allocate (but not use) more memory than is actually available.

0 - Heuristic overcommit handling. Obvious overcommits of address space are refused. Used for a typical system. It ensures a seriously wild allocation fails while allowing overcommit to reduce swap usage. root is allowed to allocate slighly more memory in this mode. This is the default.
1 - Always overcommit. Appropriate for some scientific applications.
2 - Don't overcommit. The total address space commit for the system is not permitted to exceed swap plus a configurable percentage (default is 50) of physical RAM. Depending on the percentage you use, in most situations this means a process will not be killed while attempting to use already-allocated memory but will receive errors on memory allocation as appropriate.

page-cluster (vm.page-cluster)
This controls the number of pages which are written to swap in a single attempt. The swap I/O size.

It is a logarithmic value - setting it to zero means "1 page", setting it to 1 means "2 pages", setting it to 2 means "4 pages", etc.

The default value is three (eight pages at a time). There may be some small benefits in tuning this to a different value if your workload is swap-intensive.

panic_on_oom (vm.panic_on_oom)
This enables or disables panic on out-of-memory feature. If this is set to 1, the kernel panics when out-of-memory happens. If this is set to 0, the kernel will kill some rogue process, by calling oom_kill().

Usually, oom_killer can kill rogue processes and system will survive. If you want to panic the system rather than killing rogue processes, set this to 1.

The default value is 0.

Panic is a system error that is detected by the kernel.

dirty_expire_centisecs (vm.dirty_expire_centisecs)
How old "dirty" data should be before the kernel considers it old enough to be written to disk. It is expressed in 100ths of a second.

dirty_writeback_centisecs (vm.dirty_writeback_centisecs)
This is the interval of when the writeback daemons periodically wake up and write "old" data out to disk. It is expressed in 100ths of a second.
The Following User Says Thank You to khamsakamal48 For This Useful Post: [ Click to Expand ]
 
Hero
Old
#44  
Hero's Avatar
Recognized Developer - OP
Thanks Meter 4793
Posts: 1,279
Join Date: Oct 2010
Location: West Hollywood

 
DONATE TO ME
This is just a hunch, but if you want to check to see whether the mod stuck, use the following codes:

Code:
sysctl -a| grep vm
Code:
sysctl -a| grep net
Code:
sysctl -a| grep fs
Code:
sysctl -a| grep kernel
If they allow you to see the changes, then I will add them to the OP
 
Zerox8610
Old
#45  
Senior Member
Thanks Meter 6
Posts: 187
Join Date: May 2010
Just installed on CM7 with Increikernel soooooo I'll see how it does tomorrow! Thanks!
 
tomjoad2
Old
#46  
Member
Thanks Meter 9
Posts: 78
Join Date: Nov 2007
Quote:
Originally Posted by PureMotive View Post
This is just a hunch, but if you want to check to see whether the mod stuck, use the following codes:

Code:
sysctl -a| grep vm
Code:
sysctl -a| grep net
Code:
sysctl -a| grep fs
Code:
sysctl -a| grep kernel
If they allow you to see the changes, then I will add them to the OP
Done manually, but when a try to check with "sysctl -a| grep vm" I cannot see any changes
 
sherpajosh
Old
#47  
Member
Thanks Meter 5
Posts: 79
Join Date: May 2008
So I flashed this onto my Inc with CM7.2 and nothing changed. So tried changing the permissions on both files to owner r/w/x and group r/x and then reboot. Still no luck, no change when I terminal sysctl -a| grep vm, still the old values.
 
tomjoad2
Old
#48  
Member
Thanks Meter 9
Posts: 78
Join Date: Nov 2007
Quote:
Originally Posted by sherpajosh View Post
So I flashed this onto my Inc with CM7.2 and nothing changed. So tried changing the permissions on both files to owner r/w/x and group r/x and then reboot. Still no luck, no change when I terminal sysctl -a| grep vm, still the old values.
Same to me...
 
TeeRom
Old
#49  
TeeRom's Avatar
Senior Member
Thanks Meter 113
Posts: 320
Join Date: May 2011

 
DONATE TO ME
Installed on my Gnex, gonna see how well it works. Thanks.
Galaxy Nexus LTE
  • TeeROM v2.0
  • Leankernel
  • 4.0.4 radios



Droid Incredible SLCD (Retired)
  • CM9 Alpha
  • Android 4.0.3
 
kubes069
Old
#50  
kubes069's Avatar
Senior Member
Thanks Meter 33
Posts: 176
Join Date: Sep 2011
Location: New Jersey
I am trying this with Incredible 2 running MIUI GB.

I too am getting permission denied when checking to see if the mod stuck or not.

THREAD CLOSED
Subscribe
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes