Kyle McDonald
9 min readJan 27, 2018


Disclaimer: I am not a doctor, this is not medical advice.

In 2013 around the age of 28, I stopped feeling rested when I woke up each morning. It happened gradually and never really disappeared, but in the process of trying to fix it I learned a lot about sleep, and about myself. Today, my worst nights are much more manageable than those from a few years ago. If you’re an analytical person and you’re having trouble feeling rested, this is for you. Read through to follow my journey, or skip to the end for a summary.

My trouble began around the same time I started regularly sharing a bed. I never thought of myself as a sensitive sleeper, but I become hyper-aware when someone else is in the same bed. I found myself in a constant nearly-waking state, taking as long as an hour to fall asleep and waking up as many as five times throughout the night for as many as three hours total. The next day I would feel useless: no energy, difficulty concentrating, even struggling with depression and wondering if I was “stuck” this way. And this wasn’t restricted to sharing a bed. I experienced a version of this when alone, too.

After a year without any changes, I found a sleep therapist on Psychology Today. We set rules for sleeping, started collecting data about my sleep, and worked through the psychology behind sleep.

Sleep Rules

My rules initially looked like this:

Unplug at 11:00pm.
Do not get into bed until sleepy.
Read in bed at 11:45pm until ready to sleep.
Earliest bedtime: midnight.
At any point, get out of bed if awake more than 15 minutes.
Read until very sleepy. Repeat as necessary.
Set alarm and get up at 7am.

This was the first step of something called “sleep restriction therapy”. The idea is that insomnia (difficulty falling or staying asleep) can sometimes be treated by depriving your body of any opportunity to be awake when it shouldn’t be. In this case, I was only allowed 7 hours of sleep per night for two weeks. The first week was very difficult: 7 hours in bed with 3 hours of insomnia doesn’t leave a lot of time for sleep. But in the second week, while I still felt incredibly tired, I didn’t have as much trouble sleeping. The next step was to slowly extend the amount of time I was allowed in bed until the insomnia came back. The goal is to optimize “sleep efficiency”: the percentage of time in bed spent sleeping.

The “unplug” rule is based on evidence that blue light at night can cause sleep problems. I started using f.lux regularly to make my screen more yellow at night. Today this is a built-in feature on most tablets, phones and computers. Personally, I feel access to the internet around bedtime induces a hyper-sensitivity in me, regardless of whether it’s colored blue or yellow. Some people deal with this by removing most devices from their bedroom and leaving only an alarm clock.

Get out of bed if awake” was new to me. Staying in bed with insomnia for too long can create a negative association between being in bed and trying to sleep. My therapist recommended getting out of bed and reading “something boring”.

Sleep Data

I collected a bunch of data every day and night:

  • If I had taken any sleep medication
  • Room temperature
  • Time getting in bed
  • Sleeping alone or together
  • Minutes in bed until lights out
  • Minutes after lights out until falling asleep
  • How many times waking up at night
  • How many minutes waking up at night
  • Final time of waking up
  • Minutes after waking up until getting out of bed
  • 1–5 score for how well I slept
  • 1–5 score for how rested I feel
  • If/when I exercised, and how long
  • If/when I had caffeine, and how much
  • If/when I had alcohol, and how much

I tried using a few different apps to collect this data, but eventually switched to using a spreadsheet that gave me the maximum flexibility. From this data I also computed some additional information, like sleep efficiency, average waking duration, or time from having caffeine until lights out. I collected this data for around three months. I tried plotting and analyzing it in a bunch of different ways to find patterns, but most of the lessons were obvious:

  1. Consistent timing is essential for optimizing sleep efficiency.
  2. Too much sleep can be just as tiring as too little.
  3. For me, room temperature is more significant than I expected. Once it started feeling “warm” my sleep efficiency went down. On hot nights, I noticed the noise from the A/C helped, and used a Dohm white noise machine other nights.
  4. Exercise earlier in the day can help for sleeping that same night, but the real effect of exercise is more gradual and cumulative. Also, exercising within a few hours of bed time made it difficult for me to sleep.
  5. Sometimes alcohol can make falling asleep or staying asleep easier, but I will pay in terms of feeling rested the next day.
  6. Caffeine has an almost impossibly strong effect on me. Anything more than a cup of green tea after 2pm will keep me alert at bed time.

One of the most important lessons didn’t come from analysis, but just from looking at the data as a whole: there are good and bad days, and it’s not always clear why.

Sleep Psychology

My therapist gave me a chance to talk through some of the things I was feeling and the questions I couldn’t get out of my head (“am I stuck this way?”). It also felt reassuring to hear that other people in similar situations had made progress. At the same time we started with the rules and data collection, my therapist introduced me to cognitive behavioral therapy. CBT helped me build a vocabulary and mental model for how my thoughts, feelings and behaviors are related. CBT has been demonstrated to be more effective than a placebo for treating insomnia. We worked through Mind Over Mood, which contains reading sections, worksheets completed at home, and instructions for discussion with a therapist. Over the course of a couple months, CBT helped me significantly improve my mood on the days where I hadn’t slept well the night before. I recommend working through Mind Over Mood even if you don’t have a therapist, but it’s most valuable as a precursor to discussion.

Sleep Study

After a two months with the therapist, I felt that I’d made progress with my insomnia but I still felt chronic fatigue. I had blood tests done to check for any deficiencies. I was especially curious about vitamin B12, calcium, and magnesium because I read they are connected to sleep quality. All my levels came back normal. I tried supplements and they didn’t make a difference.

My therapist recommended I do a sleep study, which involves sleeping in a strange location, covered in wires, while technicians watch you from a surveillance camera. I went to the sleep center and they attached an EEG, pulse oximeter, and breathing rate sensor. I felt like I hardly slept at all. I took notes so I could compare my experience to their analysis when the results came back.

One possibility was that I had some kind of sleep apnea, where your body doesn’t get enough oxygen due to breathing irregularities. This can be caused by obstructions in the airway (obstructive sleep apnea), or by the brain failing to initiate breathing correctly (central sleep apnea). Central sleep apnea is complicated to treat. But obstructive sleep apnea is often associated with snoring, and there are a number of anti-snoring devices out there that open up your nose or shift your jaw forward. I had already tried a few and suspected I didn’t have sleep apnea.

The results of the sleep study showed that my “sleep architecture” was disturbed. The EEG showed I would jump out of REM at unusual times or skip stages. While I felt that my sleep efficiency for that night was very low, they told me it was fairly average. They agreed that I did not have sleep apnea. In short, there was no clear explanation.

The doctor who analyzed my study prescribed doxepin to help me stay asleep and stabilize my sleep cycles. While doxepin in high doses can act as an antidepressant, in low doses it is primarily an antihistamine like diphenhydramine (Benadryl) or doxylamine (Unisom). I tried diphenhydramine and doxylamine, but didn’t like the residual drowsiness the next morning. Low-dose doxepin behaves better than other antihistamines: no withdrawal effects, no development of tolerance or dependence, no dry mouth. With doxepin I still had some residual drowsiness, but slept better and felt better rested in the afternoon.

The doctor at the sleep center also helped me understand melatonin better. Melatonin is a hormone released at night to control our sleep-wake cycle. Taking melatonin supplements can help manage changes in sleep schedules during travel, or help older folks maintain a sleep schedule even when their body is producing less melatonin. Some people have a disorder that causes their natural sleep-wake cycle to be significantly longer or shorter than 24 hours (possibly connected to delayed sleep phase disorder), and melatonin can help them stick to a 24 hour schedule.

The most important thing I learned about melatonin is that I’d been taking it wrong. Usually melatonin is sold in 1mg, 3mg, or even 10mg doses. But the ideal dose is 300mcg (0.3mg) and the higher doses can actually create a “hangover” effect and results in the hormone losing its effectiveness. The timing on melatonin is also important. The doctor recommended taking it 1–2 hours before going to bed, and I’ve settled on closer to 1 hour. Finally, melatonin should be taken at a similar time each night to maximize the effectiveness in stabilizing your sleep-wake cycle.

Another way to boost your melatonin levels is via 5-HTP which is used for the synthesis of melatonin via serotonin. For me, 5-HTP feels similar to melatonin but vaguely more relaxed instead of just slightly drowsy. I don’t take 5-HTP regularly because it feels less consistent in terms of how it affects my sleep.

The doctor also taught me a variation on breathing meditation that helps me fall asleep: count each breath, counting down from 100. Today this is one of my go-to exercises when I’m feeling anxious about falling asleep.


Everything above happened around 2013-2014, now four years ago. Since then a few things have changed:

  • Antihistamines like doxepin, diphenhydramine, and doxylamine are associated with an increased risk of dementia. I try to limit my use of these drugs to the times when I need to radically “reset” my sleep schedule.
  • 3,500IU of Vitamin D3 daily can increase sleep duration, reduce sleep latency, and improve sleep quality. Personally, I haven’t noticed a big effect.
  • There are at-home sleep study kits you can purchase online. I haven’t tried any but they seem way cheaper than the real thing.
  • There are new devices and apps for tracking health and symptom data. I have tried some, but not for tracking sleep.
  • I’ve started to maintain a mental map of recurring places in my dreams, and I find that visualizing these places helps me fall asleep faster.
  • I’ve learned that I can identify a change in my thoughts just before I fall asleep: an idea will come to mind that is nonsensical or otherwise out of place. When I notice this, I know that I’m almost asleep and I can let the nonsense flow.


This is what didn’t work for me:

  • Anti-snoring devices
  • Vitamin B12 supplements
  • Magnesium supplements
  • Calcium supplements
  • I’m currently evaluating Vitamin D3 supplements.

Here is what did work for me:

  • Sleep restriction therapy reduced my insomnia.
  • CBT helped me overcome anxiety around sleep.
  • If I can’t fall asleep, I get out of bed.
  • Reduced my exposure to blue light before bed.
  • Removed most devices from my bedroom.
  • Collected data on my sleeping patterns to help me understand what affects me the most, and to remember there will be good and bad days.
  • Not sleeping too much when “making up” for bad nights.
  • Had a sleep study to confirm I do not have sleep apnea.
  • Rarely, 25mg of diphenhydramine or doxylamine 30 minutes before bed when I need to “reset” my sleep schedule.
  • Every night 300mcg melatonin 1 hour before bed.
  • Regular exercise.
  • Getting more sunlight during the daytime.
  • Consistency in my sleep schedule.
  • Keeping my bedroom cool and noisy (white noise).
  • Counting down each breath from 100 at bed time.
  • Wearing an eye mask and earplugs in the morning as needed.




Kyle McDonald