ember-cli: The 'tmp' folder in the project root causes the typescript compiler to consume 100% cpu

We use ember-cli-typescript to compile our typescript source files. As described in https://github.com/typed-ember/ember-cli-typescript/pull/172, rebuilds can take a very long time. It is not only ember-cli-typescript that suffers from this performance issues, ‘Visual Studio Code’ has the same problem. It is bassically ‘tsc --watch’ that consumes 100% cpu.


Output from ember version --verbose && yarn --version:

ember-cli: 3.0.2
http_parser: 2.8.0
node: 8.11.1
v8: 6.2.414.50
uv: 1.19.1
zlib: 1.2.11
ares: 1.10.1-DEV
modules: 57
nghttp2: 1.25.0
openssl: 1.0.2o
icu: 60.1
unicode: 10.0
cldr: 32.0
tz: 2017c
os: darwin x64
1.5.1

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 15 (12 by maintainers)

Most upvoted comments

@bartocc and others: the jsconfig.json and tsconfig.json files don’t have quite the effect they might seem to. It turns out they don’t disable the TS language server—which VS Code uses under the hood to power a lot of its smarts even for JS—watching those directories, they just keep it from processing them. (This has come up repeatedly for TS Ember users, and it’s a major point of annoyance.)

The actual solution—which is also applicable to Sublime Text, if I recall correctly, and may be applicable to Atom as well—is to go at it from the editor settings. You can either generally exclude those directories, or you can do it in a per-workspace settings which you commit. It’ll end up in .vscode/settings.json in your directory.

As an example, here is the relevant part of my .vscode/settings.json in the Ember app I work on right now:

{
    "search.exclude": {
        "**/.git": true,
        "**/node_modules": true,
        "**/bower_components": true,
        "**/tmp": true,
        "**/dist": true,
        ".idea/*": true
    },
    "files.exclude": {
      "**/.git": true,
      "**/.svn": true,
      "**/.hg": true,
      "**/.DS_Store": true,
      ".idea": true,
      "bower_components": true,
      "dist": true,
      "node_modules": true,
      "public": true,
      "tmp": true
    },
    "files.watcherExclude": {
      "**/.git/objects/**": true,
      "**/.git/subtree-cache/**": true,
      "**/node_modules/**": true,
      "**/.git": true,
      "**/.svn": true,
      "**/.hg": true,
      "**/.DS_Store": true,
      ".idea": true,
      "bower_components": true,
      "dist": true,
      "node_modules": true,
      "public": true,
      "tmp": true
    }                      
}

This is definitely a bandaid, but it gets the job done until we get the final fix in. Note: all of these are useful, but it’s specifically the "files.watcherExclude" key that keeps the TS server from blowing up, as far as we can tell.

@jenweber flagging this up for you as a thing we might want to include docs somewhere; I can open an issue and indeed a PR if you can point me to the place the learning team thinks is the best fit for this info.

A large step forward on moving tmp out of the project landed yesterday in https://github.com/ember-cli/ember-cli/pull/7798. At the moment, you can try this out by using the master branch of ember-cli and running:

EMBER_CLI_BROCCOLI_2=true EMBER_CLI_SYSTEM_TEMP=true ember serve

I am unsure if there is a more specific tracking issue for enabling those two experiments by default…

So, I agree that it is not an ember-cli issue, but ember-cli could provide the solution, by moving the ‘tmp’ folder out of the project root.

Yep, totally agree! We are working towards moving tmp to the default system tmp folder location.

thx a lot @rwjblue for pointing us to those feature flags!

@chriskrycho, I recall trying some of those configs, but at that time I had not clearly identified the tsserver issue. I’ll try again and see how it affects the CPU issue. Thx!