Watcher

Dev tools

file watcher library

SHOW HN2022

91points
73comments
#652of 2,570 in 2022
Top 26%of 2022 by points

How HN took it

CuriousMostly questions and neutral comments

1 positive, 20 neutral or asking, 1 mixed, 9 critical, out of 31 comments about the project. Thread score -0.24.

Idea: 0 for, 5 againstPerformance: 0 for, 3 againstExecution: 0 for, 1 against

The thread, comment by comment

Each row is a top-level comment and its replies, in HN's order. Select a cell to open that comment on HN.

positive neutral or mixed critical about another commenter or something else the maker

What HN said

What people liked

  • Useful for fast feedback loops and file watching in general

    From 1 comment
    • I don't know about efficient, but at least it sounds reliable. I'm at my wit's end with trying to figure out why KDE's Dolphin can't reliably watch a directory for new files,…
      MichaelCollins on HN

Objections

  • Efficiency claims are unsubstantiated; the Windows implementation scans directories periodically

    From 3 comments
    • Looking at Win32, it scans the whole directory periodically, right? I must miss something, but how can that be called efficient?
      mikulas_florek on HN
    • I only mentioned Win32. There this library is very inefficient compared to ReadDirectoryChangesW, which consumes no CPU times when nothing changes.
      mikulas_florek on HN
    • "Watcher is extremely efficient. In most cases, even when scanning millions of paths, this library uses a near-zero amount of resources." Yea, maybe or maybe not and my first…
      dyerjohn on HN
  • Event accuracy is not guaranteed; platform backends are incomplete

    From 2 comments
    • It’s difficult to get it perfectly right. There is ongoing work attempting to make it more perfect. I expect a year or two before this is complete. For now though, it does do…
      e-dant on HN
    • More technically, here’s what we have: A “baseline” filesystem watcher which uses only the standard library. It has been made to beat kqueue. And it does. A platform filesystem…
      e-dant on HN

Requests

  • Document how it achieves low resource use in the readme

    From 2 comments
    • "Watcher is extremely efficient. In most cases, even when scanning millions of paths, this library uses a near-zero amount of resources." Yea, maybe or maybe not and my first…
      dyerjohn on HN
    • You are right. I’ll make sure to give a deeper breakdown in the readme.
      e-dant on HN
  • Use native Windows APIs such as ReadDirectoryChangesW

    From 2 comments
    • I only mentioned Win32. There this library is very inefficient compared to ReadDirectoryChangesW, which consumes no CPU times when nothing changes.
      mikulas_florek on HN
    • All are supported. Although, to be more efficient, I need to write system API calls for Windows. That will be the 1.0 release.
      e-dant on HN
  • Handle atomic overwrite by move

    From 2 comments
    • Does it keep working when files get overwritten by moving another over it, like some Linux text editors do?
      remram on HN
    • This was a case that tripped me up when using Qt's QFileSystemWatcher. Many apps implement "atomic updates" to files by writing out to a new file (e.g. foo.txt.temp), then moving…
      sgerenser on HN

Questions

  • How does it work under the hood on Linux, is it inotify?

    From 2 comments
    • How does this work under the covers on Linux? Is it using eBPF, or is it simply an abstraction over inotify? I'm particularly interested in something like this, but which will…
      GordonS on HN
    • >or is it simply an abstraction over inotify? Looks like it:…
      bertman on HN
  • Does it work over NFS or SMB?

    From 1 comment

Alternatives named

  • watchexec

    From 1 comment
    • See also: sane - for node watchexec - rust based, static binary
      awestroke on HN
  • fswatch

    From 1 comment
    • Well, I am not too lazy to search but I was interested in your experience, especially with reliability. This one looks interesting: https://github.com/emcrisostomo/fswatch
      POPOSYS on HN
  • sane

    From 1 comment
    • See also: sane - for node watchexec - rust based, static binary
      awestroke on HN
  • systemd path units and inotifywait

    From 1 comment
    • Is this just using inotify on Linux? If so, there are equivalent options, including systemd path units, incron, and the inotifywait utility, in addition to the C API. The "man…
      chasil on HN

Category, keywords, summaries and labels on this page were made by AI (Thread Reader v2) and not checked by hand. Each point links to the comments it came from.

Add a badge to your READMEShown on HackerShow
[![Shown on HackerShow](https://hackershow.org/badge.svg)](https://hackershow.org/show/33247155)