Two Years of Sleep Optimization

As a kid, I became obsessed with my sleep. When I couldn’t fall asleep, I panicked – oh no, I’m not getting enough sleep for school tomorrow! As a good Asian kid, that thought was very scary.

I would blame my bed, mattress or pillow of making too much noise or being uncomfortable. My parents had to move things around quite a bit. I ended up sleeping with no pillow (less noise) on a Japanese futon mattress (no noise).

Later, I grew up. I started using a pillow and slept on a more normal mattress. In recent years however, I’ve become obsessed with my sleep again (possibly a side effect of getting old).

Working as a software engineer, it became very obvious to me how good my mental focus was each day: You notice pretty fast when you’re writing crappy code. Some days were way better than others for no obvious reason.

But what was causing it? What I knew for sure was that when I had slept badly, the next day would be unproductive. The inverse is also true: Some nights I felt like I had slept perfectly and I would wake up full of energy – very similar like the time being addicted to World of Warcraft and waking up at 6am to go farming.

I set out to optimize my sleep. After two years of doing this, I’d like to share my findings. Enjoy!


Most of my findings don’t have any numbers or statistics to prove them. They work for me but that doesn’t mean they’ll work for you.

And a disclaimer: Even though I’m a doctor, I’m not your doctor – this is not medical advice and when in doubt, consult a doctor 🙂

Ground Rules

Sleep Duration

I always try to give myself a sleep window of 8 hours. That means I set my alarm clock to a time 8 hours in the future with the goal of waking up before by myself.


I generally try not to nap at all. If unavoidable, I try to sleep before 3pm and for less than an hour. Its very unlikely that I actually adhere to these rules once I’ve started napping.


Light Intensity

While the bright side of the force is good, bright light in your bedroom is bad. I already started sleeping with a sleeping mask two years ago when I was living in a hostel in Australia (try sleeping when random people decide to turn all lights on while some other people are doing activites for which you rather want the lights to be out).

Interestingly, a sleeping mask can only compensate for so much: If your room is very bright, just a slight slip of the mask will let enough light in to wake you up. I learned this the hard way by sleeping in a room without curtains for six months (not recommended).

Quality differences in sleeping masks are significant. The free ones you sometimes get on flights are close to unusable as they press on your eyelids and let light in through the side (I used one for one year anyway). Better pick a good one (usually less than 10€) which has a shape to give your eyes some space (imagine a bra for your eyes) and doesn’t slip during the night.

Light Temperature

Blue light suppresses the release of melatonin but you need melatonin to accumulate to be able to start sleeping. It therefore becomes harder to fall asleep and the start of your “restful” sleep will be postponed (that’s also why taking melatonin may help you fall asleep when you’re jet lagged).

Try removing all sources of blue light in the 1-2 hours before sleeping:

On all your screens, set the device to emit less blue light. Android, iOS and macOS have this as built-in features in recent versions. Note that the stock settings are quite conservative, you may want to increase the intensity (of “yellow” light). For macOS, I actually prefer f.lux as it’s more customizable.

In your home, prevent exposure to all light sources which emit blue light, mostly neon tubes and blueish LED lights (i.e. almost all LED lights). My lights are all LIFX (LED) bulbs and IKEA LED panels, both allow the color temperature to be shifted to a more yellowish tint in the evening hours.


Studies show that a too high ambient temperature leads to less restful sleep. For me, 19.5°C is the optimum temperature, factoring in a light blanket and boxer shorts.

To control this, you need 1) a digital thermostat for your heater in winter, 2) an air conditioner in summer and 3) a temperature sensor to check whether the first two items are actually working properly. You may want to get a combined temperature / humidity sensor, they’re like 10€ or so.

Temperature Change

The change in temperature over the night has some effect, at least on me. While I can sleep through the night with a constant 24°C ambient temperature (and a fan), I definitely wake up if the temperature rises from 20°C to 24°C during the night (like typically in summer).

It’s probably best to keep the temperature constant during the night. It could be interesting to explore this effect for waking yourself up.

Other people in the same bed

Somehow we have culturally evolved to a point where it’s seen as appropriate to share your bed with your partner. Considering that we move around quite a bit while we sleep, could we assume that sharing our bed with someone actually leads to worse sleep? There’s a fairly recent review on the topic:

For most couples, the reality of sleeping in the same bed is a compromise, with each partner experiencing less than satisfactory sleep. It would seem that the logical solution to sleep disruption would be to relocate; moving into another room, or at least a twin bed, to overcome the “bed of thorns” created by gendered expectations, snoring, and other aberrant partner behaviours. Yet paradoxically, […] only 7% of couples under 55 currently sleep in separate beds, despite almost half complaining of being awakened up to six times a night.

However, there aren’t any great studies on the subject, probably because they would be difficult to conduct. Imagine having to find a group of couples of which you would randomly assign some to sleep separately for some nights. Maybe even mix it up by matching random people to team up for the night!


Bed is only for sleeping

It’s a good idea to only use your bed for sleeping – not for watching movies, working, sitting around, etc. There’s a nice benefit if you condition yourself that it’s “sleeping time” once you get into bed.

Sleeping Ritual

Talking about conditioning yourself, having a regular sleeping ritual also helps. This could be as simple as brushing your teeth and reading some pages in a book.

Stimulating stuff, Thinking, Coding

Doing “stimulating” things before sleeping is generally always a bad idea. Watching series is probably the worst culprit (excitement and blue LED light!) but also reading an exciting book be counterproductive.

Programming books have proven to be particularly bad. I would start dreaming about coding which is not a relaxing activity (at least for me).


Doing sports during the day is good and improves the depth of your sleep, doing sports late in the evening however is a bad idea as it will impair your sleep.

Final Thoughts

Optimizing sleep is the ultimate life hack – we spend one third of our life sleeping! It’s one of the biggest things which we can change while ironically, it’s one of the most underrated.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.