At yesterday's Worldwide Developer Conference (WWDC) keynote, Apple made some bold claims about the future of battery life in its laptops. A new 13-inch Macbook Air, for instance, should now run a full 12 hours on a single charge, up from 7 in the previous model. Assuming that testing bears out Apple's numbers, how did the company do it? The obvious part of the answer is "Haswell"—but that turns out to be only part of the story.

The power efficiency gains found in Intel's new Haswell CPUs should provide modest gains in battery life, and such gains were widely expected. Back in January, Intel claimed that the new Haswell CPUs featured the "largest generation-to-generation battery life increase in the history of Intel" and said that the chips were the first of its architectures designed "from the ground up" for Ultrabooks and tablets. The new chips run at lower clockspeeds and at lower wattages.

Less expected was the announcement of OS X 10.9 "Mavericks" and its own focus on mobile power usage. While Apple made a few comments during the keynote about the new technologies meant to enable longer battery life, more information appeared later in the day with the separate release of a Core Technology Overview (PDF) document that offers a high-level look at some of the Mavericks internals.

The overarching goal of the power efficiency changes is of course longer battery life, but Apple claims that it can acheive this without harming "and in some cases even improving" overall system responsiveness. Three main technologies make this possible.

First up: compressed memory. Not ordinarily thought of as a power management tool, compressed memory "automatically compresses the least recently used items in memory, compacting them to about half their original size." When the items are needed, they are uncompressed and presented to the requesting program.

Apple claims that this compression/decompression cycle within memory is faster than swapping the information out to disk, even when that disk is an SSD, thanks to its use of the old WKdm algorithm. (And running Mavericks on older laptops with mechanical disks should result in even more dramatic savings.) A 2003 academic paper (PDF) comparing the speed of three "live RAM" compression algorithms concurs, concluding, "WKdm compresses and decompresses extremely fast, outperforming the other two [tested] algorithms in both respects." This frees overall memory, increases speed (compared with swapping to disk), and lowers disk wear, but Apple claims that it also "reduces the need to read and write virtual memory swap files on disk, improving the power efficiency of your Mac," despite the small increase in CPU usage due to the compression and decompression.

The second technology is App Nap. The new feature clamps down harder on apps that aren't in the foreground. (One of our Mac-using editors notes that the current version of Safari consumes about 15 percent of CPU resources when running in the background, so these power losses can be significant.) The default scenario is to aggressively throttle resources when "an app's windows are not visible and the app is not playing audio" (though devs can override this behavior). When an app is "napping," OS X throttles its program timers, limiting their frequency to generate "significant improvements in CPU idle time when running applications that frequently check for data."

Disk and network activity are both more limited than before, too. A napping app receives the "lowest priority" for disk and network access, which is meant to reduce disk power usage but also to make foreground apps more responsive. "I/O throttling reduces the chance that a background process will interfere with the I/O activity of an app that you are actively using," says Apple.

Mavericks will also lower the UNIX process priority of any napping app so that it receives a smaller slice of CPU resources. Together, the changes should exert more control over background apps and keep their power consumption in check—though with opt-out controls for any apps designed to run at full power in the background.

Finally, Apple introduces something called Timer Coalescing, which only operates while a machine is on battery power. OS X programs are constantly setting timers that can activate the CPU, the disk, or the network link to do everything from checking DHCP WiFi leases to running Software Update to triggering an audible alarm. (Most of these timers result in action that is invisible to the user.) Because apps don't coordinate their timers at all, an idling Mac can be constantly awakened by firing timers, keeping CPUs and disks out of their lowest-power idle states.

Timer Coalescing attempts to enforce some order on all this chaos. While on battery power, Mavericks will routinely scan all upcoming timers that apps have set and then apply a gentle nudge to line up any timers that will fire close to each other in time. This "coalescing" behavior means that the disk and CPU can awaken, perform timer-related tasks for multiple apps at once, and then return to sleep or idle for a longer period of time before the next round of timers fire.

Apple has never guaranteed developers that timers will run at exact times, either, so this isn't necessarily a break with convention. Apple currently tells developers that "because of the various input sources a typical run loop manages, the effective resolution of the time interval for a timer is limited to on the order of 50-100 milliseconds," and it notes that busy apps may have their timers affected even more. Current apps that set a 0.1s timer, for instance, only get something within +/- 0.00001s or so, and Apple sounds like it will get even more "approximate" with timer scheduling in Mavericks.

Apple claims the technique can "dramatically increase the amount of time that the processor spends idling," and it uses this illustrative chart to show the possible improvement in power usage:

The new technologies exist alongside some kernel-level adjustments to the way CPU resources are used—Mavericks prefers to use as few cores as possible, leaving others totally idle so long as demand allows it. Paired with the Haswell improvements, Apple is making some dramatic claims for battery life improvements—and we'll be putting them all to the test.