I'm trying to track down repetitive hangs on an oldish laptop (10yo, 4Gb of mem, 2 cores, Kubuntu 18.04) It now happens several times a day with moderate use (<10 tabs open in firefox, a bunch of other progs, nothing huge).
Sometimes I get a OOM but in most cases the user interface crawls to a halt for one to 30 minutes before things go back to normal. This is a recent occurrence (last 2 months). In most cases there's nothing in dmesg or syslog.
I've been trying to diagnose it without success, but one thing I've noticed with htop is that the load average jumps to 30 or more while the cumulative CPU usage stays below 10% and the memory usage (Mem+Swap) stays well below 4Gb.
1st question: how can the load average be so different from the CPU usage ? 2nd question: what else can I do? Can I run some stress programs and hope to get meaningful info?
[Edit] Still waiting for the next crash, but I notice that swapiness is at 0. Shouldn't it be 60 by default ?
Question 1: how can the load average be so different from the CPU usage ?
In both Linux and Unix, load averages include pending processes. In linux, as opposed to unix, load averages include I/O waits, such as waiting for disk reads or writes, and pending processes.
Let's use a magnetic disk (long seek time) to demonstrate high load average with low cpu usage, by having several tasks reading random sectors in a large file. The system gets bogged down with I/O waits.
System virtually idle:
But very high load average:
Question 2: what else can I do?
Your symptoms sounds like heavy swapping. You claim low memory use, but I would guess that isn't always true, and you sometimes get into a lot of swapping, and one time you even ran out of memory entirely.
From the comments...
As I suspected, there was a swap problem. In this case, it wasn't swapping at all.
For 4G RAM, set the vm.swappiness to 60 (it was at 0 - which was a totally wrong setting) and there hasn't been a single hang since then.