What is a reasonable amount of inotify watches with Linux?
Solution 1:
AFAIK the kernel isn't storing the pathname, but the inode. Nevertheless, there are 540 bytes per Watch on a 32bit system. Double as much on 64bit.
I know from Lsyncd (maybe you want to check that out?) people who have a million watches. It just eats a Gigabyte of memory.
Solution 2:
You can find the system limits by reading /proc/sys/fs/inotify/max_user_instances
(maximum number of inotify "objects") and /proc/sys/fs/inotify/max_user_watches
(maximum number of files watched), so if you exceed those numbers, it's too many ;-) The maximum number of watches is usually several tens of thousands or higher - on my system, 262143 - which is probably more than you'd ever need unless you're trying to watch every file in a file system, but you shouldn't be doing that. I would say, just try not to use more inotify watches than you need to, and don't worry about it unless you notice a significant decrease in performance.