barbatus / typescript-compiler

TypeScript Compilers for Meteor
14 stars 9 forks source link

Performance issue with typescript compiler #21

Closed sdarnell closed 8 years ago

sdarnell commented 8 years ago

I was giving the meteor 1.4.2.rc.0 build a spin in the hope that startup times would be substantially better... sadly, not as much as I would like. So I did a profiling run on the initial launch of meteor (on OSX 10.11.6 MacBook Pro 2015, 2.7 GHz Intel Core i5), Meteor 1.4.2.rc.0.

I used METEOR_PROFILE=100 TYPESCRIPT_LOG=4 meteor on an app that had had no changes since the last run (a few minutes earlier).

The interesting thing is that the meteor profiling says: prepareProjectForBuild takes 2.2s Build App 94.4s of which compiler.compile takes 71s, but of that,

The mystery for me is that there's no obvious explanation in the typescript profiling, it says:

compiler options: {"experimentalDecorators":true,"module":"commonjs","target":"es5","isolatedModules":false,"moduleResolution":"node","emitDecoratorMetadata":true,"removeComments":false,"noImplicitAny":false,"sourceMap":true,"noEmitHelpers":true,"jsx":"react","noResolve":false,"lib":["es5","dom"],"diagnostics":true,"noImplicitUseStrict":true}

exclude started web.browser (335 files)
tsBuild time: 223ms
tsEmitFiles time: 818ms
compilation time: 1044ms

exclude started os.osx.x86_64 (173 files)
tsBuild time: 71ms
tsEmitFiles time: 163ms
compilation time: 234ms

All of the other messages seem to suggest that compilation output is coming from the cache, and times are one or two milliseconds with a few spurious 9-10 ms. But nothing large.

So is there a way to narrow down why Meteor thinks the typescript compiler is taking so long, and if everything is coming from the cache - what is taking a minute?

I'm not criticising the compiler or anything like that, I'm just trying to establish if there is anything I can do to improve our build times.

Note that I checked the file lists, and there doesn't seem to be anything particularly out of the ordinary or duplicates in the the list (e.g. I'm definitely not pulling in node_modules).

barbatus commented 8 years ago

Check out if you use the latest version. This might be related to this https://github.com/meteor/meteor/issues/6935#issuecomment-252252761 The reason was in the size of the package. I used direct imports in the package which made it more than 10Mb. Running a file of that size can take a while.

Good analysis though 👍

sdarnell commented 8 years ago

Awesome man! With the latest versions, the typescript-compiler part only takes 176 ms (with the typescript profiling turned off).