Saturday, 3 October 2015

SetCPU tweaks - better performance and battery saving



After trying to prolong my LG Spirit's battery life, I noticed a peculiar thing after installing SetCPU. The processor stays at 800 MHz at idle. That is not supposed to be, especially since the lowest idle frequency is 200 MHz. I guess LG thought 800 MHz was the best possible mid-figure frequency that allows snappy interactivity with the phone, and set the Interactive governor accordingly to stay at 800. Screw that forced battery drain!

P.S. You can use Kernel Adiutor app, too.

So, I tried the Ondemand governor with noop scheduler - and I was amazed at the performance this budget handset is capable of and the battery I was getting on standby / idle. Only downside is that Ondemand loves to ramp up to 1.2 GHz, although it makes that up with fast "to idle" speed. But the performance was stellar!

After more testing and tweaking the Interactive governor a bit and checking out the results, I am very satisfied. There is an very ocassional stutter here or there, but I can live with it. Battery life alone is worth it:

Interactive / noop

above_hispeed_delay - 20000
boost - 0
boostpulse_duration - 80000
go_hispeed_load - 90
hispeed_freq - 400000
io_is_busy - 0
min_sample_time - 50000
target_loads - 95
timer_rate - 20000
timer_slack - 80000

If you prefer performance and don't mind sacrificing a bit of battery life, set it on Ondemand / noop.

Here's a read-up if anyone is interested in more details:

Code:


The CPUfreq governor "interactive" is designed for latency-sensitive,
interactive workloads. This governor sets the CPU speed depending on
usage, similar to "ondemand" and "conservative" governors, but with a
different set of configurable behaviors.
The tuneable values for this governor are:
target_loads: CPU load values used to adjust speed to influence the
current CPU load toward that value.  In general, the lower the target
load, the more often the governor will raise CPU speeds to bring load
below the target.  The format is a single target load, optionally
followed by pairs of CPU speeds and CPU loads to target at or above
those speeds.  Colons can be used between the speeds and associated
target loads for readability.  For example:
  85 1000000:90 1700000:99
targets CPU load 85% below speed 1GHz, 90% at or above 1GHz, until
1.7GHz and above, at which load 99% is targeted.  If speeds are
specified these must appear in ascending order.  Higher target load
values are typically specified for higher speeds, that is, target load
values also usually appear in an ascending order. The default is
target load 90% for all speeds.
min_sample_time: The minimum amount of time to spend at the current
frequency before ramping down. Default is 80000 uS.
hispeed_freq: An intermediate "hi speed" at which to initially ramp
when CPU load hits the value specified in go_hispeed_load.  If load
stays high for the amount of time specified in above_hispeed_delay,
then speed may be bumped higher.  Default is the maximum speed
allowed by the policy at governor initialization time.
go_hispeed_load: The CPU load at which to ramp to hispeed_freq.
Default is 99%.
above_hispeed_delay: When speed is at or above hispeed_freq, wait for
this long before raising speed in response to continued high load.
The format is a single delay value, optionally followed by pairs of
CPU speeds and the delay to use at or above those speeds.  Colons can
be used between the speeds and associated delays for readability.  For
example:
  80000 1300000:200000 1500000:40000
uses delay 80000 uS until CPU speed 1.3 GHz, at which speed delay
200000 uS is used until speed 1.5 GHz, at which speed (and above)
delay 40000 uS is used.  If speeds are specified these must appear in
ascending order.  Default is 20000 uS.
timer_rate: Sample rate for reevaluating CPU load when the CPU is not
idle.  A deferrable timer is used, such that the CPU will not be woken
from idle to service this timer until something else needs to run.
(The maximum time to allow deferring this timer when not running at
minimum speed is configurable via timer_slack.)  Default is 20000 uS.
timer_slack: Maximum additional time to defer handling the governor
sampling timer beyond timer_rate when running at speeds above the
minimum.  For platforms that consume additional power at idle when
CPUs are running at speeds greater than minimum, this places an upper
bound on how long the timer will be deferred prior to re-evaluating
load and dropping speed.  For example, if timer_rate is 20000uS and
timer_slack is 10000uS then timers will be deferred for up to 30msec
when not at lowest speed.  A value of -1 means defer timers
indefinitely at all speeds.  Default is 80000 uS.
boost: If non-zero, immediately boost speed of all CPUs to at least
hispeed_freq until zero is written to this attribute.  If zero, allow
CPU speeds to drop below hispeed_freq according to load as usual.
Default is zero.
boostpulse: On each write, immediately boost speed of all CPUs to
hispeed_freq for at least the period of time specified by
boostpulse_duration, after which speeds are allowed to drop below
hispeed_freq according to load as usual.
boostpulse_duration: Length of time to hold CPU speed at hispeed_freq
on a write to boostpulse, before allowing speed to drop according to
load as usual.  Default is 80000 uS.


It works a bit differently than it was supposed to.

Idle speed is 200, highest 1.2.
If the load goes to 90, go to hispeed freq that is 400.
After that, if the load rises to 95 or more, increase frequency. Otherwise, drop lower.
Phone is fast to idle, and if it's busy, it will not jump to the highest frequency without trying lower ones first ( 400 to 1.2 )



No comments:

Post a Comment