how to improve user performance on android phones

I am not responsible if you mess your phone up.  Seriously.

The following requires that you root your phone.  That is not covered here, however for the Droid you can update your 2.0.1 phone with this

Connect to your phone with adb shell, then:

$ su
# mount -o remount,rw /system
# echo 'kernel.sched_latency_ns = 600000' >> /etc/sysctl.conf
# echo 'kernel.sched_min_granularity_ns = 400000' >> /etc/sysctl.conf
# echo 'kernel.sched_features = 24188' >> /etc/sysctl.conf
# mount -o remount,ro /system
# sysctl -p
kernel.sched_latency_ns = 600000
kernel.sched_min_granularity_ns = 400000
kernel.sched_features = 24188
# exit
$ exit

Now your phone will behave a lot better.  To explain what those settings do:

Changing sched_features to 24188 disables some annoying CFS features (GENTLE_FAIR_SLEEPERS and NORMALIZE_SLEEPERS) that are stupid even on the desktop.  The other two crank the timeslice length down to 0.6ms/0.4ms.

What about BFS you say? Well BFS does not appear to perform very well on Android, and Android’s legitimate use of cgroups does not work on BFS.  However, the settings that the sysctls above change make CFS behave a lot more like BFS.

At any rate, after making these changes, my Motorola Milestone has no problems keeping up with another android phone I have (the HTC Incredible).

What does this mean?

This means that all the hype about JIT in Android 2.2 being the biggest possible source of performance improvement is a load of crap.  JIT will improve CPU-bound tasks, but it will not improve the interactivity of the underlying OS, which is what people are really complaining about.

This also proves that overclocking your phone is stupid and dangerous.  Just do the above and you won’t be damaging your phone’s hardware.  You will also get a much more noticeable performance boost out of this than you would out of overclocking your phone.

I mean, my Milestone is actually usable now.  It’s 550mhz and it has absolutely no problems keeping up with the Incredible’s 1000mhz CPU.  Just think about that.  The HTC’s CPU is being put to waste due to the way that the scheduler allocates timeslices.  If you disable the GENTLE_FAIR_SLEEPERS option, CFS becomes a very good scheduler for android, as it allows for sub-1ms timeslice deadlines.

Update: Disabling NORMALIZE_SLEEPERS on Android 1.6/2.0/2.1 is a good idea.

18 Responses to “how to improve user performance on android phones”

  1. moo says:

    do you have any numbers that prove that this is better? Your last paragraph makes some pretty broad statements but I am hoping to see some numbers proving this

  2. nenolod says:

    @moo: these are all scheduler enhancements made upstream already. Froyo already has them.

  3. htc incredible says:

    Hello all simply discovered the positioning and thought I’d say hello. I like lots of you might be ready for my Incredible to be shipped. I ordered it on-line on 6/9 they usually maintain telling me it can ship this Wednesday 6/30. Fingers crossed that it does this ready is killing me! I’m soo glad this website could be very informative to me. Thank you

  4. ernie says:

    Hi.. just tried this tweak on my Nexus One, but I encountered this problem:
    After echoing all the values to sysctl.conf and remounting.. when running ‘sysctl -p’ i get the following output:

    sysctl: error: ‘kernel.sched_latency_ns’ is an unknown key
    sysctl: error: ‘kernel.sched_min_granularity_ns’ is an unknown key
    sysctl: error: ‘kernel.sched_features’ is an unknown key

    Any ideas?

  5. nenolod says:

    If you’re on CyanogenMod you might have a BFS kernel, in which case… good luck.

    Those sysctls are for CFS only.

  6. Monique Whitten says:

    While I really like a bodily keyboard, after dealing with the Samsung Captivate for roughly quarter-hour, it’s exhausting to head back. Right now I am debating whether or not to visit Verizon for the Droid X, cross to Dash for the EVO, or stick with AT&T for the Captivate…choices, decisions.

  7. BoomOuttaHere says:

    Any chance this will work with the Droid X? BTW, I like your blog. I feel smarter after reading it. lol Thank you.

  8. chibucks says:

    nenolod – is this a permanent change or will it revert back at reboot? if you wanted to revert, how would you do it?

  9. nenolod says:

    Yes, it will work on any Android 2.1 device that is running a CFS-based kernel. It will not work on CyanogenMod-provided kernels that use BFS.

  10. nenolod says:

    The sysctl.conf changes make it permanent. If you want to revert them, just push a new sysctl.conf to your device without the lines you added. There shouldn’t be any need to revert though.

  11. Improving Android Performance (SysCtl) says:

    [...] Android Performance (SysCtl) According to this page, using sysctl tweaks will provide performance benefits similar to overclockery, minus the wear and [...]

  12. f_p says:

    hi these tweaks work well on my hero. im running a 2.2 ROM from XDA forums. Even though you say in your post these tweaks will work well on 1.6/2.0/2.1 Android versions I have noticed improved interactivity on the 2.2 ROM too. I was jsut wondering if you could give a few more details on the actual parameters you use. What do the sched_latency and sched_min_granularity values actually do? (in laymans terms please :) ) also an explanation of the sleeper functions would also be nice. thanks.
    p.s. you could email me if youd rather not go into detail in the comments

  13. nenolod says:

    sched_latency defines the maximum allowed latency in a task. tightening it up to 600000ns keeps the maximum allowed latency to sub-1ms levels, which causes the scheduler to value stricter fairness without giving CPU heavy tasks anything.

    sched_min_granularity defines the maximum allowed latency for preemption. tightening that up causes the kernel to favor task preemption, e.g. from I/O and other events such as signalling on a POSIX semaphore object (think: pthread_cond_wait, for instance). tasks that are sleeping as they wait for I/O completions or signals from other tasks and threads get immediate preemption when those events complete.

    now for an explanation of the SLEEPERS bits in the sched_features sysctl:

    FAIR_SLEEPERS/GENTLE_FAIR_SLEEPERS were attempts at giving sleeping tasks which would soon wake up an advantage over CPU running tasks. the FAIR_SLEEPERS codepath was removed in 2.6.34, the GENTLE_FAIR_SLEEPERS codepath was forced on in 2.6.35, but testing showed that it was less harmful than FAIR_SLEEPERS. disabling both ensures strict fairness.

    NORMALIZE_SLEEPERS attempted to balance sleeping tasks and wait times to guarantee fairness when used in conjunction with FAIR_SLEEPERS/GENTLE_FAIR_SLEEPERS.

  14. f_p says:

    thanks for the explanation. in conjunction with some other sources i’ve got a better idea of what everything does now. On the Hero we are stuck on the 2.6.29 kernel so we dont have GENTLE_FAIR_SLEEPERS but we do have NEW_FAIR_SLEEPERS so i guessed disabling that would have the same effect.
    Even having applied these tweaks I notice that when scrolling through big lists I still get a bit of stutter. Even with no other running tasks I get a bit of stutter. I cant understand why this would be, surely 528MHz is enough to give a smooth scroll when no other tasks are running? Could this be to do with anything in the linux kernel?

  15. [ROM Beta] As of yet unnamed Blurless ROM - AOSP Wannabe - Android Forums says:

    [...] To be honest, I'm not sure if it's even necessary on Froyo, but it doesn't hurt Source: how to improve user performance on android phones __________________ Rooted Droid X running Tranquility 1.5 w/ [...]

  16. buli says:

    what is update from dell streak 1.6 to android 2.2 dutch netherlandse

  17. Diseño Web Granada says:

    I prefer IOS , i don´t like Android market.

  18. Jomson George says:

    I am not satisfied with my Android performance. I hope the above one will help me. Let me try this:)