[Tutorial]Sysctl and you, A guide to better preformance and battery life.

Discussion in 'Liberty ROM DX' started by Jboxen, Feb 5, 2011.

  1. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    [UPDATED 2.2]
    First off I would like to say I have gotten all of my information for this mod here: imoseyon I would also like to thank the developer for posting all of his findings and for all of his hard work.

    Enabling Sysctl and changing (most) values via LIberty Settings (Update Liberty Toolbox from the market and it will work.)

    Sysctl Support: Check
    Min Free KBytes: 4096
    Dirty Ratio: 90
    Dirty Background Ratio: 70
    VFS Cache Pressure: 1
    Oom Allocating Task: Check

    Reboot your phone, go to the terminal emulator and type in:

    sysctl -a | grep vm


    Note: This will not give you all of the mods that are available, if you want the remaining mods, continue down to the next methods.

    If your settings have been saved using the App and you don't want the additional mods, then you are all done! Thanks Jrummy! Make sure you scroll down to the bottom of the post and read the IMPORTANT section as it applies to every version of this mod.

    Edit: The NEWEST version of Liberty Toolbox fixes the bugs but if your also running Droid Overclock then read below.



    Enabling Sysctl and changing (most) values via Jrummy's Droid Overclock App
    Note: If you have this and are running Liberty, you will have to change the settings in Droid Overclock too as the Liberty settings will be over-written.

    Jrummy has released an update to Droid Overclock, v.2.0.2. So go to the market and update it if you haven't already. Open up his Droid Overclock app and press Menu>Settings>Advanced Settings. Scroll down until you see Sysctl and do the following.

    Sysctl Support: Check
    Min Free KBytes: 4096
    Dirty Ratio: 90
    Dirty Background Ratio: 70
    VFS Cache Pressure: 1
    Oom Allocating Task: Check

    Reboot your phone, go to the terminal emulator and type in:

    sysctl -a | grep vm

    This version of Jrummy's Sysctl enabler and editor has worked for me so he must have squashed the bugs. Thanks Jrummy!

    Note: This will not give you all of the mods that are available, if you want the remaining mods, continue down to the next methods.



    Enabling Sysctl and changing values via Root Explorer

    So now onto the next step, enabling and changing the values manually. First off we should start by enabling sysctl. This can be done with root explorer...
    Open up root explorer and go to /data/liberty and mount the system RW. Long press on init.d.config and open it in the text editor. Now scroll down until you find SYSCTL and set that from 0 to 1.
    Sysctl is now enabled.

    Note: If for whatever reason you would like to disable this later on just use the backup file it created to do so.

    Now to set the values that Sysctl will be changing, also done with root explorer. This will be done in the /etc folder. Navigate yourself to the /etc folder and see if you already have a sysctl.conf. If not, click the menu softkey and then click more>new file. Name this new file sysctl.conf . Mount the system RW now and open the file in the text editor again. Now type exaclty these lines into the file. (It's ok to delete what's there if anything and replace it with this.)


    vm.swappiness = 0
    vm.min_free_kbytes = 4096
    vm.dirty_ratio = 90
    vm.dirty_background_ratio = 70
    vm.vfs_cache_pressure = 1
    vm.panic_on_oom = 2
    vm.oom_kill_allocating_task = 1
    kernel.panic = 5
    kernel.shmmax = 2268435456
    kernel.shmall = 16777216


    Save it and you can erase the backup that it creates as there is no original file.

    Now reboot your phone and open your terminal up. Type in this command again:

    sysctl -a | grep vm

    You should see your settings have been applied and are working as intended. If you see any errors, go back to the file and make sure you typed everything into sysctl.conf correctly. (There will be 2 permission denied errors at the very bottom when typing in this command but they aren't important.)



    Enabling Sysctl and changing values via VI commands

    After mounting the system RW, going in to terminal emulation, at the prompt:

    vi /data/liberty/init.d.conf

    Now, vi is an old school text editor so you have to maneuver around using the following keys because we have no cursor keys in droid:

    j = move cursor down one line
    k = move cursor up one line
    h = move cursor right one character
    l = mover cursor left one character

    Right now you are in vi's command mode. This allows you to move around and issue commands like save, undo, quit, etc.

    Find the line that says:

    SYSCTL=0

    Move the cursor so it is sitting right on top of 0 and press r which means to replace the character underneath the cursor and type 1.

    Save the file and quit back to the prompt by typing :wq (you will actually see this command typed at the bottom of the editor)

    Once back at the prompt, to edit the other config file:

    vi /etc/sysctl.conf

    If was easier for me to delete all the lines in there and type everything in so typing dd deletes one line at a time.

    Once all the lines are deleted, press i which means start inserting at the cursor. This puts you into edit mode in vi. Type in the following lines as detailed by Jboxen in his post:

    vm.swappiness = 0
    vm.min_free_kbytes = 4096
    vm.dirty_ratio = 90
    vm.dirty_background_ratio = 70
    vm.vfs_cache_pressure = 1
    vm.panic_on_oom = 2
    vm.oom_kill_allocating_task = 1
    kernel.panic = 5
    kernel.shmmax = 2268435456
    kernel.shmall = 16777216

    Once you are done, we need to get back into command mode by press ESC. Since the keyboard doesn't support the ESC key, we need to change a setting in terminal emulation. Hit the menu button | Preferences | Control key. I changed mine to be Vol Down. Pressing Vol Down and then 1, gets me back to command mode. Type in :wq to save and quit.

    After that reboot, go back into terminal emulation, check your work by typing:

    sysctl -a | grep vm

    If you screw up editing your files at any point and want to abandon your changes in vi, press ESC (in my settings it's Vol Down and then "1"), and type in ":q!" (minus quotes obviously)

    Anyways, you can find more info on vi commands here.

    Thank you to freezyfreaky for these instructions. :)

    IMPORTANT: "after a day or two your device may start getting sluggish because the amount of RAM available to the applications continue to shrink to the point where they are starved for memory."

    There's two solutions to this really, and they are very easy.

    1. Reboot your phone when you wake up and take it off the charger in the morning.(easy)
    2. Run this script in terminal emulator when you wake up in the morning:

    echo 3 > /proc/sys/vm/drop_caches

    "Tells the system to drop all file system caches"



    Now if you want to know why this works and what it does I would suggest following the link at the top of the page because he can explain it much better than I can. He also has so many more cool things that he has experimented with. I recomend reading it all.

    Well, there you go! Enjoy guys this is a great mod and should make the Communitty very happy! :)

    Disclaimer: I am not responisble for anything that happens to your phone as a result of this mod, anything you do to your device is your responsibility.
    Last edited: Feb 8, 2011
  2. EagleStrike
    Offline

    EagleStrike New Member

    Joined:
    Mar 3, 2010
    Messages:
    98
    Likes Received:
    1
    Trophy Points:
    0
    It would be really nice to divide it up into sections. A giant wall of text is very intimidating and can be very hard to read.
  3. markhamr
    Offline

    markhamr New Member

    Joined:
    Nov 5, 2010
    Messages:
    19
    Likes Received:
    0
    Trophy Points:
    0
    This would be a lot more useful if it were organized and not a wall of text
  4. teh_g
    Offline

    teh_g New Member

    Joined:
    Oct 14, 2010
    Messages:
    383
    Likes Received:
    0
    Trophy Points:
    0
    I don't think that clearing the cache on every boot will lead to better performance or battery life, especially since you are recommending rebooting every day or two to clear up the memory for applications. The cache will have to be rebuilt on reboot, increasing the boot time, and increasing the amount of CPU cycles being used for cache writing. The Android system, is fairly intelligent about how it handles cache.
  5. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    Sorry, It copied weird I'm fixing it now.
  6. EXQEX9
    Offline

    EXQEX9 New Member

    Joined:
    Jul 25, 2010
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    California
    <--- Anxiously waiting for OP to fix the OP so I can...read it. :)
  7. want a droid
    Offline

    want a droid New Member

    Joined:
    Jul 5, 2010
    Messages:
    1,094
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Maryland
  8. EXQEX9
    Offline

    EXQEX9 New Member

    Joined:
    Jul 25, 2010
    Messages:
    32
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    California
  9. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    Fixed!!!! :)
    Last edited: Feb 5, 2011
  10. gobbles23
    Offline

    gobbles23 New Member

    Joined:
    Jan 19, 2011
    Messages:
    75
    Likes Received:
    0
    Trophy Points:
    0
    Quick question. How can I know that the sysctl settings are active if liberty has a bug?

    Sent from my DROIDX using DroidForums App
  11. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    Set the values manually like I did and run that script
  12. db306
    Offline

    db306 New Member

    Joined:
    Feb 26, 2010
    Messages:
    131
    Likes Received:
    0
    Trophy Points:
    0
    I believe Rummy updated the toolbox to fix the bug. I was wondering if anyone has played around with the numbers through Liberty settings sysctl configuration, and if so could someone post the numbers that they have found to better battery life? Thanks
  13. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    He did but the update works for some and doesn't work for others. Also these values have shown an increase in battery life for myself and other users on the thread in the D2 section.
  14. hnc2011
    Offline

    hnc2011 New Member

    Joined:
    Dec 26, 2010
    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    0
    For those without root explorer, here's what I did to edit the values

    1) First enable sysctl from liberty settings
    2) Open liberty toolbox -> liberty mods -> build properties -> file editor -> open the init.d.conf -> change sysctl value to 1 and save
    4) Go to liberty tweaks -> miscellaneous -> mount system read/write
    5) Go to settings -> liberty settings -> sysctl settings, change the values here.
    6) Open sysctl config app and change the settings there to the same values. Not sure if this is necessary but I did it anyway.
    7) Open terminal emulator and type "sysctl -p" (output should confirm whether you've done step 4&5 correctly)
    8) Settings should stay after reboot
  15. dlbrown75
    Offline

    dlbrown75 New Member

    Joined:
    Oct 26, 2010
    Messages:
    110
    Likes Received:
    0
    Trophy Points:
    0
    What is the outcome of doing these things? A clear set of directions would be great. When everyone starts adding different ways its hard to pick which to follow. I updated liberty toolbox and it works. Now what?

    Sent from my DROIDX using DroidForums App
  16. dlbrown75
    Offline

    dlbrown75 New Member

    Joined:
    Oct 26, 2010
    Messages:
    110
    Likes Received:
    0
    Trophy Points:
    0
    One more question: can I get phone back to original?

    Sent from my DROIDX using DroidForums App
  17. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    Yes you can I showed you how in the OP, Also all of these ways may work for some but my directions in the OP will work for all.
  18. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    All OP's have been updated.
  19. macpro88
    Offline

    macpro88 DF Super Moderator

    Joined:
    Feb 7, 2011
    Messages:
    1,400
    Likes Received:
    83
    Trophy Points:
    48
    Location:
    Ohio
    Hey guys, not saying your late to the party here, but I have a great thread going over on droidxforums.com that I started on Jan 15 Liberty 1.0 and Syssctl Config
    Check it out, there are a lot of great posts there.

    Mod Edit: Removed Blog Link

    Enjoy
    Last edited by a moderator: Feb 8, 2011
  20. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    OP has been updated with Jrummy's OC app method.
Search tags for this page
android performance sysctl
,

android sysctl

,
android sysctl.conf
,
best sysctl settings android
,
edit sysctl.conf android
,

min free kbytes

,
min free kbytes android
,
min free kbytes oom killer
,
minfree kbytes
,

sysctl android

,
sysctl editor
,
sysctl mods for galaxy s3
,

sysctl.conf android

,
sysctl.conf permissions
,
vfs cache pressure android