Attend XDA's Second Annual Developer Conference, XDA:DevCon 2014!
5,779,990 Members 37,126 Now Online
XDA Developers Android and Mobile Development Forum

[MOD][KERNEL] Snappy - a new CPUfreq governor

Tip us?
 
Ezekeel
Old
(Last edited by Ezekeel; 23rd September 2011 at 11:19 PM.)
#1  
Ezekeel's Avatar
Retired Recognized Developer - OP
Thanks Meter 1,710
Posts: 715
Join Date: Jun 2011
Default [MOD][KERNEL] Snappy - a new CPUfreq governor

*** This project is dead! ***


The CPUfreq governor is responsible for switching between the different CPU frequencies the processor supports. It thus has a critical impact on both the battery runtime as well as the responsiveness of the device.

The two most popular governors which allow a dynamic frequency switching based on the current processor load are 'ondemand' and 'interactive' and I tested both for a few days to compare their performance in different scenarios: While ondemand appears to offer the best battery runtime, the responsiveness is not great which leads to problems during media playback (cracks and stuttering while playing FLACs with stock music app and watching XviD videos with MoboPlayer). On the other hand, with interactive the responsiveness is better, however the frequency scaling appears to be a bit erratic to me and it seems to spend more time in the high frequency states than actually necessary which leads to an increased battery drain. So it seems, both ondemand and interactive each have their own drawbacks and neither one shows a satisfying performance in all scenarios.

Thus I wrote a new governor called 'snappy' based on ondemand implementing the following two improvements: First, instead of using a static sampling rate, the sampling rate is dynamically adjusted depending on the current load; for a uniform load the sampling rate is set to a high value, while for a non-uniform load the time between two samples is decreased. Second, switching to lower frequency states is deferred, which on average allows the CPU to stay in its current state for longer and thus reduces the rate of frequency changes.

The governor can be tuned using three files in the cpufreq sysfs interface 'up_threshold' (default 95), 'down_threshold' (default 40) and 'sampling_rate_max' (default 100000). The current sampling rate is shown in 'sampling_rate_current'.


Changes to the source: http://www.pastie.org/2570142


BUGFIX:

The sampling rate is decreased in 2% steps while it is increased in 1% steps (this should make the sampling rate adjustment more dynamic). Also, the default for the maximum sampling rate is set to 50000.

Bug fix: http://www.pastie.org/2570778


I wrote this governor yesterday and so I did not have much time for testing. Thus your feedback is highly appreciated. Also, I did not play around much with the three parameters - so there is probably much room for improvement.


I do not accept donations and since I reached my 50GB limit of free space on SpiderOak, thanks to all of you kind people who got an account using my referral link, I could not ask for more.
Instead if you really want to donate your hard earned money to someone who deserves and needs it, consider donating to the Free Software Foundation at fsf.org: These guys are at the frontline when it comes to keeping Linux free and fighting these greedy bastards who think they are entitled to collect royalties and other fees from Linux users due to some silly patents - and if Linux falls, Android will be next.


*** This project is dead! ***
The Following 15 Users Say Thank You to Ezekeel For This Useful Post: [ Click to Expand ]
 
simms22
Old
#2  
simms22's Avatar
Recognized Contributor
Thanks Meter 21,154
Posts: 25,457
Join Date: Jun 2009
Location: BROOKLYN!
nice!
cant wait to try this out
Google+ Profile
Twitter Simms22
DerKernel For Trinity kernels and more!
 
igor.tonky
Old
#3  
Senior Member
Thanks Meter 87
Posts: 188
Join Date: Nov 2009
Location: Dnepropetrovsk
the idea sounds good, i'd like to test it!

have you checked smartass, btw?
 
superfloup
Old
#4  
superfloup's Avatar
Senior Member
Thanks Meter 19
Posts: 166
Join Date: Oct 2008
Location: Massy

 
DONATE TO ME
Really nice, I hope morfic will implement it in his kernels.

Sent from my Nexus S using XDA App

HTC ONE
Hboot: 1.55 S-OFF | Radio: 4A.21.3263.04 | Firmware: 3.62.401.1
Recovery: TWRP 2.6.3.0 | ROM 1: ARHD 31.0 | ROM 2: CM 10.2 20131026

NEXUS 7
Bootloader: 4.23 | Recovery: TWRP 2.6.0.0
Kernel: Stock | ROM: Stock JWR66V
 
r0adki111
Old
#5  
Senior Member
Thanks Meter 7
Posts: 276
Join Date: Dec 2009
Sweet I will be watching this.
Quote:
Originally Posted by xManMythLegend View Post
I throw there phone to the ground crunch it with my boot then demand they kiss my phone as I pinch and zoom the pic of me crapping in a urinal.
 
MarkGbe
Old
#6  
Senior Member
Thanks Meter 37
Posts: 367
Join Date: Nov 2010
Location: Buffalo, NY
Sounds cool. Can't wait to be able to try this

Sent from my Nexus S 4G using XDA App
 
zadnica
Old
#7  
zadnica's Avatar
Senior Member
Thanks Meter 64
Posts: 383
Join Date: May 2010
Location: Marseille
Cool! Nice idea.

Google Nexus 4
CyanogenMod 10.1 Nightlies
 
Igotsanevo4g
Old
#8  
Igotsanevo4g's Avatar
Senior Member
Thanks Meter 59
Posts: 648
Join Date: Aug 2010
Location: San Diego
Woah sweet.

Maybe this will get people off that "smartass" governor kick everyones been on.
Twitter - @Djcalied

Phone: Mako
Rom: Purity/Euroskank
Kernel: Franco/trinity

Evo 4G->Nexus S 4G->Galaxy S 3->Nexus 4
 
kenvan19
Old
#9  
kenvan19's Avatar
Senior Member
Thanks Meter 543
Posts: 3,546
Join Date: Dec 2010
Location: Phoenix

 
DONATE TO ME
Very nice work man. I particularly like how you make it sound like creating a CPU governor is about as much work as making a grilled cheese haha
 
Ezekeel
Old
(Last edited by Ezekeel; 21st September 2011 at 10:54 PM.)
#10  
Ezekeel's Avatar
Retired Recognized Developer - OP
Thanks Meter 1,710
Posts: 715
Join Date: Jun 2011
Quote:
Originally Posted by igor.tonky View Post
the idea sounds good, i'd like to test it!

have you checked smartass, btw?
I also checked smartass and it did behave pretty similar to interactive.


Quote:
Originally Posted by kenvan19 View Post
Very nice work man. I particularly like how you make it sound like creating a CPU governor is about as much work as making a grilled cheese haha
Actually most of the time I have no idea what I am doing. I am just a mad man with a Nexus S.


I made a few adjustments to snappy:

The sampling rate is decreased in 2% steps while it is increased in 1% steps (this should make the sampling rate adjustment more dynamic). Also, the default for the maximum sampling rate is set to 50000.

Bug fix: http://www.pastie.org/2570778

The Following User Says Thank You to Ezekeel For This Useful Post: [ Click to Expand ]
THREAD CLOSED
Subscribe
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes