I feel like this could easily be read as "software engineer finds placebo sleeping pills".
You very well could be right, but those sources are not scientific. If you want to show me that magnesium helps people sleep, show me a PubMed article on the subject.
"Supplementation of 500 mg of Mg has been associated with significant improvement in the insomnia severity index, sleep time, sleep efficiency, sleep onset latency, serum cortisol concentration, serum renin, and melatonin"
https://www.ncbi.nlm.nih.gov/pmc/articles/PMC5637834/
I'll pit my anecdata against your anecdata: Magnesium supplementation didn't do anything for my insomnia. I used the magnesium glycinate formulation from reputable brands at appropriate dosages.
You very well could be right, but those sources are not scientific. If you want to show me that magnesium helps people sleep, show me a PubMed article on the subject.