Hacker News new | ask | show | jobs
by andrewguy9 3583 days ago
I always get anxiety when I read about these tools. In Windows, the kernel drops file update notifications all the time. There is a fixed sized buffer for them and overflows do happen.

I've not read the Linux code for them, but I think the implementation is probably similar.

This is not something I'd like to rely on.

1 comments

I keep hearing this repeated, but when I've ran tests on this in the past (ReadDirectoryChangesW is the name of the function, if I recall correctly) it was actually quite difficult to lose messages.
For normal user behavior you will rarely encounter a problem. But build systems tend to update/create files very quickly. If there was a workload which would break ReadDirectoryChanges, it would be this one.

Reading the code for Realize, he gets the directory watching facilities from https://github.com/fsnotify/fsnotify. That library seems to drop the 'buffer overflow, please reset your assumptions' message. So if it did happen, I don't think the user would have a good experience.

If you do ever depend on ReadDirectoryChanges, you do need to fallback to stat-ing files if you get an overflow. Otherwise, your milage may vary.