129 points · by sharjeelsayed · 3y ago · 76 comments
Can we not try to force s2idle? It uses way too much power. I've not yet seen a laptop which is capable of staying "sleeping" in s2idle as long as in s3 sleep. Correct me if I'm wrong though.
I also don't really get why: s3 is more than fast enough to be awake when my laptop is open and I'm ready to login, the only "need to be faster" way I can see is when you do not lock you laptop and go straight to desktop but that has ... issues.
The problem is that a lot of laptop manufacturers, driver authors, UEFI firmware vendors, and you name it, don't exactly have power savings as a first priority. On some select devices, s2idle works great and it's just like sleep but faster. On many other devices, there are bugs and issues that just break shit.
At this point, I have more faith in a brand new Linux install going to sleep successfully than a Windows install staying the fuck off. It's quite annoying, especially since I know every modern CPU has full support for this and the issues just lie in software elsewhere on the board.
If you've got an SSD, the easiest fix is to switch to S4/hibernation/suspend to disk. You can remap the power button/laptop close handler. You may need to enter your drive encryption key again when you resume (which is probably more secure anyway) but your sleep will work reliably and it'll consume no power at all, unlike S3 sleep.
It is entirely bizarre.
But yes, the active sleep idea is terrible in windows at the moment.
And copying 32 G is not instantaneous neither. I bet a fresh boot is faster, defeating a big part of the purpose of suspend for me (part of it is finding my workspace where I left it, sure, but also being able to quickly wake up the laptop).
And 64 G laptops are sold now.
I wish I had more trust in laptops to properly handle putting itself into S2 when I close the lid, and then after 30 minutes (or if the battery gets low) go down into S3. But I've seen far too many laptops just fail to properly suspend for whatever reason.
Yes but in 2023 a 1TB SSD is $40.
> And copying 32 G is not instantaneous neither. I bet a fresh boot is faster, defeating a big part of the purpose of suspend for me (part of it is finding my workspace where I left it, sure, but also being able to quickly wake up the laptop).
How much you need to copy should depend on how much you have open, which should relate pretty strongly to how annoying a reboot is.
> In 1999, then Microsoft CEO Bill Gates stated in an e-mail that Linux would benefit from ACPI without them having to do work and suggested to make it Windows-only.
My Windows laptop from work loves to have the mouse, keyboard and/or wifi fail to wake up properly if it gets disconnected from its badly-designed power cord, despite constantly making me install the latest drivers.
I've had a 2017 MBP: it goes to sleep, continues to check email etc, and wakes up the next day with an almost full battery. I don't have any M1 Macbooks but I can imagine they could stay awake and have 90% battery left the next day.
Macs also continue responding to pings and accepting SSH connections on wired Ethernet while sleeping. I've had less luck with inbound SSH over Tailscale, but I can use any other device on the network as a jumphost.
I only use S4 (hibernate) because I can ignore my laptop for weeks at a time, unplugged, and jump right back in to where I left off. Microsoft seems to have changed some things in Windows to hide the hibernate option for some reason I can't figure out.
At least with Linux, out of the box all you'll have is the message "Lockdown: systemd-logind: hibernation is restricted; see man kernel_lockdown.7" in your logs.
(The trick is to either disable Secure Boot, or AFAIK make use of an encrypted swap partition; IIRC, there's a bug which makes it not recognize a swap volume within LVM within LUKS as encrypted swap, so it has to be directly on a disk partition.)
People say Microsoft isn't the same as 20 years ago, that they are not pure evil, but this is proof...
People haven't been paying attention since their consent decree expired over a decade ago.
1. Doing the thing $5/h
2. Knowing what thing to do $500/h
On the race condition, that was actually pretty easy to diagnose and solve, replaced the static property with a local getter/setter using the request context to store the value (asp.net 2.0).
On fedora cinnamon, I was getting random freezes on resume, and momentary freezes on resume on Linux Mint. Disabling the ability for XHCI to wake my machine fixed it.
This sleep() looks like bad code designed to work around a race condition. Perhaps it's related to the issue I had.
This issue was the worst Linux issue I've had in ~10+ years.
(I'm on ryzen first gen cpu)
You can do cat /proc/acpi/wakeup to see what is allowed to wake your machine.
Echoing the device ID into /proc/acpi/wakeup will toggle it between disabled and enabled.
So to disable XHCI wakeup, I had to do:
sudo echo XHC0 > /proc/acpi/wakeup
Now that will reset on every boot, so I wrote a systemd service to do it on startup, and instead of just disabling 'XCH0', I found another user online that had written a shell script to disable everything's ability to wake the machine.
This is the systemd unit to disable the ability for devices to wake the machine: https://github.com/jknightdoeswork/dotfiles/blob/master/disa...
This is the shell script to install that systemd unit so it runs on every boot: https://github.com/jknightdoeswork/dotfiles/blob/master/inst...
Note that with this installed, I'm pretty sure the only way to wake your machine is to press the power button. I prefer that but you might not. You may want to disable _just_ the XHCI devices, not _all_ of em. Up to you. Feel free to ask more questions.
Like epoll for events
In either case, I wouldn't expect it before 12-18 months... The RDNA 1 drivers seemed to take 8 months to see something stable drop in an LTS, the release before LTS was running an older kernel and had to add a custom PPA for more bleeding edge kernels (breaking a bunch of other stuff, but at least I could see the screen, when an update didn't kill it).
But back to the question. When might PopOS get this?
You can find basic instructions here: https://www.baeldung.com/linux/oldconfig-target-kernel-makef...
Is it worth going to all the trouble of doing this to save slightly over 1/10th of a second on wake from sleep? Probably not. Is it fun to experiment with? That's up to you to decide.
tl;dr: I think pop is a Ubuntu flavor, so ~6 months and/or it's already available today if you're not afraid to compile your own kernel.
Pop isn't currently following the Ubuntu release cadence, they've got some internal development that their focusing on instead currently.
</joke>
Surprisingly, a lot of aerospace engineers are not super computer-literate. We used a clunky maneuver planning software for the geostationary sats that spit out our plans in an ASCII printout, which we then had to copy/paste out and manipulate using several consecutive shell scripts. I got annoyed doing it and so I rewrote the whole deal in Python, and just had it locate the file that had the printout.
When I first ran it, it had turned a 3-4 hour affair into about 10 minutes (depending on network connectivity). I showed it to my boss, and he was asking why it said "working...done" instantly. He said it looked like it wasn't doing anything.
So I added an aesthetic wait variable to the config and made it 1.25 seconds. So the user got to see "Working..." and then "done" would pop out, making it seem more like it was actually doing things to the layperson.
Last I heard they were still using that script for maneuver planning to this day.
But that's the techy point of view. Most non-techies will probably prefer feel over functionality. I think most people do. If something is instant, it feels too good to be true. If something takes ages, you'll get bored or frustrated. While things that take a proportional amount of time feel satisfying.
https://garden.bradwoods.io/notes/design/juice
"..." is a kind of juice
Can't remember which one it was.
Scott: Certainly, sir. How else can I keep my reputation as a miracle worker?
Kirk: Your reputation is secure, Scotty.
On top of that solid basis, you can introduce artificial inefficiencies, and then gradually remove them.
But you can't do the trick at all, if your rewrite doesn't start off being an orders-of-magnitude efficiency improvement.