system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How do brains keep track of sleep debt?

For example: If you normally sleep 7 hours per day and one day you only get 5 hours of sleep, chances are that the next day when you fall sleep you will sleep for around 9 hours. Or if you only sleep for a normal 7 hours that day you will still need more than 7 hours the day after that to feel fully rested.

How do brains keep track of how much sleep they lost and need to make up for?
gpt
How do you keep track of if the garbage is full?

Sleep does things for the body, things we don't fully understand. One of those things is "tidying up" a bunch of blood chemicals and other things that accumulate over the waking hours. If it can't clean all of them up, then you wake up with some already present. If those chemicals interfere with other things in a way that makes you "feel tired", then guess what? You wake up tired.

It's not that there are sensors in the body for all of these things, some of them are low-key toxic depending on how you want to define toxic. For example, some byproducts of exercise create chemicals that make it harder for your muscles to work hard. That's part of why we get tired: the more those chemicals accumulate the harder it is for your muscles to do their job. So it really is like a trash can or dishes in the sink: if you let it pile up enough it starts to cause problems for unrelated things!

You "make up" for the sleep when you sleep enough to clear out all those things.