AMD has a one-liner to help speed up Linux system resume time
phoronix.com
phoronix.com
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.
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.
That said, with modern SSD prices I think the size it takes up is quite reasonable these days. For a while, when people were running 64GiB SSDs, the situation was a lot worse.
'Gaming PC' with a latest i7 but a $200 video card.
'DB Server' with gigantic core count each at 2.0GHz (for less than 30 people of course). Of HDDs as a primary storage.
Laptop with 128Gb of RAM yet insufficient storage to hold 128Gb hiberfil.sys.
Hibernation on a server? Pointless most of the time, because the bulk of the startup time is pre-OS. And hibernating VMs is just retarded.
In servers it's actually quite nice in homelab style setups where you might want to preserve your working session states, or just doing it on a nightly schedule without worrying about losing work.
For VMs it's of course useful to persist vm state to disk and suspend for lots of reasons (don't keep the RAM reseved, or free up VFIO passhthrough hardware for instance). But people often use hypervisor based snapshot for this. One advantage guest OS supported hibernation has it that your guest is aware of its own power state changes and can run your configured power management event hooks on suspend and wake. In the VFIO reddit it seems to be common for people who do windows vm gaming with gpu passthrough to prefer guest hibernate to hyprevisor side snapshots as well, not sure what are the main advantage there.
2015 was a long time ago in terms of SSD technology, but even then the space needed to hibernate 128GB was only $50.
If it's 'typical' to make a workstation that can't spare that space then that's even funnier than if it wasn't typical.
At this point it's a server in the name only. Even Supermicro takes ages to boot up, HPE and DELL can take up to 5-10 minutes to boot depending on the config.
Sure, there are some situations where it can be used for server, but hibernate is a middle ground between a full boot and STR and loses on the most important metric - the actual boot time.
> For VMs it's of course useful to persist vm state to disk and suspend for lots of reasons
But again it's quite niche. You trade the RAM for the disk space and if you are short on RAM then something gone wrong with planning the resources in the first place. Sure, in some situations (homelab again, *sigh*) it can be useful, but again it's not the popular option. With VDI you still get the bootstorm and lose the caching of the golden image.
> Depends on the vintage. Up to about 2015 a 128 GB workstation config typically had a <= 512 GB boot SSD and some spinning disk as well.
And again this is not 2015 anymore and surely you can have a $50 M.2 (or even SATA) 1Tb QLC SSD for the system drive (and your fancy whatever Tbs SSD for the actual workload).
> not sure what are the main advantage there.
The main difference is what the hardware is initialized again (instead of relying on the hypervisor to restore everything) so I bet it's some GPU shenanigas.
I would like to clarify: sure, in some cases hibernating works^W is useful, but my initial point was about 'unbalanced' configurations and having 128Gb RAM with a boot drive < 512Gb AND requiring hibernate is what would constitute as unbalanced for me.
PS for the sake of it, checked my notebook:
TM420 C:\Users\amc>dir c:\hiberfil.sys /ahs
Volume in drive C is Windows
Volume Serial Number is DEAD-BEEF
Directory of c:\
07.05.2023 03:03 4,901,584,896 hiberfil.sys
1 File(s) 4,901,584,896 bytes
0 Dir(s) 62,332,203,008 bytes free
Even if it was a full file for 12Gbs of RAM (damn those soldered modules) I would be fine with my 256Gb SSD.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.
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.
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.
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.
That said, systemd fucked the hell out of this feature and then the devs started gaslighting people about it[0][1]. That was on top of the fact that their "fix" broke the setting entirely and when you suspended your laptop it would never resume, guaranteeing a reboot and lost data (which ironically was their premise for "fixing" it in the first place). They really tried to get people to believe that a nearly dead battery 8 hours from now was preferable to hibernating after X minutes and resuming with a nearly full battery. On a motherfucking laptop.
Sigh. Just when I was starting to accept systemd they go and do that shit. Words cannot express how pissed I still am from that github thread and them breaking my laptop from a basic ass fucking system fucking mother fucking fucking upgrade. Fuck systemd.
[0] https://www.reddit.com/r/archlinux/comments/zczdnq/systemctl...
However, this one is pretty bad indeed. Also, respecting this one setting they had does not seem very complex, I'm not convinced by their way of rejecting the request to restore it.
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.
Depends where you're buying it. If it's soldered to the motherboard of the laptop it's going to be a lot more expensive.
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.
It is entirely bizarre.
But yes, the active sleep idea is terrible in windows at the moment.
> 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.
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
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.
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.
</joke>
Can't remember which one it was.
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.
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
Scott: Certainly, sir. How else can I keep my reputation as a miracle worker?
Kirk: Your reputation is secure, Scotty.