Addressing The Outmoded Swapping And Paging Strategy in OSX
dropsafe.crypticide.com
dropsafe.crypticide.com
Paging is fucked in OS X, but this isn't why.
He focuses entirely on its use of swap files, which is not a problem at all, especially since the middle of the 10.5 betas. Before that, the system would only allocate new swap files and never do compaction or reclamation, so if your filesystem was normally within 10G of being full, it could page its way into filling it, and grind into a performance hell orders of magnitude worse than what he's complaining about (for years I had to reboot every 100 days or so to reclaim swap). Insisting on using fixed swap partitions made sense twenty years ago, but it sure as hell doesn't today as long as you do GC.
Paging on OS X is much higher latency than any other modern unix, but the fault lies with how VM works in the guts of Mach, not some userland configuration trivialities. Chapter 8 of Amit Singh's Mac OS X Internals has details of the implementation but doesn't go too far into why it sucks.
Smart Geeks intelligently exploring and debating things like this is a win for any OS.
The main advantage of using fixed swap partitions is that you don't have to go through the file system to access swap. This is why swap files used to be slower on Linux with the 2.4 series of kernels -- with 2.6 and swap files, the kernel builds a map to the LBA at startup for direct physical access, so there's no performance difference any more. Shame on Linux distros that still use swap partitions in 2010.
Windows does the same, which is why Windows doesn't need (and has never supported) swap partitions, either.
However, this sort of map implies that while increasing swap size is easy, reducing the size of swap files is really difficult while the system is online, which is why Windows (and I believe Linux) don't attempt to solve this problem.
You create another new swapfile, turn it on, and then turn off the old one. The VM will copy all the old pages still in use in the old file and distribute them among the highest-priority enabled swaps with free space by round-robin. If you create the new swapfile sparsely, you don't even chew much disk space.
I discovered something hilarious in Linux's OOM-killer a while back. It has a bunch of heuristics for picking what process to kill next to save the rest: the very first one is "are any processes blocked in the swapoff syscall?"
But seriously, I find it strange that so many people in the comments section are complaining about how much swap Firefox uses. Don't they have machines with more than 128M of RAM!? (My Firefox is using 131M of RAM right now.)
I also get lots of slow-downs when closing apps - exacerbated by the fact that I swapped my MBP's hard drive for a 5'400rpm, bigger one, which means disk IO is even slower. Anything that reduces disk IO would be welcome.
The problem isn't that the 5400rpm drive is 'slower', but that the average latency is higher (though only by about 1.5x) -- it likely has higher streaming bandwidth simply by virtue of greater areal density.
i wonder what the effect would be if you simply increase the paging size, as he describes, without creating the separate partition. this solution might be more appropriate for those of us who simply want to avoid the beachball-of-death, and aren't to hung up on speed.
http://downforeveryoneorjustme.com/http://dropsafe.crypticid...
It's just you. Maybe try again in a few?