Jump to content


Photo

[HOW TO] CREATE YOUR OWN SYSCTL SETTINGS

sysctl.confsysctl battery life improve settings how to kernel performance

  • Please log in to reply
9 replies to this topic

#1 HOOKEDONDROID

HOOKEDONDROID

    Superuser

  • Superuser
  • 102 posts
  • LocationUtah
  • Current Device(s):Htc Droid DNA

Posted 19 September 2013 - 09:40 PM

Memnoch asked me to post some mods here, so I figured I would start with what I call a battery/kernel improvement mod.
 
I will walk you through how to write the script and also make sure it runs during boot and the settings stay.
 
Please, feel free to ask for help and the feedback is always welcome.
 
With all mods, your mileage will probably vary, your experience my slightly vary. Don't blame me, or my work if you fubar  your phone. You chose to apply these settings, and knowingly modified your device. Now we can continue  :D
 
 
Ok some things  we will need...
1)Init.d support in a Rom
2)

Please Login or Register to see this Hidden Content

(its free)
3)A little bit of knowledge of how to navigate using a root file manager. I use R

Please Login or Register to see this Hidden Content

, all instructions will be using it. If you choose to use another program the instructions should be mostly the same.
4)

Please Login or Register to see this Hidden Content

 -To check everything when we're done.
5)About 5 minutes time  :D
 
On to the instructions! 
 
1) Install Notepad++, open it, then copy the code below:

Please Login or Register to see this Hidden Content

2)Save the file as sysctl.conf, I usually save it to the desktop so its easy to find
 
3)Open a new tab in Notepad++ and type the following code:

Please Login or Register to see this Hidden Content

4)Save this file as S99Sysctl.sh, Again save to somewhere easy to find
 
5)Ok, now time to copy everything to the phone. Connect phone to computer and copy both files to SDcard, disconnect phone.
 
6)Open Root Explorer, find the sysctl.conf file. Copy it to /system/etc and set perms to rw-r-r
 
7)Now find the S99Sysctl file. Copy it to your init.d folder
 
8)Reboot phone
 
9)Enjoy!
 
You can do all of this through your phone if you'd like.When I have time in the future, I'll write how to do so for yall.
 
Now to see if what we just wrote is working  :D
 
Open Rom Toolbox, and slide to Performance the choose Kernel Tweaks. Check to see if what we placed into the sysctl.conf file is displayed correctly. I always scroll down to vm.vfs_cache_pressure and it should say 10%. 
 

B]Ok, so what exactly is sysctl.conf?[/B]

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 (vm.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.

Let me know how it goes!!

  • Memnoch73 and RikRong like this

#2 Sabres032

Sabres032

    Large and in charge EMS minion

  • Members
  • PipPipPipPipPip
  • 9,515 posts
  • LocationWayward USA
  • Current Device(s):Google Pixel 2 XL

Posted 20 September 2013 - 06:23 AM

Is this for sense ROMs or any? Right now I'm running CM 10.2 with crpalmer's kernel. It seems as though palmer has his kernel pretty much optimized, I'm getting nearly 16 to 17 hours battery time with about three hours screen on time.

IMG_12705794666508.jpeg


Sent from my Marine World N6 or my Nexus 7 2013 WiFi I'll let you figure out which.

#3 HOOKEDONDROID

HOOKEDONDROID

    Superuser

  • Superuser
  • 102 posts
  • LocationUtah
  • Current Device(s):Htc Droid DNA

Posted 20 September 2013 - 08:47 AM

Is this for sense ROMs or any? Right now I'm running CM 10.2 with crpalmer's kernel. It seems as though palmer has his kernel pretty much optimized, I'm getting nearly 16 to 17 hours battery time with about three hours screen on time.

It's for any Rom, no matter if it's sense etc. Most devs don't touch the sysctl file when compiling a rom. They leave it as stock, and playing with pressures and other settings. I get just a little better life, with no performance loss. Try it for a couple days, and let me know how it goes...:D.

Sent from my HTC6435LVW using Tapatalk 2


  • Sabres032 likes this

#4 Sabres032

Sabres032

    Large and in charge EMS minion

  • Members
  • PipPipPipPipPip
  • 9,515 posts
  • LocationWayward USA
  • Current Device(s):Google Pixel 2 XL

Posted 20 September 2013 - 09:01 AM

It's for any Rom, no matter if it's sense etc. Most devs don't touch the sysctl file when compiling a rom. They leave it as stock, and playing with pressures and other settings. I get just a little better life, with no performance loss. Try it for a couple days, and let me know how it goes... :D.

Sent from my HTC6435LVW using Tapatalk 2

 

I'll wait until I fully understand what I'm doing that I'll give it a try. Not worried about borking the phone since I do a nandroid every other day just I'd like to understand what's happening. Like Sam says "read, read and then read again.  :D


IMG_12705794666508.jpeg


Sent from my Marine World N6 or my Nexus 7 2013 WiFi I'll let you figure out which.

#5 HOOKEDONDROID

HOOKEDONDROID

    Superuser

  • Superuser
  • 102 posts
  • LocationUtah
  • Current Device(s):Htc Droid DNA

Posted 20 September 2013 - 09:14 AM

I'll wait until I fully understand what I'm doing that I'll give it a try. Not worried about borking the phone since I do a nandroid every other day just I'd like to understand what's happening. Like Sam says "read, read and then read again. :D

Check back to this post in a few, I have an explanation that I'll bring over. I'll add it to the op tonight..

Edit...added to op:D
Sent from my HTC6435LVW using Tapatalk 2


#6 Memnoch73

Memnoch73

    ~The Devil~

  • Smod
  • 5,016 posts
  • Google+:memnoch73@gmail.com
  • LocationRochester, NY
  • Current Device(s):Pixel 3XL

Posted 20 September 2013 - 09:43 AM

Should the first one be all one line when you paste it into Notepad ++?? 

 

Is the 2nd one just saved as a .txt file??


Bluesig3_zpsfd248ca4.png

 


#7 HOOKEDONDROID

HOOKEDONDROID

    Superuser

  • Superuser
  • 102 posts
  • LocationUtah
  • Current Device(s):Htc Droid DNA

Posted 20 September 2013 - 09:57 AM

Should the first one be all one line when you paste it into Notepad ++??

Is the 2nd one just saved as a .txt file??

No, I may need to adjust the way the code box handles the code. Everything needs to be on it's own line.
Also looking at it in tapatalk, it groups everything together. Hmm, what if I just did the code as plain text?

Save S99Sysctl as a .sh file, sorry forgot to add that in...

I wanted to teach people how to create the script, not just make a flashable. Maybe that's what I'll need to do. That or make downloadable files to just paste I to each area...


Sent from my HTC6435LVW using Tapatalk 2


#8 HOOKEDONDROID

HOOKEDONDROID

    Superuser

  • Superuser
  • 102 posts
  • LocationUtah
  • Current Device(s):Htc Droid DNA

Posted 20 September 2013 - 10:22 AM


Should look like this...
Sent from my HTC6435LVW using Tapatalk 2

Attached Files



#9 Memnoch73

Memnoch73

    ~The Devil~

  • Smod
  • 5,016 posts
  • Google+:memnoch73@gmail.com
  • LocationRochester, NY
  • Current Device(s):Pixel 3XL

Posted 20 September 2013 - 11:58 AM

I think a flashable zip with an explanation would be perfect. It would allow more people to enjoy your work as well as for guys like us to read about it and gain some understanding of what it happening.

 

Thanks again for posting this


Bluesig3_zpsfd248ca4.png

 


#10 HOOKEDONDROID

HOOKEDONDROID

    Superuser

  • Superuser
  • 102 posts
  • LocationUtah
  • Current Device(s):Htc Droid DNA

Posted 20 September 2013 - 12:15 PM

I think a flashable zip with an explanation would be perfect. It would allow more people to enjoy your work as well as for guys like us to read about it and gain some understanding of what it happening.

Thanks again for posting this

Ok, when I get back to my pc I'll build one and put it up...I'm also writing up some build.prop stuff and some write ups on other mods you can do to any rom.

Sorry guys

Sent from my HTC6435LVW using Tapatalk 2





Also tagged with one or more of these keywords: sysctl.confsysctl, battery, life, improve, settings, how, to, kernel, performance

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users