One of the things I really liked about my old iBook G4 was that it would go to sleep almost instantly when the laptop lid was closed (suspending to RAM), and would wake up almost as quickly (give or take whether the wakeup code had been paged out resulting in the disk needing to be spun up to wake up).

Unfortunately my newer MacBook (and a previous model that I used at at previous employer) don't do this out of the box. Since about 2005, the default has been "SafeSleep", viz to write everything out to disk (suspend to disk) but still keep the RAM contents alive, with the aim of surviving a power outage but also having a fast wake up if the power remains. As far as I can tell reading between the lines this was done because earlier models had a supercap to keep the RAM contents alive while you changed batteries but newer models do not have any additional RAM backup so needed the RAM contents safely saved to disk if you were to change the battery while suspended. The default has been preserved into even newer models (like mine) which do not have interchangable batteries.

The default can be changed with pmset to alter the hibernatemode value. hibernatemode is a bitfield value where the values are (from pmset(1) man page):

 0001 (bit 0) enables hibernation; causes OS X to write memory state to
 hibernation image at sleep time. On wake (without bit 1 set) OS X will
 resume from the hibernation image. Bit 0 set (without bit 1 set) causes
 OS X to write memory state and immediately hibernate at sleep time.

 0010 (bit 1), in conjunction with bit 0, causes OS X to maintain system
 state in memory and leave system power on until battery level drops below
 a near empty threshold (This enables quicker wakeup from memory while
 battery power is available). Upon nearly emptying the battery, OS X shuts
 off all system power and hibernates; on wake the system will resume from
 hibernation image, not from memory.

(0100 (bit 2) historically controlled not encrypting the sleep file even when secure virtual memory was enabled (cf MacWorld article on sleep mode); it is now recommended never to use bit 2, since now secure virtual memory is handled properly over sleep.)

From the above bitfield details we can tell that the useful values are:

  • 0 = Sleep only (keep memory alive, do not write to disk)
  • 1 = Hibernate only (do not keep memory alive, always read back from disk)
  • 3 = SafeSleep (keep memory alive, but write to disk before sleeping just in case power is lost)

(Hibenate only can be useful if you don't mind waiting and want to avoid the flashing "I'm sleeping" light, or have a device without battery backup that you need to unplug from the mains.)

There are three values for each power management setting:

  1. Battery Power (pmset -b)
  2. Charger (ie Wall Power) (pmset -c)
  3. UPS (pmset -u)

For a given piece of hardware it is likely that only two (eg, Battery and Charger, or Charger and UPS) will be relevant; pmset -a can be used to adjust all of them at once.

pmset -g can be used to retrieve the current settings in use (ie, based on what the current power situation is); and pmset -g custom can be used to retrieve the configured settings for all relevant power profiles. To find out the configured hibernatemode settings, run pmset -g custom |egrep '^[A-Z]|hibernatemode':

Battery Power:
 hibernatemode  3
AC Power:
 hibernatemode  3

For my usage patterns, I never need to change batteries while suspended (since my MacBook model doesn't support changing the battery), and my MacBook spends most of its time connected to mains power at one location or another, so the battery just needs to keep the RAM contents for long enough to get to the next location (typically only a few hours and very rarely longer then 12 hours). So I'd much rather have the speed of just sleeping without writing to disk. I also want to do this whether mains power is currently connected or not, since most of the time when I'm suspending I want to be able to pick up my laptop and walk off with it quickly -- rather than waiting 20-30 seconds until the hard drive stops and it's safe to move the laptop.

So the best option for me is to set all the hibernatemode values:

sudo pmset -a hibernatemode 0

to enable the "Sleep only" functionality, which takes 4-5 seconds rather than 20-30 seconds. (Others have reached the same conclusion.)

(The "SafeSleep" option can be enabled by setting it back to 3.)

For those that prefer a GUI, there is SmartSleep, a third party preference pane to control this functionality. (It apparently includes some intelligence around which sleep mode to use based on the remaining battery life.)

Finally as a free bonus tip, Option-Cmd-Eject on a Mac keyboard will invoke the sleep functionality that is configured, which is very useful when using a MacBook connected to an external keyboard/mouse/monitor with the lid closed. (When the lid is open, just closing the lid is the easiest way to invoke the sleep functionality.)