Two brown-headed spider monkeys are pictured sleeping at the zoo in Antwerp April 10, 2014. (REUTERS/Yves Herman)

Millions of years ago, when we were shorter and hairier and, well, let’s just say it, not too far removed from chimps, a night of uninterrupted sleep was impossible to come by.

For one thing, there were there predators — lions and giant hyenas and bears and the killer ancestor of modern kangaroos — who would happily take advantage of any ancient hominid whose eyes were closed too long. For another, there were the sleeping accommodations: the bumpy branch of some uncomfortable tree, where the risk of falling was never more than one bad nightmare away. It would have been noisy and windy and cold and an all-around uncomfortable experience.

“It’s like economy class on a plane,” Duke University evolutionary biologist David R. Samson told the New York Times.

Samson is a co-author of a recent study in the journal Evolutionary Anthropology that compared the sleep intensity of humans to that of hundreds of mammals and 21 primate cousins. Humans, it turns out, are far more efficient: We have evolved to get better quality sleep with just seven or eight hours; some primates need up to 17.

The explanation could be as simple as the comfiness of our beds: Once we started sleeping on the ground, around a fire, with plenty of friends nearby to ward off predators, it finally became safe to sleep deeply. So we did.

“Humans are unique in having shorter, higher quality sleep,” Samson said in university release.

He should know; before arriving at Duke, he logged more than 2,000 hours watching orangutans nap.

“I became nocturnal for about seven months,” he told the Times. “It takes someone who wants to get their PhD to be motivated enough to do that.”

The key to explaining our unique bedtime habits is in REM, or rapid eye movement, sleep. The purpose of the REM state remains particularly mystifying to researchers, even by the standards of the rather enigmatic world of sleep science. It’s thought to be associated with memory, brain development and dreams. Some studies have found that sleep, particularly deep sleep, is associated with the clearing out of molecular waste in the brain.

What is clear is that both REM and non-REM sleep are vitally important — stop a rat from sleeping for two weeks and he’ll simply drop dead, even if nothing else is wrong with him. Presumably the same thing would happen in humans, though no one is likely to test it.

Primates as well as humans require REM, but they can only get it in short bursts, the researchers say — sleeping too deeply in the wild can turn out to be as deadly as not sleeping at all (see: predators, risk of falling). So they must sleep for longer hours in an attempt to accumulate the benefits of REM. Chimpanzees, our closest animal relatives, sleep for 11 hours a day. The gray mouse lemur, a tiny goggle-eyed native of Madagascar, sleeps for as many as 17.

Among the most REM-desperate creatures that Samson and Nunn studied, just 5 percent of rest time was spent in the deep dream state.

Around 20 million years ago, our closest relatives became too big for mere branches — they began building nest-like sleeping platforms out of sticks and leaves instead. In a previous study, Samson described how chimps carefully choose the best and sturdiest limbs on which to build their beds.

“Big brains,” he told National Geographic at the time, “need big pillows.”

For the first two thirds of our history, our ancestors may have done the same: even after hominids became bipedal, they retained the unique arm and shoulder configurations that allowed them to swing through branches and sleep among the trees. Then came the genus Homo several million years ago. As we developed complex social groups and learned to control fire, it became safe to camp out down on the ground.

“Certain prerequisites have to be met in one’s sleep environment to have deep sleep because when you are in it you are less easily aroused, and thus more vulnerable,” Samson told the Huffington Post. “Living in larger groups, controlling fire (which keeps you warm and repels predators small and large) and sleeping consistently on stable, terrestrial sleeping surfaces … could have removed previous barriers in attaining the kind of high quality sleep humans are characterized by today.”

Today’s humans — tired though we may feel in our hectic modern lives, back-lit by the inescapable blue glow of a cell phone screen — spend 22 percent of our time sleeping in the REM phase.

Much as we now might like to spend 11 hours a day napping, our shorter sleep schedules gave humans an evolutionary edge. We used our spare time to form social bonds and develop new skills, the scientists say, and our better quality sleep could have helped to cement those skills, making us smarter and sharper in the long run.

Speaking to the New York Times, other sleep researchers applauded the study, though they noted that it raised some questions. For example, if sleep duration is inversely proportional to the likelihood of being disturbed, why does the gray mouse lemur — which sleeps in secluded tree cavities — need so much rest?

Dr. Jerome M. Siegel, a sleep researcher at the University of California, Los Angeles, noted that humans are by no means the best at REM. The platypus spends fifty percent of its sleep in the deep dream stage — a feat to which the rest of us can only aspire.