Hi,
Solar wrote:Brendan wrote:In a "perfect" system...
...and ignoring things like power usage / battery life...
Power usage could be taken into account...
If you give every "unimportant" thing a rating from "worthwhile" to "waste of power", then you could progressively throttle the CPU's voltage/frequency down according to the relative unimportance of the work being done. For example, for things that are very likely to save power later you'd run them at 75% CPU throttling and for things that will probably only save a little power later you'd run at 25% CPU throttling.
This seems dodgy, but it isn't. The reason for this is that the relationship between CPU power consumption and CPU performance is not linear, and a CPU consumes power while doing nothing.
For example, consider a CPU that consumes 100 watts of power at 100% performance, 20 watts of power at 25% performance, and 10 watts of power in a HLT state. Now assume you've got some work to do that takes 1 second (at 100% performance), but there's a 10% chance it might not be needed.
The maths works out a little like this...
If you do the work in advance at 25% performance, then it'd take 4 seconds to complete and you'd use 20 watts for those 4 seconds. Then when the work is needed you'd spend that time idle because the work is already done. Total cost for the entire 5 seconds is 20 * 4 + 10 watts, or 90 watts.
If you wait until you know the work is needed, then you'd spend those first 4 seconds doing nothing. When you do find out that the work is needed you'd want to get it done fast, so you'd use 100% CPU performance for it. In this case total cost for those 5 seconds is 10 * 4 + 100 watts, or 140 watts.
If you do the work in advance but the work is never needed, then it'd still cost you 90 watts for those 5 seconds. If you don't do the work in advance and it's not needed, then you've spent 5 seconds doing nothing, or 5 * 10 = 50 watts.
Now we know that there's a 10% chance that this work won't be needed and need to adjust for that....
On average, doing the work in advance costs 90 * 0.9 + 90 * 0.1 watts, or 90 watts. Also on average, doing the work when necessary costs 140 * 0.9 + 50 * 0.1 watts, or 131 watts.
For this (admittedly contrived) example, doing the work in advance without knowing if it's actually necessary saves a significant amount of power, and when the user says "do the work" it looks like it's completed immediately.
Of course the real problem is finding things that can be done in advance that are likely to be needed later....
Cheers,
Brendan