2012年3月12日星期一

Governor 整理

因為 governor 比較抽像,我也是在網上找出來直接翻譯 ,翻譯的不好,別炮 ORZ
Governor 和耗電有直接關係,因為這個是控制CPU如何升/降頻率的.

正文如下 :

比較常用的 governor 有 : ondemand ,smartass ,lulzactive .
現在亦有將 intellidemand 取代 lulzactive 的傾向

* 觀察所得. smartass 會傾向使用 200/500/800 (我手機最低的三個) 和 1400 (我手機中最高設定) ,lulzactive 傾向使用 200 和 1400

* 另外,似乎 smartass 待機用電比起 lulzactive 更低 .. 觀察中

--------------------
因為太多用家,包括我,對android的governor都覺得摸不著頭腦,所以決定整理一下。
翻譯不好請見諒,另歡迎留言修正
--------------------
甚麼是Governor ?
Android的CPU 的頻率並不是一成不變的,會因應程式所需而調整頻率,通常會視乎CPU Loading % 而升/降頻,在特定時間再檢查是否升/降。
Governor 就是預設的情景模式喇。
--------------------
- OnDemand : 在絕大部份內核之中都包括 ,當cpu使用去到一定程度(threshold),ondemand 會立刻將cpu升頻至所需程度 .當不需要的時侯降回去

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.

--------------------
- Interactive : 在新的內核中包含 ,和 OnDemand相似 ,但反應更快 .

Available in newer kernels, and becoming the default scaling option in some official Android kernels.
The interactive governor is functionally similar to the ondemand governor with an even greater focus on responsiveness


--------------------
- conservative : 近乎 OnDemand 的運作 ,但升頻會比較慢 .比較省電 ,不過反應同時比較慢 .

Available in some kernels. 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.


--------------------
- performance : 將CPU長期維持在最高頻率 .不過比起將 CPU恆定最高頻率更快 .因為CPU本身不需要資源去調整頻率

Available in most kernels. It will keep the CPU running at the “max” set value at all times.
This is a bit more efficient than simply setting “max” and “min” to the same value and using ondemand because the system will not waste resources scanning for CPU load.


--------------------
- powersave : 將CPU長期維持在最低頻率

Available in some kernels. It will keep the CPU running at the “min” set value at all times.

--------------------
- lazy : 與 ondemand 相似 ,但cpu頻率變動速度減低 .依編者所說,播放影音時效果完美

Thus I took the ondemand governor and implemented an additional parameter 'min_timeinstate' defining a minimum time the CPU will stay in a certain frequency state before it will be allowed to switch frequencies again. This way one can have a fine grained polling by setting the sampling_rate to a low value without running into problems with these fast frequency changes.
--------------------
- lulzactive :
假設預設時脈 : (L0)1200 - (L1)1000 - (L2)800 - (L3)500 - (L4)200
CPU 頻率由 (Lx) 調至 (Lx - 升頻級別)
時效 : 24000us

CPU Loading=60%, 升頻級別=1
cpu_load = 60%, 頻率 = (L2)800 >> 頻率 = (L1)1000
cpu_load = 60%, 頻率 = (L1)1000 >> 頻率 = (L0)1200

(L0)1200 - (L1)1000 - (L2)800 - (L3)500 - (L4)200
CPU Loading=50%, 升頻級別=2
cpu_load = 50%, 頻率 = (L2)800 >> 頻率 = (L0)1200
cpu_load = 50%, 頻率 = (L4)200>> 頻率 = (L2)800
-------------
時效 = 49000us
CPU Loading=60%, 降頻級別=1
cpu_load = 59%, 頻率 = (L2)800 >> 頻率 = (L3)500
cpu_load = 23%, 頻率 = (L1)1000 >> 頻率 = (L2)800

關屏會設定為最低處理器速度 .不用設定 screen off profile

--------------------
- SavagedZen :找不到相關說明,由編寫SavagedZen內核的程式員研發,基於smartass

--------------------
- lagfree : 這個。。。如果有接電源就可以使用。運作類似ondemand,但會傾向於全面提速,降速,而令cpu低於100%,簡單說,就是吃電怪。。

Lagfree governor this driver is rather similar to the 'ondemand'governor both in its source code and its purpose, the difference is its optimization for better suitability in a battery powered environment. The frequency is gracefully increased and decreased rather than jumping to 100% when speed is required.
--------------------
- intellidemand : intellidemand 會視乎 GPU 3D 使用率以觀察是否於[瀏覽模式] ,當GPU於重度使用時 ,所有動作都依照 OnDemand 不變 .
當3D GPU 於閒置時 ,即是說看書 ,看網頁的時侯 ,[瀏覽模式]將會啟動 .同時將CPU最高頻率鎖死於 1.0Ghz 以減少耗電.
關屏時亦會視乎 GPU 情況而作出調整 .所以亦不需要 Screen off Profile

The intellidemand governor looks at GPU 3D usage to determine whether or not it is in "browsing mode". When 3D GPU is highly busy, then the intellidemand will NOT do any frequency scaling adjustments (behaves exactly like the traditional Ondemand governor). When 3D GPU is idling, intellidemand will enter "browsing mode" and limit the CPU Max frequency to 1.0 GHz to save battery while reading books, web browsing, anything that do not require GPU 3D to be busy. The switch between browsing and non-browsing is instantaneous. As soon as GPU 3D goes above the threshold, the governor will instantly disable the limit and behave like the old OnDemand governor.

--------------------
- smartassV2 :smartassV2 是為了平衡效能和耗電而出現 .基於 interactive .
擁有的特點是 : 升頻快 ,降頻慢 .同時間亦會於鎖屏時將頻率降到最低 .
英文版太長 .. 有空再譯

+The CPUfreq governor "smartassV2", like other governors, aims to balance
+performance vs battery life by using low frequencies when load is low and+ramping the frequency when necessary, fast enough to ensure responsiveness.
+The implementation of the governor is roughtly based on the idea of interactive.
+The idle loop is used to track when the CPU has idle cycles. The idle loop will
+set a relatively high rate timer to sample the load when appropriate, the timer
+will measure the load since it was set and schedule a work queue task to do the
+actual frequency change when necessary.
+The most important tunable is the "ideal" frequency: this governor will aim
+for this frequency, in the sense that it will ramp towards this frequency much
+more aggresively than beyond it - both when ramping up from below this frequency
+and when ramping down from above this frequency. Still, note, that when load is
+low enough the governor should choose the lowest available frequency regardless
+of the ideal frequency and similarly when load is consistently high enough the
+highest available frequency will be used.
+Smartass also tracks the state of the screen, and when screen is off (a.k.a
+sleep or suspended in the terms of this governor) a different ideal frequency
+is used. This is the only difference between the screen on and screen off
+states. Proper tuning of the awake_ideal_freq and sleep_ideal_freq should
+allow both high responsiveness when screen is on and utilizing the low
+frequency range when load is low, especially when screen is off.

--------------------
- InteractiveX : 如同Interactive,但已預先設定,關屏時鎖定頻率為最低值,是以不需要設定screen off profile

--------------------
- OndemandX : 如同Ondemand,但已預先設定,關屏時鎖定頻率為500Mhz(?),是以不需要設定screen off profile

--------------------
- userspace : 一個和setcpu使用頻率並不相同的設定,為得到更好效果,並不建議使用

A method for controlling the CPU speed that isn't currently used by SetCPU. For best results, do not use the userspace governor.

--------------------
補充 : 由網友 reach1942 提供

Advanced Tab 進階選項
只有 ondemand & conservative 有作用

Sampling Rate:
裡面的數值是 setcpu 對 cpu loading(負載狀況)做偵測的區間時間,單位是微秒(百萬分之一)。

Up Threshold:
裡面的數值是百分比,當 cpu loading 高到這個百分比的時候,setcpu 會調高 cpu 運算速度。

Download Threshold:
一樣是百分比,當 cpu loading 低到這個數值的時候,setcpu 會調慢 cpu 速度。(只作用在 conservative 模式)

Ignore Nice Load:
如果設定為 1,setcpu 會忽視這些設定為 Nice 的程序,也就是不會以這些程序的 loading 為調整考量。

(不過我沒看到哪邊可以設定程序)

Posersave Bias:
裡面的數值,1000=100%,100=10%,0=0%,setcpu 會針對原先設定的速度範圍做整體調降,例如原本設定為 245-1130,Powersave Bias 值設為 900,則設定速度會調整為 220-1017。(只作用在 ondemand 模式)

6. Freq Step: Freq Step 可設定頻率階層。例如 Freq Step 設為 5 的話,cpu 速度範圍 245-1130 就會被等分為 5 等分,就是 245-422-599-776-953-1130,當 cpu loading 達到 up or down threshold 的時候,cpu 速度就會在上述單位間來回跳動。(只作用在 conservative模式)

來源:http://goo.gl/i7AGi

--------------------
再加兩份參考連結 ..

http://forum.xda-developers.com/showthread.php?t=1242323
http://forum.xda-developers.com/showpost.php?p=19339524&postcount=10023

再加一份參考
http://forum.xda-developers.com/showpost.php?p=20158514&postcount=308