So, circadian effects are at the root of the behavior that we call sleep 360 million years ago animals that resemble insects began to appear, this is the begining of the insect radiation, and based on the behavior that insects have now, like fruit flies we can speculate that slow-wave sleep, this quiescent form of sleep was evolved around that time 