I use an application that consumes inotify watches. I've already set
fs.inotify.max_user_watches=32768
in /etc/sysctl.conf
but last night the application stopped indexing unless I ran it manually, which leads me to suspect I am out of watches.
Since I don't know what the trade off is when I increase this number (does it consume more RAM?), I don't know if I should just increase this number, so I'd like to know if there's a way I can tell if it's using all these watches and what the tradeoffs might be for increasing it.
How do you know if you are out of watches? tail will tell!
tail
with the-f
(follow) option on any old file, e.g.tail -f /var/log/dmesg
:For the curious: Why is tail a "telltail"?
strace tail -f ...
instead, and when it succeeds, it ends with:Can you increase the watches? By how much? Any tradeoffs?
Short answer: Sure, no sweat. Go to straight to a half-million (524288) if you want...the additional memory used should be negligible on a modern system with 4GB+ of memory.
So, assuming you set the max at 524288, and all were used (improbable), you'd be using approx. 256MB/512MB of 32-bit/64-bit kernel memory
What's the max value? I guess none, in theory, as long as you have enough RAM. In practice, 524288 has been officially recommended by apps, and people have been setting it to 2 million, with the accompanying memory usage, of course.
I don't know if I should just increase this number
The easy way of checking if you reached your
max_user_watches
value is, with your user, to useinotifywatch
, from the packageinotify-tools
, and check if you can still collect information from a file.For example
inotifywatch -v /home/bruno/.profile
for me returns:So
inotify
has no issues creating a new watch, no issues here.If you have reached your maximum limit in inotify watches it will return something like
If you see something like this then you have reached the limit and will need to increase the allowed watches limit.
Does it consume more RAM?
Yes, it does. But according to this old article the amount it consumes is minimal compared with other aspects of a running desktop.
I am of course assuming things did not change a lot since the article was written but looking at the numbers I would not worry and increasing the limit will not increase RAM consumption by much.
Related posts about
inotify
Dropbox error - 'echo 100000 | sudo tee / proc/sys/fs/inotify/max_user_watches'
kernel-inotify-watch-limit-reached