Time for a rant about shitstaind, suspend/hibernate, and if there's room for it at the end probably swappiness, and Windows' way of dealing with this.

So yesterday I wanted to suspend my laptop like usual, to get those goddamn fans to shut up when I'm sleeping. Shitstaind.. pinnacle of init systems.. nope, couldn't do it. Hibernation on the other hand, no problem mate! So I hibernated the laptop and resumed it just now. I'm baffled by this.

I'll oversimplify a bit here (but feel free to comment how there's more to it regardless) but basically with suspend you keep your memory active as well as some blinkenlights, and everything else goes down. Simple enough.. except ACPI and I will not get into that here, curse those foul lands of ACPI.

With hibernation you do exactly the same, but on top of that, you also resume the system after suspending it, and freeze it. While frozen, you send all the memory contents to the designated swap file/partition. Regarding the size of the swap file, it only needs to be big enough to fit the memory that's currently in use. So in a 16GB RAM system with 8GB swap, as long as your used memory is under 8GB, no problem! It will fit. After you've moved all the memory into swap, you can shut down the entire system.

Now here's the problem with how shitstaind handled this... It's blatantly obvious that hibernation is an extension of suspend (sometimes called S3, see e.g. https://wiki.ubuntu.com/Kernel/...) and that therefore the hibernation shouldn't have been possible either. The pinnacle of init systems.. can't even suspend a system, yet it can hibernate it. Shitstaind sure works in mysterious ways!

On Windows people would say it's a hardware issue though, so let's talk a bit about that clusterfuck too. And I'll even give you a life hack that saves 30GB of storage on your Windows system!

Now I use Windows 7 only, next to my Linux systems. Reason for it is it's the least fucked up version of Windows in my opinion, and while it's falling apart in terms of web browsing (not that you should on an EOL system), it's good enough for le games. With that out of the way... So when you install Windows, you'll find that out of the box it uses around 40GB of storage. Fairly substantial, and only ~12GB of it is actually system data. The other 30-ish GB are used by a hibernation file (size of your RAM, in C:\hiberfil.sys) and the page file (C:\pagefile.sys, and a little less than your total RAM.. don't ask me why). Disable both of those and on a 16GB RAM system, you'll save around 30GB storage. You can thank me later.

What I find strange though is that aside from this obscene amount of consumed storage, is that the pagefile and hibernation file are handled differently. In Linux both of those are handled by the swap, and it's easy to see why. Both are enabled by the concept of virtual memory. When hibernating, the "real" memory locations are simply being changed to those within swap. And what is the pagefile? Yep.. virtual memory. It's one thing to take an obscene amount of storage, but only Windows would go the extra mile and do it twice. Must be a hardware issue as well.

Oh, and swappiness. This is a concept that many Linux users seem to misunderstand. Intuitively you'd think that the swappiness determines what percentage of memory it takes for the kernel to start swapping, but this is not true. Instead, it's a ratio of sorts that the kernel uses when determining how important the memory and swap are. Each bit of memory has a chance to be put into either depending on the likelihood of it being used soon after, and with the swappiness you're tuning this likelihood to be either in favor of memory or swap. This is why a swappiness of 60 is default most of the time, because both are roughly equally important, and swap being on disk is already taken into account. When your system is swapping only and exactly the memory that's unlikely to be used again, you know you've succeeded. And even on large memory systems, having some swap is usually not a bad idea. Although I'd definitely recommend putting it on SSD in a partition, so that there's no filesystem overhead and so that it's still sufficiently fast, even when several GB of memory are being dumped in.

  • 4
    And here endeth the brain dump. God bless systemd for making it happen I guess, pinnacle of init systems indeed!
  • 2
    As for the swap, it used to be that a swap partition was much faster, but that isn't the case anymore. It's just less flexible than a swap file, and you may have to re-partition if you fit more RAM into your computer.

    Also, reducing the swappiness makes sense for desktop (and laptop), 60 is too high. What you want isn't just raw performance or throughput, but responsiveness. If a task takes 10% longer because there's e.g. less caching (because program code isn't swapped!), but the GUI doesn't lag, that's usually the better choice for desktop and laptop usage.

    I also have to question the advantage of hibernation, given that just booting from SSD doesn't take long anyway, at least under Linux.
  • 3
    @Fast-Nop good points! As far as hibernation goes, for me personally it wouldn't really be that it's faster to boot.. usually it's slower than cold boot, due to the sheer amount of data that has to be transferred. Mostly it's the idea of being able to continue where I left off. My command line work is on a container elsewhere that I just SSH into (also helps with maintaining a shared environment across multiple workstations). But some work is also done directly on the workstations, which is where hibernation comes in. But of course suspend can also do that (assuming that the system can actually do it of course).. so yeah, with the amount of storage required to enable hibernation... It's becoming less and less important.
  • 1
    Any idea if that 30Gb hack works for Win 10?

    Cause thats awesome and I have 16Gb of RAM.
  • 1
    @Entity-01000101 You can always try! I've used these tutorials for Windows 7: https://appuals.com/enable-disable-... and https://howtogeek.com/126430/.... See if the files exist on Windows 10 and how large they are - if so, they can be deleted. The page file is for the virtual memory component (effectively the swapping part of swap), and the hibernation file is for hibernation (well.. the "send memory dump for hibernation" part of swap). After disabling it, of course hibernation becomes unavailable, so only disable it if you don't need it.
  • 1
    Nice! ill give it a shot, I dont ever use sleeep or hiber so, Ill take the space!
Add Comment