What is a reasonable amount of inotify watches with Linux?

Tim Post picture Tim Post · Feb 11, 2009 · Viewed 50.1k times · Source

I am working on a daemon that monitors file events via inotify to trigger various types of events when files are accessed. I have read that watches are a little expensive, because the Kernel is storing the full path name of every file being watched.

How many watches would be too many?

Edit: Mostly, I'm wondering .. have you ever seen a noticeable performance hit, if so, at how many watches did it happen? Yes, I have to monitor / recursively (however its a minimal bootstrapped system).

Answer

axkibe picture axkibe · Aug 17, 2011

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.