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

command-line --incremental flag doesn't speed up compilation #33667

Closed
mmkal opened this issue Sep 30, 2019 · 1 comment · Fixed by #34403
Closed

command-line --incremental flag doesn't speed up compilation #33667

mmkal opened this issue Sep 30, 2019 · 1 comment · Fixed by #34403
Assignees
Labels
Bug A bug in TypeScript

Comments

@mmkal
Copy link

mmkal commented Sep 30, 2019

When using tsc without tsconfig.json, i.e. passing compiler options via command line, subsequent incremental builds don't seem to speed up at all.

Unless I'm missing something about what exactly --incremental is supposed to do, this seems wrong. The command I'm running looks something like tsc --incremental --tsBuildInfoFile abc.json --outDir xyz path/to/input.ts. See below for exact repro.

TypeScript Version: 3.7.0-dev.20190928 (also 3.6.2, and likely earlier versions too)

Search Terms:

tsc, incremental, tsBuildInfoFile

Code

Here's a full repro you can run with bash, which installs dependencies, writes example code and runs tsc a few times (I'm using node 10.16.0, npm 6.9.0, MacOS):

mkdir tsc-incremental-bug-repro
cd $_
npm init -y
npm i [email protected] # what I got today from npm i typescript@next
mkdir -p packages/logger/src
cd packages/logger
npm init -y
npm i [email protected] @types/[email protected]
echo "import * as winston from 'winston'" >> src/index.ts
echo "export const mylogger = winston" >> src/index.ts
cd ../..
time npx tsc --incremental --tsBuildInfoFile packages/logger/buildinfo.json --outDir packages/logger/dist packages/logger/src/index.ts
time npx tsc --incremental --tsBuildInfoFile packages/logger/buildinfo.json --outDir packages/logger/dist packages/logger/src/index.ts
time npx tsc --incremental --tsBuildInfoFile packages/logger/buildinfo.json --outDir packages/logger/dist packages/logger/src/index.ts
time npx tsc --incremental --tsBuildInfoFile packages/logger/buildinfo.json --outDir packages/logger/dist packages/logger/src/index.ts

Each call to time npx tsc ... gave a similar overall time, about 5s on my machine. This seems very slow given it's compiling one tiny file. It'd be not-too-bad if it was only on the first build. As far as I can tell nothing is changing in the tsBuildInfoFile.

Note - this example is using a pseudo-monorepo structure since that's the way I found it IRL, but here there's only one package, so that may not be relevant. Conceivably the source code having a different node_modules than where tsc lives could make a difference?

Expected behavior:

After the first run, tsc uses tsBuildInfoFile to determine that packages/logger/src/index.ts is unchanged since the previous run, and finishes near-instantly.

Actual behavior:

It takes a full five seconds every time.

Some more info from using --diagnostics and --extendedDiagnostics:

Full command + output:

$ time npx tsc --incremental --diagnostics --extendedDiagnostics --tsBuildInfoFile packages/logger/buildinfo.json --outDir packages/logger/dist packages/logger/src/index.ts

Files:                         94
Lines:                      55069
Nodes:                     242144
Identifiers:                91394
Symbols:                   165716
Types:                      32500
Memory used:              163085K
Assignability cache size:   37419
Identity cache size:          174
Subtype cache size:             0
I/O Read time:              0.02s
Parse time:                 0.44s
Program time:               0.55s
Bind time:                  0.35s
Check time:                 1.58s
printTime time:             0.04s
Emit time:                  0.04s
transformTime time:         0.01s
commentTime time:           0.00s
I/O Write time:             0.00s
Total time:                 2.52s

real    0m2.884s
user    0m5.057s
sys     0m0.287s

Just for comparison, and to make sure it's not time or npx doing something bad:

$ time npx tsc --version

Version 3.7.0-dev.20190928

real    0m0.254s
user    0m0.209s
sys     0m0.041s

Playground Link:

N/A

Related Issues:

Maybe #30457

@mmkal mmkal changed the title incremental flag passed by command line doesn't seem to work command-line --incremental flag doesn't speed up compilation Sep 30, 2019
@mheiber
Copy link
Contributor

mheiber commented Oct 4, 2019

I'm seeing the same thing on both Windows 10 with Git Bash and Red Hat Linux

Steps to reproduce

npm install -g typescript 3.6.3
git clone [email protected]/bloomberg/pasta-sourcemaps/
npm i
tsc --incremental --tsBuildInfoFile tsbuildinfo
time tsc --incremental --tsBuildInfoFile tsbuildinfo
rm tsbuildinfo
time tsc --incremental --tsBuildInfoFile tsbuildinfo

Actual Behavior:

Running repeatedly takes about the same amount of time with/without an existing tsbuildinfo file.

Expected Behavior:

compilation is faster with tsbuildinfo

@RyanCavanaugh RyanCavanaugh added the Needs Investigation This issue needs a team member to investigate its status. label Oct 8, 2019
@sheetalkamat sheetalkamat added Bug A bug in TypeScript and removed Needs Investigation This issue needs a team member to investigate its status. labels Oct 14, 2019
@sheetalkamat sheetalkamat added this to the TypeScript 3.7.1 milestone Oct 14, 2019
sheetalkamat added a commit that referenced this issue Oct 14, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug A bug in TypeScript
Projects
None yet
4 participants