-
Notifications
You must be signed in to change notification settings - Fork 12.8k
High CPU when using --watch on 2000+ files (roughly 40megs) #19762
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
Do you mean even while |
Can you share the project? we would be happy to sign any required NDAs. |
Also, can you give us more information about your machines? e.g. Node version, OS, architecture, CPU count, etc.? |
I'm also experiencing this on macOS 10.13.1, with Node v8.9.0. Although it's usually 3%, but it should be almost 0, and occasionally it occupied all 100% which was gone after the restart. |
@ip can you please share a repro project? |
Sorry for the late response guys. Unfortunately, I can't share the repo yet. Will get back to you about the NDA this week. It's happening on Win10 1511 to 1709 with node 6 and 8. Yes, it's hogging the CPU while simply watching for changes (before I save anything). The machine is i7 with 16gig ram and an SSD. The project is an angular 1.5 typescript project using the old school name spaces and references. I'll try and get more info about it and maybe somehow share the project this coming week. |
I'm also experiencing this issue. Project has almost 2000 ts files, and compiling in watch mode uses about 6-7% CPU constantly when waiting on changes: I've seen similar issue when using grunt-watch task, which uses pooling to detect file changes. It's good for small projects but it's starting to stress cpu just watching hundreds of files. We switched to our custom implementation of watch using node fs.watch, which uses "native" host os watching for changes feature which is much more efficient with cpu than pooling (and much faster). // Edit |
@OlekNg, what OS are you using and what is the version of node?
So you do not see the issue if you set |
@mhegazy Setting TSC_NONPOLLING_WATCHER to 1 solved high CPU usage problem (it went down to 0%). From my previous post I also found that I can set env var for whole VSCode using setting "terminal.integrated.env.windows" which allowed me to run tsc compiler from VSCode with TSC_NONPOLLING_WATCHER flag set to 1. |
How many files do you have in your project ( |
|
TSC_NONPOLLING_WATCHER=1 solves all my problems! |
Same problem, |
I'm still experiencing high cpu usage when idle (using docker). TSC_NONPOLLING_WATCHER=1 stops watching the ts files for me. |
PR #21243 has multiple options enabled using environment variables The different options are explained in #21243 (comment) . Experience and feedback about these options is appreciated and would help us make decision on which strategy to go as default. |
Code
TypeScript version:
2.6.1 (reproduces in previous versions as well)
Expected behavior:
To not hog CPU when watching (not while compiling).
Actual behavior:
tsc
node process occupies 30-40% CPU while idle in watch.The text was updated successfully, but these errors were encountered: