Skip to content
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

File watcher maxes CPU when folder contains symlink loop #4818

Open
drkvogel opened this issue Apr 5, 2021 · 4 comments
Open

File watcher maxes CPU when folder contains symlink loop #4818

drkvogel opened this issue Apr 5, 2021 · 4 comments
Labels
remote Issues in the code server support

Comments

@drkvogel
Copy link

drkvogel commented Apr 5, 2021

Following instructions from https://stackoverflow.com/a/48214059/535071, I profiled a rogue bootstrap-fork --type=watcherService and recorded a CPU profile: CPU-20210331T105942.zip

The top 8 rows by CPU time:

Self Time   Total Time  File
9,064.72ms  9,064.72ms  _addPathCloser /home/kvogel/.vscode-server/bin/2b9aebd5354a3629c3aba0a5f5df49f43d6689f8/node_modules/chokidar/index.js:922
591.25ms    591.25ms    (garbage collector)
92.40ms     92.40ms     (program)
73.56ms     73.56ms     lstat
27.94ms     35.31ms     resolve path.js:972
19.97ms     69.24ms     LOOP fs.js:1723
19.86ms     19.86ms     FSReqCallback
17.34ms     17.34ms     stat

chokidar - npm
paulmillr/chokidar: Minimal and efficient cross-platform file watching library

Originally posted by @drkvogel in #3126 (comment)

@drkvogel
Copy link
Author

drkvogel commented Apr 5, 2021

Turns out I have symlink directory loop in one of the folders I was connecting to with "Remote - WSL":

❯ file ../pz/legacy/sites/1/htdocs/shared/pz
../pz/legacy/sites/1/htdocs/shared/pz: symbolic link to ../../../

and when I click "Reconnect" after getting the "Cannot Reconnect" dialog after resuming from hibernation, I get several bootstrap-fork --type=watcherService processes which max out the CPU and that I have to kill off.

(Full path: /home/user/.vscode-server/bin/2b9aebd5354a3629c3aba0a5f5df49f43d6689f8/node /home/user/.vscode-server/bin/2b9aebd5354a3629c3aba0a5f5df49f43d6689f8/out/bootstrap-fork --type=watcherService)

I attached a debugger to one of these processes, and in devtools, file: VM path.js, Local variables, found something like:

path: /home/user/projects/myproject/pz/legacy/sites/1/htdocs/shared/includes/sites/shared/includes/sites/shared/includes/sites/shared/includes/sites/shared/includes/sites/shared/includes/sites/shared/includes/sites/shared/includes/sites/shared/includes/sites/shared/includes/js/colorbox/

which would seem to indicate that a symlink directory loop is being followed infinitely. Certainly, this doesn't happen on any other folder/repo/project.

@drkvogel
Copy link
Author

drkvogel commented Apr 6, 2021

Also, shouldn't files that are excluded from search be excluded by the file watcher?
In my project, Search, "files to exclude" included ./pz which contained the offending symlink loop.

@aeschli
Copy link
Contributor

aeschli commented Apr 6, 2021

@bpasero FYI, also see question #4818 (comment)

@bpasero
Copy link
Member

bpasero commented Apr 6, 2021

If one of our watchers fails over circular symbolic links, I suggest to report this as issue to the watcher in use. I am not sure which watcher we end up using in remote setups.

If a watcher fails to exclude a directory, even though indicated by settings, please file an issue in https://github.com/Microsoft/vscode/ with clear steps how to reproduce. Note that if NSFW watcher is used, we do not support excludes (see microsoft/vscode#40898)

@chrmarti chrmarti added the remote Issues in the code server support label Apr 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
remote Issues in the code server support
Projects
None yet
Development

No branches or pull requests

4 participants