8000 use `watch-project` rather than deprecated `watch` · Issue #389 · wincent/command-t · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content
use watch-project rather than deprecated watch #389
Closed
@mr-salty

Description

@mr-salty

watch is deprecated per the watchman docs: https://facebook.github.io/watchman/docs/cmd/watch.html
it should be replaced with watch-project: https://facebook.github.io/watchman/docs/cmd/watch-project.html

The latter has the big advantage of not creating redundant watches for subdirectories. When I looked at watchman watch-list on my machine I had ~20 watches, all of which were subdirectories of my home directory. The daemon was using ~1.6GB of memory (I have about 1.5M files in my homedir).

I did watchman watch-del-all, killed the daemon, then did watchman watch-project $HOME, the current memory usage is 571MB.

The downside is you have to change how you do queries, you have to supply the "real" root returned from watch-project and put the subdirectory in the expression. It seems to me that watchman could easily split the path itself to allow existing queries to continue to work.

So, for instance:

$ watchman watch-project $HOME
{
    "version": "2022.06.13.00",
    "watch": "/Users/todd",
    "watcher": "fsevents"
}

$ watchman watch-project $HOME/subdir
{
    "version": "2022.06.13.00",
    "relative_path": "subdir",
    "watch": "/Users/todd",
    "watcher": "fsevents"
}

then, instead of using this query: ["query", "/Users/todd/subdir", { "expression": ["type", "f"], "fields": ["name"]}]
we have to do ["query", "/Users/todd", { "expression": ["allof", ["dirname", "subdir"], ["type", "f"]], "fields": ["name"]}]
and, annoyingly, strip subdir/ from the results.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      0