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

Atom Helper process takes up 100% CPU #32

Open
nene opened this issue Mar 4, 2018 · 18 comments
Open

Atom Helper process takes up 100% CPU #32

nene opened this issue Mar 4, 2018 · 18 comments

Comments

@nene
Copy link
Contributor

nene commented Mar 4, 2018

Whenever I execute any of the atom-import-js commands, the CPU goes to 100% and everything in Atom becomes terribly slow.

This happens regardless of whether I run Atom in normal or in dev mode.

Output from top command:

PID    COMMAND      %CPU  TIME     #TH   #WQ  #PORTS  MEM    PURG   CMPRS  PGRP  PPID  STATE    BOOSTS             %CPU_ME
24337  Atom Helper  126.0 02:44.47 22/1  1    158+    285M-  0B     0B     24325 24325 running  *0[2]              0.00000
5174   node         31.9  06:53:28 10/3  0    33      2852K  0B     475M   5170  5173  running  *0[1]              0.00000
2346   Google Chrom 6.7   56:04.13 18    1    184+    287M+  0B     88M    352   352   sleeping *0[1]              0.00000
@trotzig
Copy link
Contributor

trotzig commented Mar 5, 2018

Can you share a little on what your project looks like? For large projects, there will be an initial burst as import-js starts indexing all your javascript files. But the burst shouldn't last forever, plus the next time you run it things should be faster (it will reuse the old cache). That being said, you're likely going to get a better experience if you install Watchman as well. See the import-js readme for more on this.

@nene
Copy link
Contributor Author

nene commented Mar 5, 2018

Thanks for a quick response.

The project I first tested it on has 247 JavaScript source files + 102 SCSS files which are also imported. Its node_modules/ dir has 1165 packages.

  • Initially I thought the fault is in node_modules.linux/ dir which is use by Docker and has essentially the same 1165 packages. So I deleted it, but performance didn't improve.
  • Then I tried also deleting the node_modules/ dir itself. That did slightly improve the time it took to run the "Import word" command, but after that the CPU again spun up to 100%.
  • I waited for a several minutes... then killed it down.

I also tried it on a different project with 940 .js files, 227 .scss files, and 1016 packages in node_modules/.

  • And it all worked just fine. Perhaps a small jump in CPU-usage when first running the "Import word" command. But from then on, no performance issues.

So there must be some sort of odd difference between the projects, and it's not the plain number of files.

@nene
Copy link
Contributor Author

nene commented Mar 5, 2018

One difference that might be important is that this first project makes heavy use of named exports (while the second one mostly uses default exports).

@nene
Copy link
Contributor Author

nene commented Mar 5, 2018

I remembered that there were some large compiled .min.js files (around 1MB in size), which weren't listed in .gitignore. I deleted those as well. Initially it seemed that this didn't help... but then the CPU usage dropped down.

I added the problematic directory to excludes config, and the problem went away :)

@nene nene closed this as completed Mar 5, 2018
@macrozone
Copy link

same problem here from time to time. I try to import something and atom hangs. I have watchman installed on the computer using brew. I have no clue whether importjs actually uses watchman though

@nene
Copy link
Contributor Author

nene commented Mar 16, 2018

I started to experience this problem again too.

I then went back to deleting all these problematic directories and files, and some more... and at one point it started to work again. Added some additional directories to exclude config... we'll see if this prevents the problem from coming back again in the future.

At one point, during messing with this, I even got to the point where the import-js plugin stopped working completely (like the commands weren't even available from the menu). I uninstalled and re-installed it, to get it back to working state again.

But there definitely are some problems in here with this...

@nene nene reopened this Mar 16, 2018
@trotzig
Copy link
Contributor

trotzig commented Mar 16, 2018

I have no clue whether importjs actually uses watchman though

You should see something about this in the import-js logfile:
https://github.com/Galooshi/import-js#loglevel

I'd be interested to see more of what's in that logfile. Can you either share here or link to an uploaded gist @macrozone?

@macrozone
Copy link

@trotzig hi,

This is my .importjs.js file now:

module.exports = {
  environments: ['meteor', 'node'],
  excludes: ['.meteor/**'],
  logLevel: 'debug',
};

but no logfile is created. I restarted atom, but without luck.

@macrozone
Copy link

ok, i uninstalled importjs and reinstalled. Then i got a message about native modules that were built for an older version of atom and could rebuild it.

after that, it started to work again. also logfile is now there

@trotzig
Copy link
Contributor

trotzig commented Mar 16, 2018

Interesting. This could definitely be related to building the sqlite3 dependency (I have seen this come up several times in the past).

I'm glad you found a workaround, and I hope this can help others running into the same issue.

@trotzig
Copy link
Contributor

trotzig commented Mar 16, 2018

Quick question, are you on windows, linux or mac?

@macrozone
Copy link

mac os x high sierra.

by the way, now the cpu issue is back, but nothing appear in the logfile :-(

@trotzig
Copy link
Contributor

trotzig commented Mar 16, 2018

Is there anything in the dev console log in Atom?

@nene
Copy link
Contributor Author

nene commented Mar 16, 2018

FYI, I'm also running the latest OSX.

@bennypowers
Copy link

bennypowers commented Jul 1, 2018

Same here OSX. AFAICT importjs is watching changes in my build directory, which is constantly being recreated. I have public/build in my root project gitignore and build in my public/.gitignore but it doesn't help.

Project structure:

/ (nodejs)
|- .importjs.js (excludes: ['public/**/*'])
|- public (browser)
   |- .importjs.js (excludes: ['build/**/*'])
   |- build (browser, bundled)

NOTE: I'm also using rollup plugins to transform css and graphql files, so I can
import query from './query.graphql';. Could that be gumming up the works?

@trotzig
Copy link
Contributor

trotzig commented Jul 1, 2018

@bennypowers If I'm not mistaken, only the project root .importjs.js will be used in your case, so you can probably get rid of the one in the public folder.

I had a look at some of my own projects and their .importjs.js config. I have excludes patterns starting with a dot, e.g.

// .importjs.js
module.exports = {
  excludes: ['./build/**'],
}

Could you try changing your excludes config to see if it makes things better?

@bennypowers
Copy link

Seems to have helped, thanks.

Docs show without ., maybe should be updated.

excludes: [
  'react-components/**/test/**',
]

@trotzig
Copy link
Contributor

trotzig commented Jul 3, 2018

Thanks for the callout! I made that change here: Galooshi/import-js@6e88abf

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

4 participants