Burnout is not fun and it can put your out of business for months, or even years if you have a bad case. (In my case, it was a year and a half of zero productive work). One of my relatives, after a particularly rough Ph.D, claimed that she will never be able to perform at the same level again. It's okay to be ambitious, but I think too many young and ambitious people let their ambition get the best of them. Learning your limits by crashing into them at full speed is not advisable.
I don't mean to sound negative or dismissive, but I've experienced this myself and seen too many cases first-hand not to care. The Silicon Valley startup culture is in many places outright destructive when it comes to this aspect of life.
More constructively: Setting strict deadlines and schedules that you will maintain unless the sky is falling (change the definition to "no matter what" if the sky is "constantly" falling), balancing your time so you have enough sleep and enough time to yourself is a safe way to ensure that you are working sustainably. This will lower your productivity, though. At least make your sacrifices with both eyes open.
My understanding is that taking it consistently isn't a good idea. Using it the odd night that I'm restless seems like a good idea.
All the research I've read says that it makes absolutely no difference. You never develop an immunity to it and it doesn't inhibit natural production. No research (that I'm aware of) has yet to find a downside, even at regularly taken large doses.
Here's another article mentioning that it should be taken for 3 months at most:
http://www.huffingtonpost.com/dr-michael-j-breus/melatonin-s...
Gwern has a page (with a very pro-Melatonin message) with lots of links: http://www.gwern.net/Melatonin
Also, no laptop/phone/tablet/etc. in the bedroom - just books/magazines. Reading before bed is the best way to slowly move towards sleep and not keep yourself up for hours the way that looking at a screen does.
Yes, sometimes you feel like you can work for an extra couple hours, etc. - but at the end of the day it's a choice you have to make. If you genuinely care about being healthy, put {sleep | healthy food | exercise } before everything else. The first few weeks might be a bit rough, but the rest will follow.