-
-
Notifications
You must be signed in to change notification settings - Fork 586
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
Network drives on win32: 24x slower #665
Comments
I tested with one of the folders trees I really intended to use. It has 2370 entries.
That means the 24x slower is apparently consistent. It doesn't appear to be a function to the number of folders, depth, or, entries for example. While I can pre-scan with readdir myself I'm a little conserned that chokidar won't notice changes for 22 minutes into my app though. Any ideas what might be causing the issue? |
Chokidar isn't just scanning the files, it's setting file watchers as it goes. Stat polling is very CPU-intensive. Trying to watch a huge directory across a network share is the source of your performance concern. If you just need the scan and not the watching then don't use chokidar. It is not likely that you'll find a significant performance boost for this situation just by optimizing code, but please send a PR if you do. You could do things like run your program on the system where the files are in order to get off of polling. |
It seems kind of sad to me you closed this ticket. Isn't this an issue people should be aware of they can look for solutions? Checking on Mac to the same share with |
You claimed the issue is chokidar is CPU intensive. Watching the CPU on my test above I see no evidence of this. It never goes above 3% |
There's something missing from the info you're providing. If you actually ran with the typo you showed here ( |
The code in question is exactly as pasted above. (the typo was only in my last message not in any code I've been running) On Mac it's exactly as pasted above except with
So to be clear, chokidar on mac to smb network share - fast cpu usage low There are also other tools for windows that scan and keep track of network changes on Windows fast. Since you've already got a custom native plugin for Mac for FsEvents it seems like something similar for Windows is probably the way forward. Either that or visiting libuw to figure out why node is so slow here. |
Ok, I'll go ahead and reopen the issue. Take a look at #410 and #412, although the end result seemed to be a solution to managing system resources during the scan, not an overall time reduction to the Can you set up a test for walk-filtered vs readdirp in your environment to see how they fare against each other? |
I tried walk-filtered and it took 3-4 seconds in the same setup. I have a feeling I'm just going to run into all the problems previous adventurers have run into 😅. I compiled libuv last night and setup a test. I see I get notifications for changes on the share but filename info is missing. Trying to find other native examples on Windows to see if I can find a way to make it work but if no one has fixed it previously there's probably a reason 😓. Crossing my fingers 🤞 |
So if walk-filtered is a huge improvement for your setup, have you tried the swapping in the #412 version of chokidar in your original setup? This could help us determine if the problem you've experienced is in readdirp or somewhere in chokidar. |
Sorry just starting to get back into this. What I did notice today is chokidar has issues on Windows even not on shares. I tried to run this small sample code (non-polling) just on one of my local node project folders as in "C:\Users\me\src\myproject" and it failed with
Since chokidar's readme mentioned that VSCode uses it and since VSCode doesn't crash on that folder I thought I'd go see how they are using chokidar. Turns out they only use chokidar on linux and mac but they use their own solutions on Windows For windows they have a C# program they wrote that they spawn that watches a tree and outputs the changes which they read. |
I don't think VSCode uses chokidar. It uses vscode-nsfw |
vscode still uses chokidar. You can see it in the package.json, Here's the top level code for their watcher This code used vscode-nsfw based on a flag, otherwise it uses chokidar for linux/mac and their own custom solution for windows. Maybe they'll remove chokidar and their custom solution in the future |
new readdirp is out now, so this should be improved a lot with chokidar v3 |
Using chokidar 3.0.0 (and readdirp 3.0.1) the problem still happens. My test:
and
got the following results:
Note: The directory used is a symlink to a network drive on my own computer:
Any other thought? |
I think this only happens because you're using a network drive, even though it's locally-bounded. |
That is the entire point of the issue. That chokidar is 24x slower on a network drive than other techniques. Not sure why you closed it. Seems like 24x slower is something that should be fixed rather than ignored. Especially when there is ample evidence there are faster methods. Also pointed out chokidar is just plain buggy on windows and pointed out that that VSCode saw this too and stopped using chokidar on windows. |
I am getting same issue in ubuntu mounted NAS folder. Chokidar don't read any changes in it until I access that folder through bash |
@greggman -- what does VS code use now? |
The watchers are here https://github.com/microsoft/vscode/tree/master/src/vs/platform/files/node/watcher On Windows it uses a C# app which it runs in a separate process and looks at its output https://github.com/microsoft/vscode/tree/master/src/vs/platform/files/node/watcher/win32 |
@greggman have you found any workarounds for this issue? |
I ended up making my own solution using the chokidar on Mac/Linux and the C# program from VSCode on Windows. Unfortunately my solution is not well tested and IMO poorly designed ATM but I haven't had time to deal with it. I would prefer to find a way to add it back into chokidar instead but IIRC the semantics of what comes out of windows are different so , though I don't recall honestly as it's been a couple of years. |
The backlog is going to start from zero as a preparation for v4 release. v4 would bring massive rewrite to the table and drop most dependencies. All issues are being closed as preparation for v4 release. In the future, only issues with enough community support would be considered. See issue 1195 for more info. Thank you. |
I'm trying to use chokidar on Windows Shares and finding it's extremely slow on the initial scan. For a relatively small tree of files (183 entries of directories and files)
takes 3.5 seconds
which gets most of the same stat data takes about the same amount of time where as
Takes 80 seconds until chokidar emits 'ready' or about 24x as long
Those same shares on Mac (same NAS, also smb), same options is fast (3.5 seconds)
I'm wondering if there is some way to speed up the initial scan?
Just doing my own recursive
fs.readdir
with anfs.stat
on every file is only (9.5 seconds) or 8x faster (tho still 3x slower than dir/tree)To see the ready event here is my chokidar test
and here's my readdir test
And here's what the test tree looks like. Note: this is not a typical folder I'm watching it was just something on my NAS that was a reasonable size to test. A typical folder is MUCH deeper with 1000s of files and chokidar takes many many minutes until it gets done with it's initial scan.
Any ideas on how to speed up chokidar? Should it's initial scan do something different? Am I better off doing my own initial scan?
The text was updated successfully, but these errors were encountered: