Watch for Changes

Is Watch for Changes reliable (on Windows)? I.e., should I set rescan interval to a low value (e.g. to 1h) even when Watch for Changes is on? In what situation could Watch for Changes fail to notice a change (on Windows)?

Reason: On my notebook I’ve got a folder with 16000 files and 50GB (and another folder with 250000 files and 25GB), and rescanning it every hour takes a lot of time, CPU and battery power.

It depends on how frequently and how much it changes.

Watching might drop events if there are a big influx of events in a short period of time, because they are buffered and the buffer has limit on size.

If it’s some sort of cold storage data that you don’t need to access immediately, then probably normal scanning is good enough, you might not need watching. If you want to modify the file and see it on the other side fairly quickly, then you want watching, but that doesn’t guarantee the behaviour if you suddently rename or modify 500k files in one go.

That’s what I needed to know. Thank you.

If you mean on the golang side of things, that’s not the case: It can theoretically happen that the buffer overflows, but we detect that and schedule a full scan in that case. I don’t know what the windows side of things does exactly.

Last but not least, ReadDirectoryChangesW uses a fixed-size buffer for each directory handle internally and will flush all change records before they get handled if it cannot keep up with the number of events. In other words, its internal buffer does not function as a ring, and cannot be trusted to degrade gradually or gracefully in the presence of lots of high I/O loads.

I believe the same is true for inotify/kqueue.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.