A self-regulating system.
Our body has two key drivers to regulate our sleep: circadian alerting and the sleep-wake homeostasis system. Sleep-wake homeostasis is the one that manages how long we need to be awake and when to feel the need to sleep, depending on experience. This self-regulating system follows how long you’ve been awake to know how long you will need to sleep to recuperate.
It is unclear how it determines how much we need to sleep. However, during the day, neurons in our brain will activate that sensitivity with sleep loss. This system is also the one that will set up to sleep longer and deeply when there are periods of very little rest.