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

tsserver.js/typingsInstaller.js is watching ignored directories (causing CPU load) #36394

Closed
a1291762 opened this issue Jan 22, 2020 · 8 comments · Fixed by #39243
Closed

tsserver.js/typingsInstaller.js is watching ignored directories (causing CPU load) #36394

a1291762 opened this issue Jan 22, 2020 · 8 comments · Fixed by #39243
Assignees
Labels
Fix Available A PR has been opened for this issue

Comments

@a1291762
Copy link

a1291762 commented Jan 22, 2020

TS Template added by @mjbvz

TypeScript Version: 3.7.3

Search Terms

  • watcher
  • watch

I have Visual Studio Code 1.41.1 on Ubuntu 18.04.
I have an Ember project, that builds into a tmp/ directory.
I have added this to the watch exclude list because it's large and changes regularly (eg. while running tests).

"files.watcherExclude": {
    "**/web-ui/tmp/**": true,
},

I turned on verbose logging for tsserver (after reading many bugs and trying to identify the source of my CPU load). The logs show that changes inside the tmp directory are triggering something, which is probably why the CPU load is so high. Also, once this starts it seems to just loop forever? (or maybe it's just queued up the notifications).

Here's a sample of the part of the log that repeats.

Info 19646[14:51:17.385] DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/funnel-output_path-84OVG1Ct.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19647[14:51:17.385] Elapsed:: 0ms DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/funnel-output_path-84OVG1Ct.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19648[14:51:17.665] DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/funnel-input_base_path-wnOSxgXB.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19649[14:51:17.665] Elapsed:: 0ms DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/funnel-input_base_path-wnOSxgXB.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19650[14:51:17.959] DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/funnel-input_base_path-wnOSxgXB.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19651[14:51:17.959] Elapsed:: 0ms DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/funnel-input_base_path-wnOSxgXB.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19652[14:51:18.305] DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/funnel-input_base_path-wnOSxgXB.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19653[14:51:18.305] Elapsed:: 0ms DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/funnel-input_base_path-wnOSxgXB.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19654[14:51:18.606] DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/broccoli_persistent_filterbabel__babel_ember_concurrency-input_base_path-KfhqeYgr.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19655[14:51:18.606] Elapsed:: 0ms DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/broccoli_persistent_filterbabel__babel_ember_concurrency-input_base_path-KfhqeYgr.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19656[14:51:18.894] DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/broccoli_persistent_filterbabel__babel_ember_concurrency-input_base_path-KfhqeYgr.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19657[14:51:18.894] Elapsed:: 0ms DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/broccoli_persistent_filterbabel__babel_ember_concurrency-input_base_path-KfhqeYgr.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19658[14:51:19.177] DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/broccoli_persistent_filterbabel__babel_ember_text_measurer-output_path-jaXKXveR.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19659[14:51:19.177] Elapsed:: 0ms DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/broccoli_persistent_filterbabel__babel_ember_text_measurer-output_path-jaXKXveR.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19660[14:51:19.489] DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/broccoli_persistent_filterbabel__babel_ember_text_measurer-cache_path-4KZn31rh.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19661[14:51:19.489] Elapsed:: 0ms DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/broccoli_persistent_filterbabel__babel_ember_text_measurer-cache_path-4KZn31rh.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19662[14:51:19.798] DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/broccoli_persistent_filterbabel__babel_ember_text_measurer-input_base_path-I4mIM5US.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations
Info 19663[14:51:19.798] Elapsed:: 0ms DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/broccoli_persistent_filterbabel__babel_ember_text_measurer-input_base_path-I4mIM5US.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /dev/null/inferredProject1* WatchType: Failed Lookup Locations

Is there something else I need to do to stop tsserver from watching this excluded directory?

I can upload the whole log if it helps.

@vscodebot
Copy link

vscodebot bot commented Jan 22, 2020

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@a1291762
Copy link
Author

To the bot: I have read through many bugs about high CPU load for tsserver.js/typingsInstaller.js but none of them seemed relevant to my specific situation (ts server log detecting changes to files that are supposed to be ignored).

Also... I apparently cannot upload logs.

$ code --upload-logs
Option 'upload-logs' is unknown. Ignoring.

I have the snap-based install, which maybe doesn't have that option?

@mjbvz
Copy link
Contributor

mjbvz commented Jan 23, 2020

That TS server's file watcher is separate from files.watcherExclude (which is what VS Code uses internally to update opened files and the list of files in the explorer)

Do you have a tsconfig or jsconfig? Can you try adding that tmp directory to the exclude section of that?

{
	"compilerOptions": {
		...
	},
	"exclude": [
		"**/web-ui/tmp/**"
	]
}
``

@a1291762
Copy link
Author

I failed to get exclude to work :(

I tried various patterns in the "exclude" array to no avail ("/tmp/", "tmp").

Since it's possibly relevant, I open a folder with VSCode: ~/work/git.
I have ~/work/git/web-ui that holds the Javascript (there are many other directories holding other things that are not Javascript)
I created ~/work/git/web-ui/jsconfig.json and VSCode is definitely seeing it.

Info 780  [9:29:50.304] Open files: 
Info 780  [9:29:50.304] 	FileName: /home/lincolnr/work/git/web-ui/tests/acceptance/configure/firewall/zones-aggregate-test.js ProjectRootPath: /home/lincolnr/work/git
Info 780  [9:29:50.304] 		Projects: /home/lincolnr/work/git/web-ui/jsconfig.json

I don't see anything about the exclude property in the tsserver.log, but it still hits files in tmp.

Info 788  [9:33:51.382] DirectoryWatcher:: Triggered with /home/lincolnr/work/git/web-ui/tmp/watch_detector-tmp-IAaV13ai.tmp :: WatchInfo: /home/lincolnr/work/git/web-ui 1 Project: /home/lincolnr/work/git/web-ui/jsconfig.json WatchType: Wild card directory
Info 789  [9:33:51.382] Project: /home/lincolnr/work/git/web-ui/jsconfig.json Detected file add/remove of non supported extension: /home/lincolnr/work/git/web-ui/tmp/watch_detector-tmp-IAaV13ai.tmp

But while reading https://code.visualstudio.com/docs/languages/jsconfig I thought maybe include could work. I only have 4 folders with JS in them after all...

My jsconfig now has this:

"include": [
    "app/**/*",
    "config/*",
    "mirage/**/*",
    "tests/**/*"
]

I still don't see this mentioned in the tsserver.log, but I also don't see the watcher firing on files in tmp!

So I have a "solution" to my problem.

@mjbvz mjbvz transferred this issue from microsoft/vscode Jan 24, 2020
@mjbvz mjbvz removed their assignment Jan 24, 2020
@mjbvz
Copy link
Contributor

mjbvz commented Jan 24, 2020

Moving upstream for TypeScript team's awareness

@sheetalkamat
Copy link
Member

We don't have support to ignore watch directories yet, but #35615 enables us for that. we haven't gotten around to it yet. Note that typescript tries to optimize watches where in instead of watching all failed lookup locations we watch directory corresponding to it or something similar. Since your OS is ubuntu, we are creating recursive watches..

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Feb 26, 2020
@RyanCavanaugh
Copy link
Member

@sheetalkamat what's the follow-up recommendation for this now?

@RyanCavanaugh RyanCavanaugh added this to the TypeScript 3.9.1 milestone Feb 26, 2020
@sheetalkamat
Copy link
Member

For now if the folder for web-ui was one level below i think we would skip watching it but i am not 100% sure if we do it in all places or not (esp when creating recursive directory watching).
Moving this to 4.0 to look into watch ignore pattern specification.

@sheetalkamat sheetalkamat linked a pull request Jun 25, 2020 that will close this issue
@sheetalkamat sheetalkamat added Fix Available A PR has been opened for this issue and removed Needs Investigation This issue needs a team member to investigate its status. labels Jul 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Fix Available A PR has been opened for this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants