Fascinating. I would love to see my breakdown of bugs-per-commit, or words-spoken-in-meetings, compared to sleep to see if there any correlations. Anecdotally, sleep seems to be the number one factor that influences my productivity. More so than diet, exercise, or even mental health.
I remember when played a lot of DotA 2, trying to climb the ranks. < 6.5 hours of sleep == significantly more bad plays I wouldn't have made otherwise: forgetting about some important aspect, mistiming an action or reacting too slow. It was a level where I was often matched with competitive players and one mistake often changed the result of the game. In hindsight, I would've been better off just stopping for the day the moment I noticed my performance is garbage, but well, the game was addictive. It was almost always a bad decision to keep playing, but again, I was prone to making bad decisions on such days.
I have chronic insomnia that got worse every year. Eventually I stopped being able to sleep without being absolutely exhausted, usually after 35h or more awake hours. Almost drove me crazy. Paranoia, auditory and visual hallucinations, extreme touch sensitivity, you name it.
Lucky, modern medicine pretty much saved my life. (trazodone, which was combined with mirtazapine a few years later.)
I later was diagnosed with ADHD, and after medication I find it a bit easier to sleep (although I still need the other to have consistent sleep). Biggest problem was my brain just wouldn't shut up (and got noiser and noiser the longer I was awake.)
It took me a long time to get there, but I finally accepted that when I am tired, I shouldn't work. I should rest. The quality of the work that I do when tired is abysmal, and usually requires that it be redone anyway.
For low-latency work more sleep = better. There's no real advantage to pushing long hours. You can sleep and make quick progress when fresh.
For high-latency work that "should" be low-latency (ie you are on the end of a 1 hour pipeline that in an ideal world would be much faster) there can be significant advantages to just pushing more hours. This is a depressingly large % of enterprise work. Basically doing low brain stuff (which is most dev work) but trying to get feedback from the end of a long ci pipeline. I'm not sure this is true "in principle" but my observation is that after you hit baseline competence the people who make the most forward progress in this kind of dysfunctional scenario are the people who just spin the pipeline more and put in more hours.
For writing / proper design / activities where there might be no real safety net and feedback cycle might be years, definitely do that in the morning after good sleep.
BF Skinner, entry in one of his notebooks (as cited in “A Matter of Consequences”):
> Some way of controlling the strength of my own behavior. How to stop work before the optimal condition fades? This might be automatic if it were not for leftover compulsive effects of aversive control. Exhaust- ing avocations are a danger. No more chess. No more bridge problems. No more detective stories. When I am not working, I must relax—not work at something else! A good measure of fatigue would be helpful. I can tell how tired I am when playing the piano. Early in the morning, well rested, I surprise myself. Later in the day, I accept my errors as inevitable. My handwriting is also a gauge. It would be nice to have a shibboleth—a passage to be written in ten seconds, the errors to determine whether I work or relax. ... I must keep busy? Then relax profitably.