-
Notifications
You must be signed in to change notification settings - Fork 317
use watch-project
rather than deprecated watch
#389
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
Comments
Here's a proof of concept I did, it's hacky but it works - I can clean it up and submit it as a PR:
|
We probably should, so as not to break people's set-ups... One hacky way to do it that springs to mind is to scan the output of The other question that comes to mind is whether there is any performance impact from the |
yeah, I was worried about all the extra string data, plus the cost of stripping it, but I found a better option that takes care of that inside watchman - one issue is that says it was introduced in 3.3 whereas |
If watchman is bersion 3.3 or later, use `watch-project` rather than the deprecated `watch`. The main advantage is eliminating redundant nested watches (i.e. where one is a subtree of another), which reduces RAM and CPU usage in the `watchman` daemon and eliminates the indexing delay when invoking Command-T after moving down the directory hierarchy. Although `watch-project` was introduced in 3.1 it is awkward/inefficient to use without the `relative_root` query which was introduced in 3.3. 3.3 was released in June 2015, so most users should have a newer version but backward compatibility with older versions is maintained. Fixes wincent#389 Tested: * Tested the new code under various scenarios by invoking Command-T in my homedir and various subdirectories, as well as other paths (/tmp). * Manually tested the fallback path to `watch`, which is unchanged from existing code. * Tested various version numbers by manually simulating the output of `--version` * If the version number is missing or malformed, it will end up as version 0.0 * test cases: nil, "", "foo.bar", "-5.2", "1", "3.2", 3.3.449", "4", "2022.06.13.00"
If watchman is version 3.3 or later, use `watch-project` rather than the deprecated `watch`. The main advantage is eliminating redundant nested watches (i.e. where one is a subtree of another), which reduces RAM and CPU usage in the `watchman` daemon and eliminates the indexing delay when invoking Command-T after moving down the directory hierarchy. Although `watch-project` was introduced in 3.1 it is awkward/inefficient to use without the `relative_root` query which was introduced in 3.3. 3.3 was released in June 2015, so most users should have a newer version but backward compatibility with older versions is maintained. Fixes: wincent/command-t#389 Tested: * Tested the new code under various scenarios by invoking Command-T in my homedir and various subdirectories, as well as other paths (/tmp). * Manually tested the fallback path to `watch`, which is unchanged from existing code. * Tested various version numbers by manually simulating the output of `--version` * If the version number is missing or malformed, it will end up as version 0.0 * test cases: nil, "", "foo.bar", "-5.2", "1", "3.2", 3.3.449", "4", "2022.06.13.00" See also: - https://facebook.github.io/watchman/docs/cmd/watch.html - https://facebook.github.io/watchman/docs/cmd/watch-project.html Signed-off-by: Greg Hurrell <greg@hurrell.net>
Uh oh!
There was an error while loading. Please reload this page.
watch
is deprecated per the watchman docs: https://facebook.github.io/watchman/docs/cmd/watch.htmlit should be replaced with
watch-project
: https://facebook.github.io/watchman/docs/cmd/watch-project.htmlThe 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 didwatchman 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 theexpression
. It seems to me thatwatchman
could easily split the path itself to allow existing queries to continue to work.So, for instance:
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.The text was updated successfully, but these errors were encountered: