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
watchexec takes 8s to start, does 2M syscalls across 148 threads #377
Comments
That's Known Issue Number 2! You can work around for now with |
Oops, sorry I missed that! Thanks for the tip, The excessive context switching via futex operations might be worth looking into as an optimization opportunity -- it seems to me that even without behavioral changes, some time could probably be saved there. But feel free to close this if you prefer. |
That's true, yes, we could likely get much better performance by optimising where file I/O happens. I'll have a specific look at this. |
@passcod is .gitignore parsing currently a depth-first search, when it should be breadth-first starting at the root for project origin detection, and then recursively applying ignore files in descent? Ignore files only apply to their subtrees, yet after installing an NPM package, I see traces like the following:
If ignore files follow the
This seems like it would be possible for me to make a contribution here. The product I work on, Pulumi, recently shipped a a change to embed |
Yes, that's absolutely the case (well, kind of, it's complicated, there's actually two layers of figuring out ignore files and that's where the issues arise; happy to chat if you want to know more). I'd love a contribution! The work would be in the ignore-files crate and filterer, which get used in the relevant places in watchexec. |
I have a similar issue with I did use |
Aside from any other possible optimisations, shouldn't it be fairly trivial to make watchexec skip looking for ignore files if all of |
Yes. That would be a conditional around here, if you want to PR this: https://github.com/watchexec/watchexec/blob/main/crates/cli/src/filterer/globset.rs#L23 |
I also ran into this (very significant) problem
|
It seems "scanning and watching the entire filesystem for files that could slightly modify the behavior of the program" is more anti-feature than feature for a small utility like this. |
While not fully fixed, 1.23 is more clever around this, and you can use |
While a more thorough fix would be great, |
Hey @kentonv a fix for this issue made it into |
I've measured a bit myself and it's not really fixed, though your improvements did help. However, one larger issue than the ignores, which I hadn't twigged on until I started measuring in earnest, is the notify watches, which are recursed by notify and not by us. For example looking at watchexec with It turns out that this particular issue here is an onion of causes adding up to a large negative effect, rather than a single buggy layer to be fixed! |
Ahh thanks for checking this -- sad that this issue isn't fixed completely, but thanks for linking to the explanation/your thoughts on it! |
I'm using watchexec 1.20.5 on Linux. It works great! Except for one thing...
I have a directory structure like this:
When I run
watchexec
I do it like this:watchexec
spends about 8 seconds scanning through the entirety ofdeps
. The-vvvv
log, which is 528 megabytes long, suggests it is looking for "ignore files". The various--no-*-ignore
options don't seem to change anything.During this time, according to
strace
,watchexec
apparently creates 148 threads which perform 2,458,067 system calls, of which 2,337,801 are futex operations. It also stat()s 44,270 files and opens 14,634 of them. After all that, it sets up 26 inotify watches.Could
watchexec
be made to scan only the directory I asked it to watch?The text was updated successfully, but these errors were encountered: