I am developing software that will utilize inotify to track changes on a large amount of files (tens to hundreds of thousands of files). I have come up with these ideas:
- one watch per file
- one watch per parent directory
- avoid inotify and periodically scan the fs for changes (not preferred)
I will have a database of all of the files I am watching and some basic stat information (like mtime and size), however, I would have to stat each file in that directory until I found the one that changed.
Which would be faster, tons (100,000+) of inotify watches or tons of stat calls?
I'm thinking that reducing the number of stat calls would be better, but I don't know enough about inotify.
Note:
This will be running on a workstation, not a server. It's main purpose is to synchronize changes (potentially to an entire filesystem) between a client and a remote server.