-
-
Notifications
You must be signed in to change notification settings - Fork 244
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
CPU usage on idle? #236
Comments
Could you provide more information about your setup? The best option would be a bug reproduction repository and information about your OS and hardware. If you are not able to create bug reproduction repository, send at least your webpack config :) |
@piotr-oles hey, thanks for getting back! I've tried to replicate the problem in a new repo with similar setup, and some auto-generated typescript files but the worst I'm getting so far is ~4% cpu on idle. It kind of feels like the number is slowly getting higher with more ts files but it's hard to tell as it jumps around and my dumb ad hoc generator quickly exceeds available stack size. I couldn't find any benchmark/test files that I could use though. That said, even 4% on idle isn't nothing, especially once compared to webpack which uses zero when watching. I'm using current node lts on macOS, cpu i5-7360U (2 cores) Here's the repo: https://github.com/mszczepanczyk/fork-ts-checker-high-cpu-on-idle |
I'm not able to share the repository I am working on, but I am seeing this same issue, where it's getting up to 40% on idle. System Information: Dependencies: |
As part of your tweaking I suggest dropping happypack and starting to use the incremental API. Check out the config here for inspiration: https://github.com/TypeStrong/ts-loader/blob/master/examples/fork-ts-checker-webpack-plugin/webpack.config.development.js Stopping using happypack might reduce the resource usage significantly |
I have the exact same issue on Windows 10 using this via create react app v2.1.8 |
Same issue here (Win 10). Upgraded from 0.4.6 to 1.0.1. 1.0.1 uses about 10% CPU, 0.4.6 practically none. |
I have the same issue with my system: Windows 10 1809 x64 I just tried your suggestion and changed to ts-loader to transpileOnly with the But unfortunately the issue remains, fork-ts-checker plugin eats 5-8% cpu (of total 4 real i7 cores) while sitting idle: If I set instead the |
I think I had some improvement when I tried setting environmental variable TSC_NONPOLLING_WATCHER = '1'. |
I read the link and figured out that this is the correct setting to use:
I tested it and indeed cpu usage on idle is 0.0% without any issues (so far) watching and recompiling the files upon change. |
Is this PR-able? I'd be interested in baking in better default behaviour if we can. |
Yeah I guess so. Probably we could also bake in a new option too, that you could switch from polling to fsevents. |
If you'd like to try something out we'd be very grateful ❤️ |
sure :) |
PR ready, check it out :) |
Hi,
|
To spread the knowledge about this issue (and the workaround) I've blogged it here: https://blog.johnnyreilly.com/2019/05/typescript-and-high-cpu-usage-watch.html Hope it helps people reading this! |
When will this be fixed? it is eating my battery. |
Please see the blog post linked above for details @allnash. This is not an issue with the |
@johnnyreilly you are a hero, thanks for chasing this up, i'm late to the party but this has bugged me for a while, great blog post, I've managed to fix it by adding TSC_WATCHFILE=UseFsEvents. I've found UseFsEvents is the best option, UseFsEventsWithFallbackDynamicPolling was still using quite a bit of CPU (maybe trying to poll?) If you're using a Mac (even with a docker guest) you don't need polling-fallback, only with a windows host. In case anyone else comes here, Typescript's reasoning is layed out here: |
FYI I added This was happening with Next.js which ends up running this service in dev mode. |
Unfortunately, that did not help in my case. I tried both In my use-case, I use a
The entrypoint simply runs |
In order to |
I got a
|
@mszczepanczyk , @taylortdixon , @delaaxe , @ajkettun , @NeKJ , @harrybin , @allnash , @jasonwilliams , @activescott , @samupl , @remorses |
See this for problems with the 4.x line of this plugin: #655 |
I added checker to the build process in our app and after a while I started getting complaints about high CPU usage with
webpack --watch
. Interestingly only windows people raised it. I've tried to investigate the issue on my macOS and realized the checker processes use quite a lot of CPU resources even when idling:V8 inspector attached to one of them shows no executions:
I suspect the CPU consumption is caused by GC or file watchers. Any idea how to fix/debug this one?
The text was updated successfully, but these errors were encountered: