I've been running Linux for 15 years and am stuck. Help!

On Ubuntu Desktop, sometimes (usually after a few minutes - sometimes not at all until reboot) all file write operations seem to hang, while opening files is not a problem. Can't kill processes, they just go <defunct>. Extremely slow drawing of windows.

What's going on here? Memory and CPU look good. Open files are not crazy... io load is very low. Not virtualized.

Any ideas?

@_lennart

Two guesses:

First guess: nofiles ulimit is probably too low.

ulimit -a will show you what they're set to, for some insane reason some distros set this to like 1024. The idea being that a user shouldn't have more than 1024 open files.

IME on a few systems, snap has exacerbated this because of the way snap does things.

You can set this via/etc/security/limits.conf:

@usergroup hard nofile 16384
@usergroup soft nofile 8192

Then sysctl -p to reload them, then see if it happens again. :)

Second guess: Something is actually locking disk access for some reason (long syncs), which you can look at this using something like iostat or iotop are options.

@fennix @_lennart

This is an excellent point! I wouldn't have thought of this as a possibility and it might explain some similar issues I've been frustrated with for a long time.

However, this change doesn't effect a graphical user login. You'd have to do an su - <user> and then the new limit would apply.

I confirmed this by doing the ulimit -a after logging in and seeing the 1024 limit, and then after doing the su to my user, only then I saw the limit increased.

To make the change as well for graphical user login, modify both /etc/systemd/user.conf and /etc/systemd/system.conf by adding the following line:

DefaultLimitNOFILE=16384

At least, this is my understanding

@Jerry @_lennart oh because of course systemd does its own thing... 🤦‍♂️