More Android 5.0 Details Revealed, Microsoft Band Fitness Tracker – XDA TV

Google talks more about Android 5.0 Lollipop! That and much … more

Google Allows Search Queries To Interact With Apps

Android 5.0 Lollipop brings lots of new features that are quite useful for end users and … more

Lenovo Officially Owns Motorola, Following ~$3 Billion Deal

Google is now officially no longer the owner of American phone manufacturer … more

Microsoft Band Fitness Tracker Announced, Available

The wearable market has been around for a few years, with Pebble and Samsung smartwatches … more
Thread Closed

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

OP Ezekeel

21st September 2011, 08:43 PM   |  #1  
Ezekeel's Avatar
OP Retired Recognized Developer
Thanks Meter: 1,715
 
715 posts
Join Date:Joined: Jun 2011
*** 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: 21,943
 
26,350 posts
Join Date:Joined: Jun 2009
nice!
cant wait to try this out
21st September 2011, 09:04 PM   |  #3  
Senior Member
Flag Dnepropetrovsk
Thanks Meter: 87
 
188 posts
Join Date:Joined: Nov 2009
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: 19
 
166 posts
Join Date:Joined: Oct 2008
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
 
276 posts
Join Date:Joined: Dec 2009
Sweet I will be watching this.
21st September 2011, 09:19 PM   |  #6  
Senior Member
Flag Buffalo, NY
Thanks Meter: 37
 
368 posts
Join Date:Joined: Nov 2010
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
 
383 posts
Join Date:Joined: May 2010
More
Cool! Nice idea.
21st September 2011, 09:58 PM   |  #8  
Igotsanevo4g's Avatar
Senior Member
Flag San Diego
Thanks Meter: 60
 
648 posts
Join Date:Joined: Aug 2010
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
Flag Phoenix
Thanks Meter: 543
 
3,546 posts
Join Date:Joined: Dec 2010
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,715
 
715 posts
Join Date:Joined: Jun 2011
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 ]
Thread Closed Subscribe to Thread
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Top Threads in Nexus S Android Development by ThreadRank