I haven't used Linux desktop lately though, but I'm not aware that they had an API for that.
You're probably right. Linux desktops environments (or at least some of them) used to have an attempt at something like that, but I think it only worked for applications that made an effort towards it, and I personally haven't even tried to see how or if that works nowadays.
Suspend to RAM and hibernation fill that hole for me, although it's admirable if someone has been able to properly solve the problem of restoring the session after a full reboot.
Also, I have no idea how your computer boots in seconds.
POST to UEFI is at least 3-5 seconds.
Than I have to wait about 5-10 ish seconds after I type my password to decrypt my drive.
Than it gets to OS selection screen which takes 3-5 seconds. Then it has to load all services after boot which takes about another 5-10 seconds before things get into a vaguely usable state.
This versus 2 seconds to wake.
And when someone says "seconds" the implication is that its at max around 5-9 seconds. I would be pretty pissed if a application that took "seconds" to boot actually took 59 seconds.
Also probably most people don't have encrypted HDDs on their home computer, so another 10 seconds you can shave off.
My current Ubuntu boots in maybe 10 secs from power button to login. And that includes the 3sec Grub menu pause.
But my point is that, for most of the time, I just leave it on. It consumes almost the same power sleeping that fully on, at idle.
And 10 seconds is still nearly 1000 subjective years. A Commodore 64 boots faster than the CRT can warm up and, while certainly doing less in the process, does it with a 1Mhz processor. Which, for reference, is 3000 times slower than our single core 3Ghz example not even accounting for CPI=>IPC inversion.
Computers are ludicrously fast, but we've apparently worked hard as an industry to slow them down as much as possible even for the simplest of tasks.
This is the wrong year to complain about boot time.
I remember being on an airplane with no wifi and a brand new MacBook Air and spent most of the time idly turning it off and on, since I was really impressed :) . And today that > 1 minute boot time I would consider crap.
Because we have ludicrously fast computers, but they feel slow. I have an period appropriate XP laptop in my office and every time I have to pull it out and use it I'm momentarily shocked by how responsive it is compared to modern OSs. We should be better than this, but our industry sucks at its job and I'm kinda sick of it.
> These days my Linux desktop computer boots in around 10 seconds [...]
> My desktop literally boots in less time than it takes for my DP monitor to power on from zero and start displaying frames.
Your monitor takes more than 10 seconds to power on, and you seriously don't think this is ridiculous? What the hell is it doing that could possible be taking that long?
No matter how many cores the CPU has or how fast they're clocked they're not going to make all that IO faster. They also can't run a hard coded 10ms sleep faster than 10ms.
Even once you get into a booted kernel and PID 1 you're still going to wait on IO to get daemons running. If you've got services (in systemd parlance) waiting on Networking you can have totally variable wait periods depending on local network conditions.
SSDs and parallel starting of daemons has improved boot times a lot over the past decade but there's still hard minimums just based on booting up low level crap before the kernel turns things over to PID 1.
Here is a real world scenario that is extremely common. I am using my laptop, say doing random hobby projects, with code open, a few browser tabs open, some terminal tabs, maybe with something running. My kid or spouse need my attention. I close my laptop lid so 1. It keeps all my windows open, 2. No one knocks over my laptop because its lid is open on a couch, 3. I can respond to my kid or spouse without having to shut down, wait for the shutdown process (a few seconds is a year when a kid is waiting for you... and in some cases, it could be a real emergency too).
Because my laptop where I run Linux on (Lenovo ideapad 320s) fails 100% of the time when I close the lid to put it to sleep, I simply cannot do this. When I say fail, I mean it hard crashes -- to fix it I'd have to hold the power button for 5 seconds to shut it down fully and reboot.
What I ended up doing was configuring it so closing the laptop lid does nothing at all (no sleep, no hibernate, simply turns off screen). This is an OK alternative but anyone who dosn't live alone know that when you close your laptop lid, you have no idea when you're going back to your laptop next. It could be in the next 5 minutes. Or, it could be the start of a series of events (changing diapers, bathing the kid, tantrums, etc.) that keeps you unavailable for the next 4 hours, and then it's bed time and you forget your laptop was still running, and then you go to work the next day, and finally a full 24 hours later you came back to your laptop and you remember that you didn't shut it down 24 hours ago, now it drained up all your battery and closed all your apps anyway. (Real world examples that have happened to me)
Into a clean screen, without any of the webpages, terminals, and other applications I've been running.
Recently upgraded to Ubuntu 20.04 and found out GNOME3 doesn't even support session save. (Seriously, WTF?) So sleep/hibernate is the only thing that allows me to get back to what I was doing.