Curious Case of a 99.9% Latency Hike
mahdytech.com
mahdytech.com
They look at the free memory and think, "wow look at all that free space, I can totally take up half of that no problem".
The moment the collective working set exceeds total memory things go sideways. They learn that the performance of the system tanks when there's not enough space left for OS-level caches and especially for memory mapped files.
However, the MacOS kernel seems to require a much higher amount of wired memory than the Linux kernel for similar workloads, so...
I don't know if those are related, but it'd be interesting to figure out what MacOS does differently (their kernel is open sourced) and to see if that behavior could be adapted into the Linux kernel.
Really? I’ve had the opposite experience. MacOS running out of memory and paging heavily almost always necessitates a reboot to get performance fully restored, even if you kill the memory hog (if you aren’t willing to deal with a sluggish machine for a while that is).
To let you skip the anecdote if you don't care, I'd be very curious if someone can answer _why_ this happens.
Earlier this week I was running into Very Strange errors coming out of some deep libraries in one of my hobby services. Nothing was specifically failing but things were going very slow and vomiting a bit. I observed that I had over 25g of active Ram (Typically idle at ~8g) and some absurd amount of paged data too. Even after killing almost all non-system running processes I was sitting at ~20g total, including a 10g nonpaged pool and 6g process private. On reboot, and for the week since? 8g. (On Win10)
I usually just swapoff and swapon, but I'm sure there's a better way.
The real recovery from this is cleaning virtual mem, and let your program run for a while so that some cache is collected. This may take seconds to hours, depending on your application and vmem size.
It would be nice to language and os your talking about.
Also, to the writer, I think you want to turn off swap?
It will give you the option of swap when OOM would otherwise kill process, but you can decide exactly how much, to prevent swapping from hurting performance -- say have a 10% extra.
Assuming you have a significant number of identical servers, turning off swap should be reserved for after you have done your tuning of the daemons and their memory use, and you are confident nothing will run out (still, you should monitor dmesg) to maximize bang for bugs.
If however you need swap a good old trick- don't put the swap on LVM or RAID. Just have separate partition on each physical device. The kernel will always know to use them in parallel, and you get to squeeze out a bit of extra performance
Using kernel panics as an alerting mechanism is a brutal solution.
Why not track page faults? Most orgs that I interact with track paging across the whole fleet.
Turning off swapping has been a heated discussion, and I am on the negative side of it. Swapping is good; not all memory is important and some of it should not occupy precious physical space. Not all processes are important though. What I would rather have is a per-process swapping flag, allowing me to disable swapping for one or two essential processes, but swap the rest.