-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add kqueue backend to avoid event types weirdness from hfsevents on OS X #36
Comments
Do you want to open this issue up at: https://github.com/luite/hfsevents |
Well, I'm pretty sure @luite is faithfully reproducing the information that the FSEvents API gives. I looked at the code and it's just yanking this info right out of the data structure the OS provides. The question is just how to better map it to the abstractions in this library. |
ahh, ok. I think there is already some trickiness with mapping what happens in Windows. |
yep i don't think this is an |
I offered a bounty for a similar issue at StackOverflow, but no-one seems to know what to do about it. So my plan is the this: use fsevents only as a trigger, and use the logic already used in the polling to compute the actual events. That logic will be factored out of What do others think? |
seems like it is worth a shot :) One thing we can always look to is what the libraries in other languages do. Some of those are also buggy though :) |
Any specific suggestions? I'm not familiar with the Mac OS X ecosystem. |
rb-fsevent doesn't support file events at all |
Seems that you are referring to this, which has a lot of info on OS X limitations: So yeah, we should not try to listen to files, only directories. |
I was referring to their README:
|
It's been suggested that we use kqueue instead. This is interesting both because it probably avoids this bug, but also because we get support for BSDs this way, too. There's already bindings for Haskell by @hesselink http://hackage.haskell.org/package/kqueue |
That is a good suggestion, although kqueue has its own issues. It is probably best to keep both backends and make it possible for users to choose one. I usually just monitor directories with infrequent changes so fsevents works for me. |
What issues does kqueue have? This issue has nothing to do with frequency of changes. The reported events are simply wrong. |
In general my understanding is that kqueue works well to monitor a file, but there are issues to figure out with renames and watching directories. Perhaps a hybrid approach is actually best: node apparently switched to using fsevents for watching directories: http://blog.nodejs.org/2012/09/17/node-v0-9-2-unstable/ |
From your links it looks like the opposite: watching directories (for renames, creation and removal) works fine, but it doesn't detect actual file changes inside the directory. (Well, watching individual files probably works too.) Still, you're right in that this doesn't do what we need, sadly. |
In the kqueue package I have a module |
@hesselink do you know if it scales/performs well? |
No , sadly I don't. I think that some system limits like the maximum number of open files could become a problem, but that should probably be tested. |
Did you mean to export |
@feuerbach It seems I misremembered. The |
OS X's FSEvents API has some odd behavior which I still don't entirely understand. It often provides several flags for each event. For example (output produced using
trace
fromhfsevents
), if I do this:I get this log output:
Take a look at the flags for the second entry.
Consider also this command:
Which yields this log:
Notice the fact that each event contains flags from other recent events. This explains the anomalies I've seen regarding the types of events generated by System.FSEvents on OS X. (I ended up just ignoring the event type totally for now.) There definitely needs to be a change to how System.FSEvents decides what type of event to generate. It seems impossible to do this correctly in a stateless fashion, which is unfortunate. (Though one option is just to generate duplicate events and give the user of the library the responsibility to deduplicate them if they need to.)
The text was updated successfully, but these errors were encountered: