FORUMS

Analysis & Opinion

Top Forum Discussions

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

715 posts
Thanks Meter: 1,722
 
By Ezekeel, Retired Recognized Developer on 21st September 2011, 08:43 PM
Thread Closed Subscribe to Thread Email Thread
*** 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! ***
Last edited by Ezekeel; 23rd September 2011 at 11:19 PM.
The Following 15 Users Say Thank You to Ezekeel For This Useful Post: [ View ]
 
 
21st September 2011, 08:49 PM |#2  
simms22's Avatar
Recognized Contributor
BROOKLYN!
Thanks Meter: 25,333
 
More
nice!
cant wait to try this out
21st September 2011, 09:04 PM |#3  
Senior Member
Flag Dnepropetrovsk
Thanks Meter: 87
 
More
the idea sounds good, i'd like to test it!

have you checked smartass, btw?
21st September 2011, 09:10 PM |#4  
superfloup's Avatar
Senior Member
Flag Ivry-la-Bataille
Thanks Meter: 20
 
Donate to Me
More
Really nice, I hope morfic will implement it in his kernels.

Sent from my Nexus S using XDA App
21st September 2011, 09:15 PM |#5  
Senior Member
Thanks Meter: 7
 
More
Sweet I will be watching this.
21st September 2011, 09:19 PM |#6  
Senior Member
Flag Buffalo, NY
Thanks Meter: 37
 
More
Sounds cool. Can't wait to be able to try this

Sent from my Nexus S 4G using XDA App
21st September 2011, 09:22 PM |#7  
zadnica's Avatar
Senior Member
Flag Marseille
Thanks Meter: 64
 
More
Cool! Nice idea.
21st September 2011, 09:58 PM |#8  
Igotsanevo4g's Avatar
Senior Member
Flag San Diego
Thanks Meter: 60
 
More
Woah sweet.

Maybe this will get people off that "smartass" governor kick everyones been on.
21st September 2011, 10:33 PM |#9  
kenvan19's Avatar
Senior Member
Thanks Meter: 549
 
Donate to Me
More
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
21st September 2011, 10:50 PM |#10  
Ezekeel's Avatar
OP Retired Recognized Developer
Thanks Meter: 1,722
 
More
Quote:
Originally Posted by igor.tonky

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

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
Last edited by Ezekeel; 21st September 2011 at 10:54 PM.
The Following User Says Thank You to Ezekeel For This Useful Post: [ View ]
21st September 2011, 11:19 PM |#11  
651stp's Avatar
Senior Member
Flag Minneapolis
Thanks Meter: 45
 
More
thanks for all your contributions thus far for the NS. looking foward to more of your work!

Read More
Thread Closed Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes