← Back to the chapter · Previous detail · Next detail →

Technical detail · Measure-First Optimization

Race-to-sleep arithmetic

Model the active current as I_active = k x f + I_fixed, a frequency-proportional dynamic part plus a fixed overhead that is on whenever the core is awake. For a fixed workload of N cycles, run time is N / f, so the dynamic energy is constant with frequency while the fixed-overhead energy shrinks as the clock rises.

Worked example: an 8 million cycle task.

Take k = 0.15 mA/MHz and a fixed overhead of 2 mA while awake, at a constant core voltage. The voltage comparisons below use a 1.0 V baseline. Calculate with unrounded run times and round the final results.

So the faster clock uses about 30% less energy despite drawing about twice the current, entirely because the fixed active overhead was paid for less time - and only if the core actually sleeps once the task ends.

Do the same arithmetic with the costs around the task. If both choices pay a 0.25 mA-s wake transition, the totals become 2.45 and 1.78 mA-s, so the fast case still wins. If the fast case alone instead pays a 0.70 mA-s voltage-switch or PLL-lock cost, its total rises to 2.23 mA-s, roughly equal to the 2.20 mA-s slow baseline before the shared wake cost. Including both costs gives 2.48 mA-s versus 2.45 mA-s. That is why the ledger must include wake, clock, sensor, and regulator overheads, not just instruction time.

← Back to the chapter · Previous detail · Next detail →