Skip to content
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 FSEvents-based watcher on macOS #10098

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

satotake
Copy link
Contributor

@satotake satotake commented Jul 17, 2022

On macOS, fsnotify uses kqueue internally.
This causes some long-lasting issues (#8594, #6109) though we have the workaround for them.

This PR tries to resolve these issues by using FSEvents instead of kqueue.

After applying it, we can use --enableFSEvents flag like so

hugo server --enableFSEvents

There are some considerations.

  • fsnotify/fsevents might not be stable yet
  • we have to enable CGO if we would apply this as @nathany and @bep pointed.
  • Related tests look passed but we have to wait for a while just before adding targets to watch.
    • Otherwise, delayed past events are sent.
    • update: fixed

ref: https://discourse.gohugo.io/t/fsevents-for-watching-on-macos/39053/4

@bep
Copy link
Member

bep commented Jul 18, 2022

Thanks for this.

I will add some comment, but please don't spend time on adjusting your PR until we decide what to do. I have not tested this myself, but I'm assuming that FSEvents is significantly better, and I'm always a fan of that.

Somme comments:

  • When we add this, it should be on for all. --enableFSEvents is a flag I don't want to explain to people. I suspect that we should get this one battle tested pretty fast, considering there are lots of active MacOS Hugo users out there. If it happens to be a bug for someone, I suggest they fall back to polling.
  • This needs to be in the extended build tag (to get CGO_ENABLED=1), which would require a small refactor of your

I will look closer at this later.

@satotake
Copy link
Contributor Author

please don't spend time on adjusting your PR until we decide what to do.

ok. I will do so.

@nathany
Copy link
Contributor

nathany commented Jul 23, 2022

@arp242 You may want to be aware of this work going on in Hugo.

On macOS, `fsnotify` uses `kqueue` internally.
This causes some long-lasting issues (gohugoio#8594, gohugoio#6109)
though we have the workaround for them.

This PR tries to resolve these issues by using `FSEvents` instead of `kqueue`.

ref https://discourse.gohugo.io/t/fsevents-for-watching-on-macos/39053/4

Use FSEventsWatcher as default on darwin

* eventwatcher_darwin.go
  * NewEventWather returns fsEventWatehr

* eventwatcher_other.go
  * NewEventWather returns fsNotifyWatcher
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants