You know the horrors a sleepless night can bring. They haunt you the following day: fatigue, headaches, irritability, and inability to focus, to name a few. Though sleep deprivation comes for us all on occasion, a new study suggests that habitually substandard shut-eye is linked to accelerated brain aging.

While poor sleep quality doesn’t necessarily cause speedier brain aging, researchers at the University of California, San Francisco (UCSF) and other U.S. institutions found that poor sleep quality in early middle age is associated with more signs of poor brain health in late middle age.

Their findings were published Oct. 23 in Neurology , the medical journal of the American Academy of Neurology . “Sleep problems have been linked in previous research to poor thinking and memory skills later in life, putting people at higher risk for dementia,” study coauthor Clémence Cavaillès, PhD , an epidemiologist at UCSF’s Center for Population Brain Health , said in a news release about the research.

“Our study, which used brain scans to determine participants’ brain age, suggests that poor sleep is linked to nearly three years of additional brain aging as early as middle age.” The study assessed nearly 600 people over the course of 15 years. At the outset, participants’ average age was 40.

They completed a baseline survey about their sleep habits and were asked questions such as: “Do you usually have trouble falling asleep?” “Do you usually wake up several ti.