March 28, 2026
File fights on macOS
Detecting file changes on macOS with kqueue
Tiny Mac tool sparks big debate: speed vs scale, kqueue vs FSEvents
TLDR: A dev shows how to detect file changes on macOS using kqueue and wires it into a tiny reload tool. Commenters split between loving the simplicity, pushing Apple’s folder-level FSEvents for scale, and demanding speed benchmarks—while others praise BSD portability and drop alternative tools for comparison.
A solo dev showed how to make macOS notice file changes using kqueue—basically the system’s built‑in “hey, this file changed” buzzer—and plugged it into a tiny Go tool called reload. Simple idea, clean write‑up, and the crowd went wild. One camp cheered the craftsmanship ("small projects FTW!") and dropped tips like the minimalist entr. Another camp instantly raised the red flag: kqueue watches files one by one, which can melt your brain (and file descriptors) on giant folders. “Use Apple’s folder‑level thing instead”—that’s FSEvents, a higher‑level system that tracks whole directories.
Then the speed demons crashed in: benchmarks or it didn’t happen. One user demanded timing numbers from change to rerun—“I bet it’s super fast.” Meanwhile, portability warriors flexed: kqueue isn’t just macOS—it’s big across the BSD family too, with OpenBSD docs getting shout‑outs like they’re Michelin‑starred. And in true internet fashion, a commenter dropped their own watcher and even an eBPF experiment for the Linux-curious here.
The vibe? Cozy tool, spicy thread. Fans love the “just works” workflow; skeptics warn it won’t scale to massive projects; performance hawks want numbers; and the rest are swapping links like it’s Pokémon cards. It’s DIY energy vs enterprise scale, with a side of nerdy love for good docs and tiny tools.
Key Points
- •The author’s Go tool “reload” reruns commands when files change, watching named files or all files in the working directory.
- •Initially using fsnotify, the article explains macOS’s underlying mechanism: kqueue for file change notifications.
- •kqueue uses kevent structures with fields ident, filter, flags, fflags, and udata to register and read events.
- •For file changes, EVFILT_VNODE with NOTE_WRITE is used, along with EV_ADD and EV_CLEAR to manage event registration and resetting.
- •Multiple writes to a single file are collapsed into one event; files are opened with O_EVTONLY for event-only monitoring.