Welcome to XDA

Search to go directly to your device's forum

Register an account

Unlock full posting privileges

Ask a question

No registration required
Post Reply

[GUIDE]Kernel Governors and I/O SCHEDULERS

OP Knight47

2nd May 2012, 08:56 PM   |  #1  
Knight47's Avatar
OP Senior Member
Thanks Meter: 4,438
 
677 posts
Join Date:Joined: Mar 2012
More
Original post by droidphile about Kernel Governors, Modules, I/O Schedulers, CPU Tweaks, AIO App Configs under Galaxy S II General.I altered & wrote in a way Newbies can read His post
Thanks To................
Sirkay,hansip87,jjdoctor for their work in Xperia ray which inspired me to write(Modified and altered from the original thread )

NEW-Check my 3rd post for QUESTIONS AND ANSWERS(21-08-12)-Click here

1. Kernel Governors


These are the 19 governors we're talking about.

1) Ondemand
2) Conservative
3) Interactivex
4) Smartass
5) SmartassV2
6) Lagfree
7) Brazilianwax
8) SavagedZen
9) Userspacce
10) Powersave
11) Performance
12)Minmax
13)Scary
14)Lulzactive
15)intellidemand
16)badass
17)Lionheart
18)Lionheartx
19)Virtuous


1) Ondemand:
Available in most kernels, and the default governor in most kernels. When the CPU load reaches a certain point (see "up threshold" in Advanced Settings), ondemand will rapidly scale the CPU up to meet demand, then gradually scale the CPU down when it isn't needed

2) Conservative:
A slower Ondemand which scales up slowly to save battery. It is similar to the ondemand governor, but will scale the CPU up more gradually to better fit demand. Conservative provides a less responsive experience than ondemand, but can save battery.


3) Interactivex:

This is an Interactive governor with a wake profile. More battery friendly than interactive.


4) Smartass:
based on the concept of the interactive governor. I have always agreed that in theory the way interactive works - by taking over the idle loop - is very attractive.Smartass is a complete rewrite of the code plus more. I think its a success. Performance is on par with the "old" minmax and I think smartass is a bit more responsive. Battery life is hard to quantify precisely but it does spend much more time at the lower frequencies


5) SmartassV2:

SmartassV2 is a governor (controls the frequency of the CPU at each give moment) which like the first smartass is generally based on the implementation of interactive with some major changes and the addition of a built in sleep profile (behaves a bit differently when screen is off vs. on).The smartassV2 improves the very naive scheme which the first smartass had


6) Lagfree:
Lagfree is similar to ondemand. Main difference is it's optimization to become more battery friendly. Frequency is gracefully decreased and increased, unlike ondemand which jumps to 100% too often. Lagfree does not skip any frequency step while scaling up or down. Remember that if there's a requirement for sudden burst of power, lagfree can not satisfy that since it has to raise cpu through each higher frequency step from current. Some users report that video playback using lagfree stutters a little.


7) Brazilianwax:
Similar to smartassV2. More aggressive ramping, so more performance, less battery.

8) SavagedZen:
Another smartassV2 based governor. Achieves good balance between performance & battery as compared to brazilianwax.

9) Userspace:
Instead of automatically determining frequencies, lets user set frequencies.

10) Powersave:
runs minimum speed all the time (good for low battery/high temp situations)

11) Performance:

Top speed all the time(better for benchmarking/speed test)

12)Minmax
stays at minimum speed until more speed is needed then goes straight to highest speed

13)Scary
based on conservative with some smartass features, it scales accordingly to conservatives laws. So it will start from the bottom, take a load sample, if it's above the upthreshold, ramp up only one speed at a time, and ramp down one at a time. It will automatically cap the off screen speeds to 245Mhz, and if your min freq is higher than 245mhz, it will reset the min to 120mhz while screen is off and restore it upon screen awakening, and still scale accordingly to conservatives laws. So it spends most of its time at lower frequencies. The goal of this is to get the best battery life with decent performance. It will give the same performance as conservative right now, it will get tweaked over time.


14) Lulzactive

This new find from Tegrak is based on Interactive & Smartass governors and is one of the favorites. Old Version: When workload is greater than or equal to 60%, the governor scales up CPU to next higher step. When workload is less than 60%, governor scales down CPU to next lower step. When screen is off, frequency is locked to global scaling minimum frequency. New Version: Three more user configurable parameters: inc_cpu_load, pump_up_step, pump_down_step. Unlike older version, this one gives more control for the user. We can set the threshold at which governor decides to scale up/down. We can also set number of frequency steps to be skipped while polling up and down. When workload greater than or equal to inc_cpu_load, governor scales CPU pump_up_step steps up. When workload is less than inc_cpu_load, governor scales CPU down pump_down_step steps down. Example: Consider inc_cpu_load=70 pump_up_step=2 pump_down_step=1 If current frequency=200, Every up_sampling_time Us if cpu load >= 70%, cpu is scaled up 2 steps - to 800. If current frequency =1200, Every down_sampling_time Us if cpu load < 70%, cpu is scaled down 1 step - to 1000.


15) Intellidemand

Intellidemand aka Intelligent Ondemand from Faux is yet another governor that's based on ondemand. Unlike what some users believe, this governor is not the replacement for OC Daemon (Having different governors for sleep and awake). The original intellidemand behaves differently according to GPU usage. When GPU is really busy (gaming, maps, benchmarking, etc) intellidemand behaves like ondemand. When GPU is 'idling' (or moderately busy), intellidemand limits max frequency to a step depending on frequencies available in your device/kernel for saving battery. This is called browsing mode. We can see some 'traces' of interactive governor here. Frequency scale-up decision is made based on idling time of CPU. Lower idling time (<20%) causes CPU to scale-up from current frequency. Frequency scale-down happens at steps=5% of max frequency. (This parameter is tunable only in conservative, among the popular governors ) To sum up, this is an intelligent ondemand that enters browsing mode to limit max frequency when GPU is idling, and (exits browsing mode) behaves like ondemand when GPU is busy; to deliver performance for gaming and such. Intellidemand does not jump to highest frequency when screen is off.

16)badass

Badass removes all of this "fast peaking" to the max frequency. On a typical system the cpu won't go above 918Mhz and therefore stay cool and will use less power. To trigger a frequency increase, the system must run a bit @ 918Mhz with high load, then the frequency is bumped to 1188Mhz. If that is still not enough the governor gives you full throttle. (this transition should not take longer than 2-5 seconds, depending on the load your system is experiencing) Badass will also take the gpu load into consideration. If the gpu is moderately busy it will bypass the above check and clock the cpu with 1188Mhz. If the gpu is crushed under load, badass will lift the restrictions to the cpu.

17)Lionheart

Lionheart is a conservative-based governor which is based on samsung's update3 source. Tweaks comes from 1) Knzo 2) Morfic. The original idea comes from Netarchy. See here. The tunables (such as the thresholds and sampling rate) were changed so the governor behaves more like the performance one, at the cost of battery as the scaling is very aggressive.

To 'experience' Lionheart using conservative, try these tweaks: sampling_rate:10000 or 20000 or 50000, whichever you feel is safer. (transition latency of the CPU is something below 10ms/10,000uS hence using 10,000 might not be safe). up_threshold:60 down_threshold:30 freq_step:5 Lionheart goes well with deadline i/o scheduler. When it comes to smoothness (not considering battery drain), a tuned conservative delivers more as compared to a tuned ondemand.

18)Lionheartx

LionheartX is based on Lionheart but has a few changes on the tunables and features a suspend profile based on Smartass governor.

19)virtuous governor

It set your max cpu for wake and sleep and changes the governor when your device is awake or asleep. It saves battery by lowering cpu frequencys while the device sleeps, when it awakes it automatically speeds it up again. Or alternately you can set the cpu.It is based on smartassV2(It use 2 governors.one for sleep and other for awake)

Governor which is for performance and battery life-smartassV2(To get maximum performance, use ondemand or conservative)

2. I/O SCHEDULERS

Q. "What purposes does an i/o scheduler serve?" A.
  • Minimize hard disk seek latency.
  • Prioritize I/O requests from processes.
  • Allocate disk bandwidth for running processes.
  • Guarantee that certain requests will be served before a deadline.

So in the simplest of simplest form: Kernel controls the disk access using I/O Scheduler.

Q. "What goals every I/O scheduler tries to balance?" A.
  • Fairness (let every process have its share of the access to disk)
  • Performance (try to serve requests close to current disk head position first, because seeking there is fastest)
  • Real-time (guarantee that a request is serviced in a given time)

Q. "Description, advantages, disadvantages of each I/O Scheduler?" A.

1) 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 our flash drives). Advantage here is that flash drives does not require reordering of multiple I/O requests unlike in normal hard drives.

Advantages:
  • Serves I/O requests with least number of cpu cycles. (Battery friendly?)
  • Best for flash drives since there is no seeking penalty.
  • Good throughput on db systems.
Disadvantages:
  • Reduction in number of cpu cycles used is proportional to drop in performance.

2) 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:
  • Nearly a real time scheduler.
  • Excels in reducing latency of any given single I/O.
  • Best scheduler for database access and queries.
  • Bandwidth requirement of a process - what percentage of CPU it needs, is easily calculated.
  • Like noop, a good scheduler for solid state/flash drives.
Disadvantages:
  • When system is overloaded, set of processes that may miss deadline is largely unpredictable.

3) 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. V2 of CFQ has some fixes which solves process' i/o starvation and some small backward seeks in the hope of improving responsiveness.

Advantages:
  • Considered to deliver a balanced i/o performance.
  • Easiest to tune.
  • Excels on multiprocessor systems.
  • Best database system performance after deadline.
Disadvantages:
  • Some users report media scanning takes longest 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.
  • Jitter (worst-case-delay) exhibited can sometimes be high, because of the number of tasks competing for the disk.

4) BFQ

Instead of time slices allocation by CFQ, BFQ assigns budgets. Disk is granted to an active process until it's budget (number of sectors) expires. BFQ assigns high budgets to non-read tasks. Budget assigned to a process varies over time as a function of it's behavior.

Advantages:
  • Believed to be very good for usb data transfer rate.
  • Believed to be the best scheduler for HD video recording and video streaming. (because of less jitter as compared to CFQ and others)
  • Considered an accurate i/o scheduler.
  • Achieves about 30% more throughput than CFQ on most workloads.
Disadvantages:
  • Not the best scheduler for benchmarking.
  • Higher budget assigned to a process can affect interactivity and increased latency.

5) 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:
  • Simple, so reliable.
  • Minimized starvation of requests.
Disadvantages:
  • Slow random-read speeds on flash drives, compared to other schedulers.
  • Sequential-read speeds on flash drives also not so good.

6) V(R)

Unlike other schedulers, synchronous and asynchronous requests are not treated separately, instead a deadline is imposed for fairness. The next request to be served is based on it's distance from last request.

Advantages:
  • May be best for benchmarking because at the peak of it's 'form' VR performs best.
Disadvantages:
  • Performance fluctuation results in below-average performance at times.
  • Least reliable/most unstable.

Q. "Best I/O Scheduler?"
A.There is nothing called "best" i/o scheduler. Depending on your usage environment and tasks/apps been run, use different schedulers. That's the best i can suggest.
However, considering the overall performance, battery, reliability and low latency, it is believed that
SIO > Noop > Deadline > VR > BFQ > CFQ, given all schedulers are tweaked and the storage used is a flash device.
Last edited by Knight47; 28th October 2012 at 11:13 PM. Reason: corrected some errors
The Following 262 Users Say Thank You to Knight47 For This Useful Post: [ View ]
3rd May 2012, 11:38 AM   |  #2  
droidphile's Avatar
Recognized Contributor
Flag Bangalore
Thanks Meter: 6,968
 
1,065 posts
Join Date:Joined: Jul 2011
I didn't know my 'essay' could be shortened nicely this way and still convey the real idea
The Following 19 Users Say Thank You to droidphile For This Useful Post: [ View ]
3rd May 2012, 02:15 PM   |  #3  
Knight47's Avatar
OP Senior Member
Thanks Meter: 4,438
 
677 posts
Join Date:Joined: Mar 2012
More
Question Questions
Question Time

Q.which governor is for performance and which one is for battery life?
A. Tough question! lulzactive and smartassV2 for a balance between performance and battery. For light weight tasks, lulzactive should be better for battery. And for heavy weight tasks, lulzactive should be better for performance also. To get maximum performance, use a tweaked ondemand or conservative, but never complain about battery. NOTE: It's not so easy to tame luzactive. If you don't know how exactly to do it, stay away from it or you will end up complaining about battery drain!

Q. "Hey, almost forgot. How do i change governors?"
A.use Voltage Control/SetCpu/No Frills/Antuntu CPU Master, etc. Nofrills has the interfaces for gpu oc/uc/uv and charge-current change if your kernel supports them. Like we guessed, these apps will tell us the active governor too.

Q. "How do i know which governor is best for me?"

A. It depends on what you need and your daily usage pattern. Performance or battery. Better choose a governor that's balanced for battery/performance. Or tweak a governor to give performance an upper-hand as compared to battery. We can always re-charge the phone:

Q. "Well i have set my favorite governor as screen-on governor and another one as screen-off governor. Why the hell is the phone not waking up after deep sleep. I need to force-restart the phone by pressing power button for about 10 secs. Is it a sleep-of-death?"

A. Yes it is. Do not use two governors as screen-on & screen-off govs, if they both have an upper frequency limit for screen-off state.
Didn't get it?
Examples for right combinations(screen-on:screen-off):-
ondemand:smartassV2, lulzactive:smartassV2

Q. "How to make my device more snappier. I don't care much about batt....err...I do care about battery life, but only in terms of avoiding unwanted power consumption. Device should instantly dance to my tunes."

A. Scale 500 to 1200 during screen-on and 200-500 during screen-off. Use performance tweaked conservative/ondemand(x). Response will be sweet. And don't worry, minimum of 500 during screen-on will not drain too much battery like you think!

Q.Which Rom is more battery friendly?

A.hmmm.....well.JJ's Hybrid.which is smooth in 800mhz

Q.What kernel will you recommend me to use?
A.Sirkays 7.3.431 kernel.Link for that thread

Q.What is the stable value for OC in Xperia Ray?
A. 1400mhz(1,4Ghz) because you'll experience some wild reboots in 1600Mhz(1.6Ghz)

Q.Is it possible to have Dual boot in Ray?
A. No

Q.What exactly is smooth scaling?

A. Ondemand governor jumps straight to max frequency a little too often. We can control this by setting a smooth scaling frequency to which the CPU will scale to first before scaling to maximum frequency. A little power saving is the target here. Note that CPU driver does smooth scaling - not governor. When CPU driver is requested by governor to scale up to max frequency, it first scales to smooth frequency, and only in the next sampling to highest frequency. Smooth scaling atm is active for ondemand

Q.What is OTG?

A. On-The-Go,is a specification that allows Xperia Ray to act as a host allowing a USB flash drive to be attached and also connecting USB peripherals directly for communication purposes among them.

Q.Q.What is BFS?

A.Brain F**k Scheduler (BFS) is a task scheduler .The objective of BFS, compared to other schedulers, was to provide a scheduler with a simpler algorithm, that did not require adjustment of heuristics or tuning parameters to tailor performance to a specific type of computation workload. The BFS author asserted that these tunable parameters were difficult for the average user to understand, especially in terms of interactions of multiple parameters with each other, and claimed that the use of such tuning parameters could often result in improved performance in a specific targeted type of computation, at the cost of worse performance in the general case. BFS has been reported to improve responsiveness.It's better for Multi Tasking

Q.What is task sheduler?

A.scheduling is the method by which threads, processes or data flows are given access to system resources (e.g. processor time, communications bandwidth). This is usually done to load balance a system effectively or achieve a target quality of service. The need for a scheduling algorithm arises from the requirement for most modern systems to perform multitasking (execute more than one process at a time) and multiplexing (transmit multiple flows simultaneously).For more info

Q.What is ZRAM?[/B]
A.It increases performance by avoiding paging on disk and instead uses a compressed block device in RAM in which paging takes place until it is necessary to use the swap space on the hard disk drive. Since using RAM is faster than using disks, zRam allows to make more use of RAM when swapping/paging is required.

Q.How to make a Zram script?
A.1. Using Root Explorer, got to /sytem/etc/init.d/
2. press Menu then create new file
3. paste these in it

Code:
#!/system/bin/sh
sysctl -w vm.swappiness=60
echo '1' > /sys/block/zram0/reset
echo $((60*1024*1024)) > /sys/block/zram0/disksize
mkswap /dev/block/zram0
swapon /dev/block/zram0
4. close and save it as 99zram
5. set permission to 777 or "rwxrwxrwx" (tick all)
6. take note: 60*1024*1024 = 60MB zram disksize. if you want to set 30MB, change 60 to 30.
Source-Sirkays thread

Q.Is there is any way to run Tegra,PowerVR android games on Ray?
A.Yea,you can use Chainfire3D(you have to install Tegra,PowerVR plugins too

Q.My device is not stable at 1.6 Ghz. But i still wanna overclock the device to possible maximum and show off to friends?
A.Try 1516Mhz

Q.I sometimes get unexpected reboots. What could be wrong?
A. Number of reasons.
- Problem from ROM side -wrong build.prop tweaks, etc.
- Too much UV on CPU
- Too much CPU OC
- CPU/Battery heated up too much because of weather/benchmarking/faulty charger, etc

Q.I want to help dev debug an issue providing a Log-cat. How to?
A. After the problem (random reboot/freeze/lockup), do not pull out battery to recover. Just long press power button so that device can reboot. Then connect device to PC,
Then do the following steps from this guids

Q.How to flash kernel in Xperia ray other than "fastboot flash boot <file name>.img"?
A.Use Flash-tool or this QuickIMG tool
Last edited by Knight47; 20th August 2012 at 08:26 PM.
The Following 28 Users Say Thank You to Knight47 For This Useful Post: [ View ]
3rd May 2012, 06:51 PM   |  #4  
hansip87's Avatar
Senior Member
Flag Jakarta
Thanks Meter: 1,890
 
2,571 posts
Join Date:Joined: Jan 2011
Donate to Me
More
Quote:
Originally Posted by Knight47

I think you missed scary and minmax in your post.. ...Anyway your post is better than mine ...:)

Sent from my ST18i using XDA

Nice post :) well, actually I'm stuck with ondemand. Because the smartassv2 is too active in high freq imho and buggy with setXperia app. could you give me another recommendation?

sent from my white ray using XDA App
3rd May 2012, 08:33 PM   |  #5  
Ridho1's Avatar
Senior Member
Flag Suroboyo cok!
Thanks Meter: 162
 
376 posts
Join Date:Joined: Dec 2011
Donate to Me
More
Quote:
Originally Posted by hansip87

Nice post :) well, actually I'm stuck with ondemand. Because the smartassv2 is too active in high freq imho and buggy with setXperia app. could you give me another recommendation?

sent from my white ray using XDA App

Yeah bro. I have a problem with setxperia. My ray becomes so lazy when receives a call. Dont use setxperia. Use incredicontrol.

Sent from my ST18i using Tapatalk
3rd May 2012, 08:51 PM   |  #6  
Srkineo's Avatar
Senior Member
Flag Geel
Thanks Meter: 78
 
313 posts
Join Date:Joined: Sep 2010
More
Great post,very informative

Sent from my Desire using XDA Premium App
4th May 2012, 07:57 AM   |  #7  
Knight47's Avatar
OP Senior Member
Thanks Meter: 4,438
 
677 posts
Join Date:Joined: Mar 2012
More
Quote:
Originally Posted by hansip87

Nice post :) well, actually I'm stuck with ondemand. Because the smartassv2 is too active in high freq imho and buggy with setXperia app. could you give me another recommendation?

sent from my white ray using XDA App

Use InteractiveX............ Because I don't have any problem with that governor in set Xperia. .

Sent from my ST18i using XDA
The Following User Says Thank You to Knight47 For This Useful Post: [ View ]
4th May 2012, 08:04 AM   |  #8  
Knight47's Avatar
OP Senior Member
Thanks Meter: 4,438
 
677 posts
Join Date:Joined: Mar 2012
More
Quote:
Originally Posted by Srkineo

Great post,very informative

Sent from my Desire using XDA Premium App

Don't forget to hit thanks

Sent from my ST18i using XDA
The Following 4 Users Say Thank You to Knight47 For This Useful Post: [ View ]
6th May 2012, 11:34 AM   |  #9  
Senior Member
Thanks Meter: 4
 
111 posts
Join Date:Joined: Mar 2012
More
can explain about io?

Sent from my ST18i using XDA
6th May 2012, 12:48 PM   |  #10  
Knight47's Avatar
OP Senior Member
Thanks Meter: 4,438
 
677 posts
Join Date:Joined: Mar 2012
More
Quote:
Originally Posted by blaze012345

can explain about io?

Sent from my ST18i using XDA

I updated the post with io
Last edited by Knight47; 20th May 2012 at 04:41 PM. Reason: nothing

The Following 3 Users Say Thank You to Knight47 For This Useful Post: [ View ]
Post Reply Subscribe to Thread

Tags
governor, i/o, kernel, noop, shedulers
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes