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

Discussion in 'Liberty ROM D2' 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 FINAL]
    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.

    Changing all kernel tweaked values and an auto flush via flashing a .zip file:

    Imoseyon was nice enough to make us all a flashable .zip file which makes all tweaks for us :). Thank you Imoseyon!!!

    Due to the amount of times Imoseyon updates his zip I will from now on just be directing you to his site. Check back now and then to see if there is an update available.

    http://www.imoseyon.com


    Enabling Sysctl and changing (most) values via LIberty Settings (Update Liberty Toolbox in 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 you're 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."

    Note: If you chose the flashable .zip method then this is done for you automatically at 1AM PST and you don't need to read this.

    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:

    sync; echo 3 > /proc/sys/vm/drop_caches

    "Tells the system to drop all file system caches"

    **REVERTING BACK TO STOCK**

    1) revert build.prop file
    2) delete /etc/init.d/99imoseyon.



    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: Apr 2, 2011
  2. thebird36
    Offline

    thebird36 New Member

    Joined:
    Oct 31, 2010
    Messages:
    410
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New York
    when you do the sysctl -a | grep vm how would i get the straight line because i cant go into symbols
    EDIT: unless its the button in the top left corner with the line and arrow
  3. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    You'll need to use the onscreen keyboard for that symbol.
  4. thebird36
    Offline

    thebird36 New Member

    Joined:
    Oct 31, 2010
    Messages:
    410
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New York
    ight thank you sir :)
  5. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    No problem. Let me know how it works for you!
  6. thebird36
    Offline

    thebird36 New Member

    Joined:
    Oct 31, 2010
    Messages:
    410
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New York
    well i got it all done the phone seems to move faster which is a good sign i'll let you know later tonite on how the battery was i'm not going to be using it a whole lot since i have other things to do tonite
    btw i was in rochester last week =) at montage music hall last saturday
  7. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    I found the increase in battery life a lot more noticable than the increased prefomance. You'll see :)
  8. thebird36
    Offline

    thebird36 New Member

    Joined:
    Oct 31, 2010
    Messages:
    410
    Likes Received:
    1
    Trophy Points:
    0
    Location:
    New York
    haha well then i might be in for a surprise :)
  9. want a droid
    Offline

    want a droid New Member

    Joined:
    Jul 5, 2010
    Messages:
    1,094
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Maryland
    Thanks for the write up Jboxen. I've been waiting for one of these to show up.
  10. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    :)
    No problem :)
  11. jrummy16
    Offline

    jrummy16 Premium Member Theme Developer Premium Member Developer

    Joined:
    Jan 25, 2010
    Messages:
    1,212
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Orange County, CA
    Updated the toolbox in the android market.. bugs with sysctl should be fixed. If they are not shoot me a pm or something.
  12. want a droid
    Offline

    want a droid New Member

    Joined:
    Jul 5, 2010
    Messages:
    1,094
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Maryland
    Meaning we can use the settings instead of root explorer?
  13. jrummy16
    Offline

    jrummy16 Premium Member Theme Developer Premium Member Developer

    Joined:
    Jan 25, 2010
    Messages:
    1,212
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Orange County, CA
    Yes, unless you want to add some extra tweaks not found in liberty toolbox.
  14. want a droid
    Offline

    want a droid New Member

    Joined:
    Jul 5, 2010
    Messages:
    1,094
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Maryland
    I tested and changing inputs in the settings works now.
  15. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    Thank you Jrummy.
  16. knivesout
    Offline

    knivesout New Member

    Joined:
    Feb 2, 2011
    Messages:
    163
    Likes Received:
    0
    Trophy Points:
    0
    So this tweak basically improves battery life and CPU performance? I've found Liberty pretty snappy as it is and between the extended battery and this rom, I'm getting some damn good battery life already. Can I basically accomplish the same thing by emptying the cache manually through Liberty mods every day or so? I know that this mod does more than auto-empty the cache but just wondering.
  17. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    This mod actually emptys the vm cache less, which is why I said to reboot every day or run that script.

    Vm cache and data cache are differen't.
    Last edited: Feb 5, 2011
  18. knivesout
    Offline

    knivesout New Member

    Joined:
    Feb 2, 2011
    Messages:
    163
    Likes Received:
    0
    Trophy Points:
    0
    Ah, ok. Learn something new all the time here. When you empty the cache through liberty mods, that would just be the data cache then?
  19. Jboxen
    Offline

    Jboxen Premium Member Premium Member Developer

    Joined:
    Jun 15, 2010
    Messages:
    902
    Likes Received:
    0
    Trophy Points:
    0
    Location:
    Rochester, NY
    Correct.

    10char
  20. jovapa
    Offline

    jovapa New Member

    Joined:
    Jan 22, 2011
    Messages:
    52
    Likes Received:
    0
    Trophy Points:
    0
    Probably a stupid question, but does this mean the toolbox that came with 1.5 is now out of date?



    Sent from my DROID2 using DroidForums App
Search tags for this page
android dirty ratio
,
ejamaru7
,
laptop mode android
,
min free order shift
,
overcommit ratio android
,

sysctl examples

,
sysctl examples android
,
sysctl faq
,
sysctl tutorial
,
vm laptop mode android
,
vm min free order shift
,
vm.laptop mode android