I've anecedotedly studied how much sleep is the most efficient before writing an exam, throughout the many I've taken at university. This is a bit different than long term rentention though, as my hypothesis was basically "if you think you're screwed for an exam, what's the optimal crammed studying/sleep ratio the night before?"
1. All nighter is never worth it no matter how little material you think you know.
2. If you're semi confident in the exam, prioritize getting a full sleep over a little sleep.
3. If you're not confident in the exam, definitely still aim for at least 5-6 hours of sleep.
That's what I've noticed when it comes down to cram studying, otherwise my performance goes out the window.