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

karma: extras: usePolling #297

Closed
3 tasks
michaelsbradleyjr opened this issue Apr 20, 2017 · 7 comments
Closed
3 tasks

karma: extras: usePolling #297

michaelsbradleyjr opened this issue Apr 20, 2017 · 7 comments

Comments

@michaelsbradleyjr
Copy link
Contributor

michaelsbradleyjr commented Apr 20, 2017

This issue is a:

  • Bug report
  • Feature request
  • Question / support request
  • [ X ] Other

When making use of nwb's npm run test:watch, on macOS Sierra (10.12.4), node v7.9.0, I was getting very high CPU usage even when the node process was idle, i.e. just waiting to be triggered by a change to a source or test file.

I spent several hours trying to figure out what was happening. This helped:

sudo fs_usage -f pathname -w

Thousands of files were getting polled in node_modules, relative to my project's top-level directory. I tried to figure out whether it was karma or webpack, or both, and whether I could tell either or both to exclude node_modules ....... long story short, nothing I changed in the extra: fields for karma and webpack, in nwb.config.js, was having any significant effect.

Later, while digging around in some GitHub issues, I saw where one can set usePolling: false in one's karma config (that options seems not well documented)

So, in nwb.config.js:

module.exports = {
  ...,
  karma: {
    extra: {
      ...,
      usePolling: false
    },
  ...
};

Finally, that worked. Now, the node process for npm run test:watch sits idle at ~0% cpu usage, which is what one would expect, i.e. when it's not busy compiling or running tests.

I'm filing this issue since it may be helpful to others, and perhaps warrants a note in nwb's configuration documentation.

@michaelsbradleyjr
Copy link
Contributor Author

michaelsbradleyjr commented Apr 20, 2017

Okay, so it seems that on macOS, usePolling is getting set to true at runtime:

https://github.com/karma-runner/karma/blob/master/lib/config.js#L318

tracking it back with blame:

karma-runner/karma@66f50d7

That commit was about 3 1/2 years ago, and it seems that non-polling file watching on macOS works fine now, i.e. since I set usePolling to false and the autoWatch facility is picking up changes and w/ low impact on CPU usage, as I noted previously. I'll leave the karma maintainers a note.

@michaelsbradleyjr
Copy link
Contributor Author

Filed an issue yesterday with karma-runner/karma:

karma-runner/karma#2669

@loklaan
Copy link
Collaborator

loklaan commented Apr 20, 2017

@michaelsbradleyjr Wow, nice discovery. I hope it becomes default in upstream karma 👍 .

Would you mind updating the docs on the master branch? I'll be sure to merge it in asap.

@michaelsbradleyjr
Copy link
Contributor Author

What do you think is the best approach? Should I include a note under the extra heading?

@loklaan
Copy link
Collaborator

loklaan commented Apr 20, 2017

Under the karma intro paragraph with a "Note:" prefix, would be great. Thanks for getting confirmation

@michaelsbradleyjr
Copy link
Contributor Author

See #298.

@loklaan
Copy link
Collaborator

loklaan commented Apr 26, 2017

Resolved by #298

@loklaan loklaan closed this as completed Apr 26, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants