Jump to content


Governors And Schedulers - Explained


  • Please log in to reply
16 replies to this topic

#1 Guest_BDH_*

Guest_BDH_*
  • Guests

Posted 15 July 2012 - 02:19 AM

Wanted to make a little post so that people can be more informed when choosing their governors and schedulers so everyone can make their own combo that best suits their needs. If you find information on a Governor or Scheduler that is NOT posted, please let me know. Some of this information is a straight copy/paste from an old thread I posted for the LG Revolution over at XDA. Some is posted from other sources.


First, let's start with "governors."

OnDemand:
The default governor in almost all stock kernels. One main goal of the ondemand governor is to switch to max frequency as soon as CPU activity is detected to ensure the responsiveness of the system. Effectively, it uses the CPU busy time as the answer to the "how critical is performance right now" question. So Ondemand jumps to maximum frequency when CPU is busy and decreases the frequency gradually when CPU is less loaded/apporaching idle. Even though many of us consider this a reliable governor, it falls short on battery saving and performance on default settings. One potential reason for ondemand governor being not very power efficient is that the governor decides the next target frequency by instant requirement during sampling interval. The instant requirement can respond quickly to workload change, but it does not usually reflect workload real CPU usage requirement in a longer time and it possibly causes frequent changes between highest and lowest frequency.


Smartass2:
Version 2 of the original smartass governor from Erasmux. Another favorite for many people. The governor aims for an "ideal frequency", and ramps up more aggressively towards this freq and less aggressive after. It uses different ideal frequencies for screen on and screen off, namely awake_ideal_freq and sleep_ideal_freq. This governor scales down CPU very fast (to hit sleep_ideal_freq soon) while screen is off and scales up rapidly to awake_ideal_freq when screen is on. There's no upper limit for frequency while screen is off (unlike Smartass). So the entire frequency range is available for the governor to use during screen-on and screen-off state. The motto of this governor is a balance between performance and battery.


Performance:
Sets min frequency as max frequency. Very useful while benchmarking!


Interactive Governor:
Much like the OnDemand governor, the Interactive governor dynamically scales CPU clockspeed in response to the workload placed on the CPU by the user. This is where the similarities end. Interactive is significantly more responsive than OnDemand, because it's faster at scaling to maximum frequency.

Unlike OnDemand, which you'll recall scales clockspeed in the context of a work queue, Interactive scales the clockspeed over the course of a timer set arbitrarily by the kernel developer. In other words, if an application demands a ramp to maximum clockspeed (by placing 100% load on the CPU), a user can execute another task before the governor starts reducing CPU frequency. This can eliminate the frequency bouncing discussed in the OnDemand section. Because of this timer, Interactive is also better prepared to utilize intermediate clockspeeds that fall between the minimum and maximum CPU frequencies. This is another pro-battery life benefit of Interactive.

However, because Interactive is permitted to spend more time at maximum frequency than OnDemand (for device performance reasons), the battery-saving benefits discussed above are effectively negated. Long story short, Interactive offers better performance than OnDemand (some say the best performance of any governor) and negligibly different battery life.

Interactive also makes the assumption that a user turning the screen on will shortly be followed by the user interacting with some application on their device. Because of this, screen on triggers a ramp to maximum clockspeed, followed by the timer behavior described above.


InteractiveX Governor:
Created by kernel developer "Imoseyon," the InteractiveX governor is based heavily on the Interactive governor, enhanced with tuned timer parameters to better balance battery vs. performance. The InteractiveX governor's defining feature, however, is that it locks the CPU frequency to the user's lowest defined speed when the screen is off.


Hotplug Governor:
The Hotplug governor performs very similarly to the OnDemand governor, with the added benefit of being more precise about how it steps down through the kernel's frequency table as the governor measures the user's CPU load. However, the Hotplug governor's defining feature is its ability to turn unused CPU cores off during periods of low CPU utilization. This is known as "hotplugging."

Obviously, this governor is only available on multi-core devices.


OndemandX:
Basically an ondemand with suspend/wake profiles. This governor is supposed to be a battery friendly ondemand. When screen is off, max frequency is capped at 500 mhz. Even though ondemand is the default governor in many kernel and is considered safe/stable, the support for ondemand/ondemandX depends on CPU capability to do fast frequency switching which are very low latency frequency transitions. I have read somewhere that the performance of ondemand/ondemandx were significantly varying for different i/o schedulers. This is not true for most of the other governors. I personally feel ondemand/ondemandx goes best with SIO I/O scheduler.


Now for the "schedulers."

Noop:
Inserts all the incoming I/O requests to a "First In First Out" queue and implements request merging. Best used with storage devices that does not depend on mechanical movement to access data (yes, like a flash drive). Advantage here is that flash drives do not require reordering of multiple I/O requests unlike in normal hard drives.

*Advantages*


1. Serves I/O requests with least number of cpu cycles. (Battery friendly?)
2. Best for flash drives since there is no seeking penalty.
3. Good throughput on db systems.

*Disadvantages*

1. Reduction in number of cpu cycles used is proportionate to drop in performance.


Deadline:
Goal is to minimize I/O latency or starvation of a request. The same is achieved by round robin policy to be fair among multiple I/O requests. Five queues are aggressively used to reorder incoming requests.

*Advantages*

1. Nearly a real time scheduler.
2. Excels in reducing latency of any given single I/O.
3. Best scheduler for database access and queries.
4. Bandwidth requirement of a process - what percentage of CPU it needs, is easily calculated.
5. Like noop, a good scheduler for solid state/flash drives.

*Disadvantages*

1. When the system is overloaded, the set of processes that may miss deadline is largely unpredictable.


CFQ:
Completely Fair Queuing scheduler maintains a scalable per-process I/O queue and attempts to distribute the available I/O bandwidth equally among all I/O requests. Each per-process queue contains synchronous requests from processes. Time slice allocated for each queue depends on the priority of the 'parent' process.

*Advantages*

1. Considered to deliver a better balanced i/o performance.
2. Easiest to tune.
3. Excels on multiprocessor systems.
4. Best database system performance after deadline.

*Disadvantages*

1. Some users report that media scanning takes longer to complete using CFQ. This could be because of the property that since the bandwidth is equally distributed to all i/o operations during boot-up, media scanning is not given any special priority.
2. Jitter (worst-case-delay) exhibited can sometimes be high, because of the number of tasks competing for the disk.


SIO:
Simple I/O scheduler aims to keep minimum overhead to achieve low latency to serve I/O requests. No priority quesues concepts, but only basic merging. SIO is a mix between noop & deadline. No reordering or sorting of requests.

*Advantages*

1. Simple, very very reliable.
2. Minimized starvation of requests.

*Disadvantages*

1. Slow random-read speeds on flash drives, compared to other schedulers.
2. Sequential-read speeds on flash drives also not so good.
  • PillClinton, DeeMat, andlaw and 12 others like this

#2 Guest_BDH_*

Guest_BDH_*
  • Guests

Posted 15 July 2012 - 02:20 AM

Reserved for more Governors and Schedulers.

Edited by spc_hicks09, 15 July 2012 - 02:20 AM.


#3 andlaw

andlaw

    BW ftw!! !!!!!

  • Developer
  • 2,463 posts
  • LocationOH-I-O
  • Current Device(s):Nexus 6

Posted 15 July 2012 - 02:22 AM

great writeup, !!
nows all we need are links to the governors that arent available through rom toolbox B)

"A truly blacked out experience"

Posted Image

[XT912 |[(BLACKWIDOWICS 214)] | [(BLACKWIDOWICS AOKP/CM9)] | [(BLACKWIDOWJB AOKP/CM10/CNA)] | [(wWIDOWICS 214)] | |[(BLACKWIDOWHDish)]| XT912]

[XT926 |[(BLACKWIDOWHD|wWIDOWHD)]| XT926]


#4 Guest_BDH_*

Guest_BDH_*
  • Guests

Posted 15 July 2012 - 02:27 AM

great writeup, !!
nows all we need are links to the governors that arent available through rom toolbox B)


Yeah that's why I only posted info for the ones we can currently run. Along with the help of whirleyes over at XDA.

#5 garywojdan81

garywojdan81

    Droid Master

  • Members
  • PipPipPip
  • 633 posts
  • Twitter:gwojdan_81

Posted 15 July 2012 - 04:36 AM

Hey Hicks, thanks for this write up. Very informative & easy to understand.

Sent from my XT912 using Tapatalk 2

#6 PillClinton

PillClinton

    #FireGaryBettman

  • Members
  • PipPipPip
  • 441 posts
  • Twitter:530SharksFan
  • LocationNorCal

Posted 15 July 2012 - 01:06 PM

Great write up, thank you.

#7 Hero_Indeed

Hero_Indeed

    Android Rescue Squad

  • Members
  • PipPip
  • 173 posts
  • LocationMinnesota

Posted 15 July 2012 - 01:50 PM

Thank you Hicks! I learned a few things I didn't know, profit.

Sent from my DROID RAZR using Xparent ICS Blue Tapatalk 2
Posted Image

#8 AStoke002

AStoke002

    n00b

  • Members
  • Pip
  • 10 posts

Posted 16 July 2012 - 08:03 AM

Nice ...learn something new eveyday :)

#9 DCarrollUSMC

DCarrollUSMC

    Grunt

  • Members
  • PipPip
  • 85 posts
  • LocationBloomington, Illinois

Posted 20 July 2012 - 04:32 AM

Great write up, this question gets asked a lot. Thanks Hicks!
Posted Image

#10 neur0tk

neur0tk

    Member

  • Members
  • PipPip
  • 123 posts
  • Twitter:neur0tk
  • Google+:neur0tk1@gmail.com
  • LocationLatrobe, Pennsylvania

Posted 20 July 2012 - 05:00 AM

Very informative thanks for this write up

Sent from my DROID RAZR using Tapatalk 2

#11 thrasher194

thrasher194

    http://androidn00b.com/

  • Members
  • PipPip
  • 226 posts
  • Google+:Thrasher194@gmail.com
  • LocationNorthCarolina, USA
  • Current Device(s):Motorola G4 Play (xt1609)

Posted 20 July 2012 - 02:31 PM

Very well put. I was wondering about the diff cpu speeds and memery useage.

#12 TauntingBull

TauntingBull

    Member

  • Members
  • PipPip
  • 25 posts

Posted 21 July 2012 - 01:24 AM

Very nice read... thanks bud!

#13 Scipio

Scipio

    Member

  • Members
  • PipPip
  • 133 posts
  • LocationNew York

Posted 08 August 2012 - 11:32 AM

Wow this helped out a lot, thank you. In terms of the schedulers though, what does I/O mean? I was thinking in/out which kinda works but would enjoy a little better understanding of it all. And I'm sorry if it's somewhere else on the site but I must have not seen it.

eb7gn6.png

 


#14 Collin James

Collin James

    Member

  • Members
  • PipPip
  • 59 posts

Posted 27 August 2012 - 10:47 PM

So does everyone use SetCPU to control their governors or is there something better out there?

removed


#15 tucstwo

tucstwo

    www.drdevs.com

  • Administrator
  • 14,435 posts
  • Twitter:tucstwo
  • Google+:tucstwo@gmail.com
  • LocationNJ
  • Current Device(s):LG G3 VS985, Nexus 7 (flo)

Posted 12 September 2012 - 06:07 AM

So does everyone use SetCPU to control their governors or is there something better out there?


It depends on your ROM, CyanogenMod has a section under Settings for "Performance" that allows you to set the schedulers and governors.

Visit DRDevs.com hosting site for all official Droidrzr.com ROMs, Apps, GApps and other mods/files!!
Please PM me if you need help!
I will be hosting AOSP-Based ROM GApps packages!
Download the most Up-to-Date GApps Packages for AOSP ROMs from me here!


#16 Maxxaholic

Maxxaholic

    Droid Master

  • Members
  • PipPipPip
  • 628 posts
  • LocationWashington, USA

Posted 12 September 2012 - 06:35 AM

So does everyone use SetCPU to control their governors or is there something better out there?


No frills is a good free one but its very basic. U can still set governor and I/0 and min-max but no profiles

Sent from my XT912 using Xparent SkyBlue Tapatalk 2

#17 DroRzr

DroRzr

    Member

  • Dedicated Supporter
  • PipPip
  • 97 posts
  • Current Device(s):XT912, Nexus7

Posted 24 May 2013 - 04:19 PM

It depends on your ROM, CyanogenMod has a section under Settings for "Performance" that allows you to set the schedulers and governors.

Wow!  Great write up and hope ti will stop my battery drain if I know proper settings:-)

 

Seems like a good place to ask this:    XT912 using CM10.1, and read that default GOVERNOR should be set to Hotplug instead of Interactive??   I am not a gamer, just  use device for calls, browsing, email, chat, txt etc.  So, is Hotplug the best way to go? 

Also default on current Rom for CPU FReq is set to 300?  is that OK??

M\max CPU Freq is defaulted to 600MNz? Should it be changed to__?

These are specs:

Support frequency band: 2 G: GSM 850/900/1800/1900

2 G: CDMA 800/1900

3 G: WCDMA / 850/1900

3 G: CDMA EVDO 800/1900 MHz

Operating system: Android OS 2.3

Core count: dual-core

CPU type: OMAP4430 Texas instruments

CPU frequency: 1228 MHz

 

Thanks!!!!!   You guys know a heck of a lot more than I do, and I hope u can help.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users