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

Long compilation time (hello world takes ~5sec) #36396

Closed
karrakoliko opened this issue Jan 24, 2020 · 4 comments
Closed

Long compilation time (hello world takes ~5sec) #36396

karrakoliko opened this issue Jan 24, 2020 · 4 comments
Labels
Unactionable There isn't something we can do with this issue

Comments

@karrakoliko
Copy link

karrakoliko commented Jan 24, 2020

TypeScript Version: 3.7.5

Search Terms:

  • compiling
  • compilation
  • time

Just installed typescript.

Compiling 1-string typescript "hello world" file takes ~5 sec on my machine. It doesn't depend of current CPU/RAM loading etc. Looks like it "hangs" for 4 sec, and then starts working.

I tried to reboot, reinstall typescript, run as different user - nothing helps.
Is it OK?

tu@DESKTOP-5GAUPEG MINGW64 /d/home/projects/test
$ ls -la
total 5
drwxr-xr-x 1 tu 197121  0 Jan 24 13:01 ./
drwxr-xr-x 1 tu 197121  0 Jan 24 13:01 ../
-rw-r--r-- 1 tu 197121 29 Jan 24 12:54 test.ts

tu@DESKTOP-5GAUPEG MINGW64 /d/home/projects/test
$ cat test.ts
console.log("hello world!");

tu@DESKTOP-5GAUPEG MINGW64 /d/home/projects/test
$ time tsc test.ts

real    0m5.230s
user    0m0.061s
sys     0m0.198s

tu@DESKTOP-5GAUPEG MINGW64 /d/home/projects/test
$ for i in {1..5}; do time tsc test.ts; done

real    0m6.339s
user    0m0.075s
sys     0m0.230s

real    0m6.491s
user    0m0.122s
sys     0m0.213s

real    0m6.433s
user    0m0.182s
sys     0m0.244s

real    0m6.527s
user    0m0.060s
sys     0m0.338s

real    0m7.114s
user    0m0.107s
sys     0m0.275s

Expected behavior:
Taking about .001sec for compiling console.log("hello world!")

Actual behavior:
Taking about 5sec for compiling console.log("hello world!")

Additional info:
OS: Windows 10
Intel Core i3-4005U CPU @ 1.70GHz / 8GB RAM / SSD
Terminal: git bash

Let me know if you need any additional info.
Thanks.

@RyanCavanaugh
Copy link
Member

Can you run with --extendedDiagnostics and show the output?

The version of node would also be useful.

Probably a 7-year-old laptop CPU is just going to take this long for node to load tsc.js and there may not be anything we can do about it

@RyanCavanaugh RyanCavanaugh added the Needs More Info The issue still hasn't been fully clarified label Feb 26, 2020
@karrakoliko
Copy link
Author

karrakoliko commented Mar 2, 2020

@RyanCavanaugh

tu@DESKTOP-5GAUPEG MINGW64 /d/home/projects/ts-test
$ cat test.ts
console.log('hello world!');

tu@DESKTOP-5GAUPEG MINGW64 /d/home/projects/ts-test
$ tsc test.ts --extendedDiagnostics
Files:                         6
Lines:                     24904
Nodes:                    112200
Identifiers:               41098
Symbols:                   27969
Types:                      8299
Memory used:              76788K
Assignability cache size:  33122
Identity cache size:           2
Subtype cache size:            0
I/O Read time:             0.02s
Parse time:                1.22s
Program time:              1.26s
Bind time:                 0.57s
Check time:                3.31s
transformTime time:        0.02s
commentTime time:          0.00s
I/O Write time:            0.00s
printTime time:            0.03s
Emit time:                 0.03s
Total time:                5.17s

@RyanCavanaugh RyanCavanaugh added Unactionable There isn't something we can do with this issue and removed Needs More Info The issue still hasn't been fully clarified labels Mar 3, 2020
@RyanCavanaugh
Copy link
Member

This is what I see for a similarly small file

Assignability cache size:    33700
Identity cache size:             1
Subtype cache size:              0
Strict subtype cache size:       0
I/O Read time:               0.08s
Parse time:                  0.36s
Program time:                0.49s
Bind time:                   0.24s
Check time:                  1.19s
transformTime time:          0.01s
commentTime time:            0.00s
I/O Write time:              0.00s
printTime time:              0.01s
Emit time:                   0.01s
Total time:                  1.94s

~99.99% of the checkTime is checking lib.d.ts and its dependencies; you should probably enable --skipLibCheck. This improves the numbers:

Memory used:               82930K
Assignability cache size:       1
Identity cache size:            0
Subtype cache size:             0
Strict subtype cache size:      0
I/O Read time:              0.04s
Parse time:                 0.35s
Program time:               0.43s
Bind time:                  0.24s
Check time:                 0.02s
transformTime time:         0.01s
commentTime time:           0.00s
I/O Write time:             0.00s
printTime time:             0.02s
Emit time:                  0.02s
Total time:                 0.71s

However we can't skip parsing and binding the built-in definitions, so ultimately this is just "slow computers are slow"

@DanielRosenwasser
Copy link
Member

There is technically #25658

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Unactionable There isn't something we can do with this issue
Projects
None yet
Development

No branches or pull requests

3 participants