this post was submitted on 03 Jun 2024
1300 points (96.4% liked)
Technology
59605 readers
3501 users here now
This is a most excellent place for technology news and articles.
Our Rules
- Follow the lemmy.world rules.
- Only tech related content.
- Be excellent to each another!
- Mod approved content bots can post up to 10 articles per day.
- Threads asking for personal tech support may be deleted.
- Politics threads may be removed.
- No memes allowed as posts, OK to post as comments.
- Only approved bots from the list below, to ask if your bot can be added please contact us.
- Check for duplicates before posting, duplicates may be removed
Approved Bots
founded 1 year ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
Hmm. Yeah, okay, I can see about a minute-and-a-half being obnoxious.
So, the login prompt can probably be dealt with by just having some way to treat the login process specially and paging it in sooner. Like, I can't believe that it uses all that much memory. If it isn't an isolated process, make it one.
I'm using a 32 gig laptop. But most of that doesn't get used other than as disk cache, and I believe that normally, Linux isn't gonna restore the disk cache; it'll just drop the cache contents. Right now, I'm using 2.3G for actual application usage.
considers
I figure that maybe the desktop shell or whatever Apple calls it these days -- going back to classic MacOS, the Finder -- probably is more-heavyweight than what I'm using, but I figure that they could maybe do something like temporarily twiddle I/O priority on processes during the de-hibernation process. Like, okay, anything other than the foreground process gets an I/O priority penalty for a period of time. Like, maybe your music player or something is choppy for a few seconds, but whatever you're directly interacting with should be active more-quickly.
If this is SSD, that seems kinda long, still. Like, it shouldn't take 2 minutes to move 32GB to SSD.
It looks like I get about 3GBps reading from SSD:
And that's doing I/O going through the filesystem layer; I dunno if Macs use a swap file or swap partition these days, but if they have a dedicated partition, they might pull a bit more throughput). So if you figure that in terms of raw I/O performance, it shouldn't take more than about 10 seconds to fully restore memory contents on a 32GB laptop with comparable SSD performance, even if the OS has to fully-restore the entire contents of the memory. There's some hardware state restoration that has to happen prior to starting to pull stuff back into memory, but for the memory restoration, that's the floor. If it's more than that, then presumably it's possible to optimize by reprioritizing reads.
So, I guess that there are maybe a couple areas for potential improvement:
If the thing is locked and requires a password or something, you know that the user is gonna have to use the login process before anything else. Get that paged back in as soon as possible. Ditto for the graphics layer, Quartz or whatever Apple has these days. Strip that login process down; maybe separate it from whatever is showing blingy stuff on the login screen. Can have the OS treat it specially so that it's first in line to come up.
The next goal is to get the stuff that the user needs to be immediately interacting with back into memory. My guess is that that's probably the launcher and/or task switcher and the foreground process. Might have a limited amount that can be done to strip the launcher/task switcher down. Have all processes other than those few favored processes get a temporary I/O priority penalty.
One wants to keep the I/O system saturated until the system is to a fully-restored state, so that we don't have to have the latency of waiting for a process to request something to bring it back into memory. So have some process that gets started, runs with I/O priority below all other processes, and just does bulk reads of valid pages from the pagefile (or wherever MacOS stores the hibernation state). Once that thing has completed, the system should be fully-warmed back to pre-hibernation state. That eliminates idle gaps when maybe there's no reads happening. Maybe restore the disk cache state after that, if that doesn't happen now, if the reason the system is sluggish is because it's having to re-warm the cache bit by bit. On my Linux box, it looks like post-restoration, the disk cache is empty, so it's probably just dropping the disk cache contents (which probably speeds up hibernation, but is gonna mean that the post-hibernation system is gonna have to figure out what it's sensible to cache).
EDIT: Also, relevant Steve Jobs quote that comes to mind:
https://www.folklore.org/Saving_Lives.html