Skip to content

useTypescriptIncrementalApi increases initial build time #211

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

Closed
Kavorka79 opened this issue Jan 29, 2019 · 8 comments
Closed

useTypescriptIncrementalApi increases initial build time #211

Kavorka79 opened this issue Jan 29, 2019 · 8 comments

Comments

@Kavorka79
Copy link

Kavorka79 commented Jan 29, 2019

Hi,

I wanted to try the new option useTypescriptIncrementalApi. But our build time was as follows:

                                         initial                incremental
with 4 workers:                              31s                    10s
with one worker:                             50s                    30s
with useTypescriptIncrementalApi:           180s                    10s

Incremental was only change to one file, so a little strange to see the difference between 4 workers and 1 worker. Any insights?

We got no incremental build time improvment and a initial build time slow down?

setup:

new ForkTsCheckerWebpackPlugin({
  checkSyntacticErrors: true,
  async: false,
  tsconfig: root('./tsconfig.json'),
  tslint: root('./tslint.json'),
  useTypescriptIncrementalApi: true,
  measureCompilationTime: true,
  workers: 1
});

tsconfig.js:

{
  "compilerOptions": {
    "sourceMap": true,
    "target": "es5",
    "module": "commonjs",
    "noImplicitAny": false,
    "noImplicitReturns": true,
    "noUnusedLocals": true,
    "preserveConstEnums": true,
    "removeComments": true,
    "version": true,
    "importHelpers": true,
    "skipLibCheck": true,
    "typeRoots": [
      "./typings",
      "./node_modules/@types"
    ],
    "lib": [
      "es5",
      "dom",
      "scripthost",
      "es2015.core",
      "es2015.promise",
      "ES2016.Array.Include",
      "ESNext.Array"
    ]
  },
  "exclude": [
    "node_modules",
    "build",
    "coverage",
    ".idea",
    ".vscode",
    "config"
  ]
}

package.js

devDependencies: {
    "fork-ts-checker-webpack-plugin": "1.0.0-alpha.2",
    "thread-loader": "1.2.0",
    "ts-loader": "4.4.2",
    "typescript": "3.0.1",
    "webpack": "4.16.3",
    "webpack-cli": "3.1.0",
    "webpack-dev-server": "3.1.5"
},
"engines": {
    "node": "8.9.4"
  }
@johnnyreilly
Copy link
Member

I don't think you can be using the version of the plugin specified as the plugin does not support multiple workers with the incremental build API mode. Do you want to double check?

Also, check out this example: https://github.com/TypeStrong/ts-loader/tree/master/examples/fork-ts-checker-webpack-plugin

@Kavorka79
Copy link
Author

Hi,
Thanks for the quick reply! :)

The multiple worker is without useTypescriptIncrementalApi flag set, just to illustrate different settings and results. Settings are like under setup section.

@johnnyreilly
Copy link
Member

johnnyreilly commented Jan 29, 2019

Do you have the latest version? I can't guarantee it's going to be faster for you but my own experience has been significant. About 4 times faster.

Suggest you change your config to:


new ForkTsCheckerWebpackPlugin({
  tsconfig: root('./tsconfig.json'),
  tslint: root('./tslint.json'),
  useTypescriptIncrementalApi: true,
  measureCompilationTime: true,
  workers: 1
});

@0xorial
Copy link
Contributor

0xorial commented Mar 11, 2019

Hi, @Kavorka79.
Just to give more context - could you provide some info about your codebase:

  • how many files do you have and what is the total size?
  • is it possible for you to run directly tsc --watch and see how much time it takes?
  • are you using modules in your project?
  • if so, do you have circular dependencies between them?

Also, to give you some more history of useTypescriptIncrementalApi, it was inspired by compiling the sources of Visual Studio Code (which I encourage to do, just to have a better feeling). They are compiling the sources with tsc directly. Here are some very rough measurements that I have from my own repository and vscode repository (by old I mean useTypescriptIncrementalApi: false and 4 workers):

codebase compiler setup files total size initial compilation incremental compilation initial compilation (old) incremental compilation (old)
my repo webpack (dev-server) 150 1.5 MB 12 s 0.5-4s 8s 2s
vscode tsc --watch 2500 20MB 20s 0.3-5s

Currently, I have a feeling that performance of typescript incremental compilation depends on how sources are organized: less globals -> faster incremental compilation.

@IIIristraM
Copy link

Hi, are any updates on this issue ?

I have about 6k files in my repo. Compilation with "useTypescriptIncrementalApi: true" takes 300+s without linters, when with "useTypescriptIncrementalApi: false" about 90s with a single worker

TS v3.5.3
fork-ts-checker-webpack-plugin v1.5.0
webpack v4.40.2

@0xorial
Copy link
Contributor

0xorial commented Sep 19, 2019

Just FYI, I was recently trying to get some performance measurements for webpack+TS setup, but discovered that webpack watch mode time grows linearly with the number of files. I found this extremely discouraging and didn't do any further tests/investigation.

@Kavorka79, could you try running tsc --watch and see if it has better performance? (and, while we are at it, also try the tsc --incremental). This way we could know if there is still hope to fix something in the plugin.

@myshov
Copy link

myshov commented Apr 5, 2020

There is a related issue in TypeScript repo: microsoft/TypeScript#34119

If you have a problem with slow initial build with useTypescriptIncrementalApi, please run tsc (with watch mode and without with --diagnostics) independently and post the results in the issue. The more information we will give to the developers of TS the sooner they will resolve the issue.

@piotr-oles piotr-oles mentioned this issue Apr 18, 2020
26 tasks
@piotr-oles
Copy link
Collaborator

@Kavorka79 , @IIIristraM
Please try fork-ts-checker-webpack-plugin@alpha - I've published a new version which should resolve this issue 🚀
I will close this issue to clean-up the backlog. If this release didn't solve the issue, we can re-open this :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants