I know that this might sound too obvious to say. But I've found that, it is much easier to maintain good sleep habits when real life is not stressful. If I'm facing a big problem in life, an important deadline for example, it is unlikely that any effort I put into sleeping habits is going to help. Sometimes, I just stay up as late, but instead of working, time is spent in blaming myself for not sleeping in time, and worrying about getting up tomorrow.
The reason I think this is worth saying, is that sometimes, to break the vicious cycle of [stress -> sleep-deprivation -> more stress -> ...], you need to shift the focus to tackle the real life problem first, and don't beat yourself up for not being a good sleeper. Trying and failing to develop sleep hygiene can pile on the frustration and worsen the vicious cycle.
This is certainly true, although many of us have to deal with problems and projects large enough and time-consuming enough that if they prevented us from sleeping properly, we’d never sleep properly. It takes practice, essentially. Experimenting with various approaches until one finds methods that work.
For the particular issue you described, one approach is to journal before bedtime. Write out what is worrying you about the project, its deadline, etc. Put on paper the thoughts that are swirling through your head. Once captured in that manner, they may leave your brain alone for a few hours. It also helps to be organized, so you can reassure yourself that you have a plan.
Then there is the dreaded 3 or 4 am wake up, where all the thoughts can come rushing back in, preventing sleep for the next hour or perhaps even for the rest of the night. I have found that body scan meditation is helpful at these times.
I am not always successful, and these methods won’t work for everyone. The key is, like I said before, experimenting to find methods that work, and practicing the ones that show promise.
This is one reason why I write a short poem for my journaling. Maybe just four lines, does not matter if it rhymes. Poems are for fun, not work. Unless you are a poet, I suppose.
I find journaling a bit like physical exercise: It feels like _work_ in the moment, but you never regret writing it after. And you feel a lot better - there's a therapeutic effect to it. There's studies on this.
And dumping it out by journaling is much better than letting bad thoughts swirl in your head, which leads to even more rumination.
I've always found that journaling without an intended structure (a few sentences about a baseball game, or some coding paradigm, or a good memory) helps me to relax. If I task myself to "write about my day" like my parents taught me to as a kid I'd have a grand total of about 12 journal entries in my life.
Therapists suggest writing whatever is on your mind, including thoughts about the process itself, unfiltered. E.g. basically start with an F and how you hate all this bs and everything. If journaling itself is an issue, address it first. It’s another stupid …ing thing that you now have to do too for your idiotic mental health and your life became full of this … so quickly and …ing WHY, it was so normal just a few years ago, even with…
This is the fundamental shift - accepting everything including meta. People tend to distance from themselves, as if they were two distinct parts, one broken and one debugging. But the debugging part is also broken.
When I quit work because of burnout some years ago, at some point I just started going to bed every night at like 9pm with no effort whatsoever, really.
Completely broke when I started a job again and has been difficult ever after.
Reading in bed totally does it for me. Most of the time a novel or something. I can do three pages at most before everything becomes blurry and I struggle to stay awake and make it to the end of the page.
In exactly the same way though I can’t sleep if I’m excited about something, or really interested in solving a problem. That’s basically impossible to switch off, even if I could totally de-stress. This has basically been my experience for as long as I can remember (back to primary school).
In the end I saw a sleep doctor and he prescribed a low-dose melatonin regimen (1mg in a sublingual suspension, I take it about an hour before bed) and it’s actually worked pretty amazingly. Per my sleep tracking I’m averaging more than an hour extra per night and spending a lot less time in bed trying to go to sleep.
I went on a surf holiday to Indonesia, I was asleep by 9pm every night after day 3. Als spent time in various deserts, I'm so far away from my problems there I was in bed asleep by 8pm and up at 4:30am, with plenty of energy.
I've been surfing every day since I was a young child, so I don't really feel exertion from surfing anymore. Sure if I'm in the water for 3 hours, I get tired, but I surf the same intensity and time frames back home and don't necessarily sleep better.
When I'm in another country on a surf holiday, especially in a country with a rich culture like Indonesia, I just forget everything going on back home, and just relax.
The reason I think this is worth saying, is that sometimes, to break the vicious cycle of [stress -> sleep-deprivation -> more stress -> ...], you need to shift the focus to tackle the real life problem first, and don't beat yourself up for not being a good sleeper. Trying and failing to develop sleep hygiene can pile on the frustration and worsen the vicious cycle.