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

Speed up watch mode #19275

Closed
wants to merge 4 commits into
base: master
from

Conversation

Projects
None yet
5 participants
@tbosch
Member

tbosch commented Sep 19, 2017

The first commit is from #19213 which was already reviewed.

tbosch added some commits Sep 12, 2017

perf(compiler): make the creation of `ts.Program` faster.
We now create 2 programs with exactly the same fileNames and
exactly the same `import` / `export` declarations,
allowing TS to reuse the structure of first program
completely. When passing in an oldProgram and the files didn’t change,
TS can also reuse the old program completely.

This is possible buy adding generated files to TS
in `host.geSourceFile` via `ts.SourceFile.referencedFiles`.

This commit also:
- has a minor side effect on how we generate shared stylesheets:
  - previously every import in a stylesheet would generate a new
    `.ngstyles.ts` file.
  - now, we only generate 1 `.ngstyles.ts` file per entry in `@component.styleUrls`.
  This was required as we need to be able to determine the program files
  without loading the resources (which can be async).
- makes all angular related methods in `CompilerHost`
  optional, allowing to just use a regular `ts.CompilerHost` as `CompilerHost`.
- simplifies the logic around `Compiler.analyzeNgModules` by introducing `NgAnalyzedFile`.

Perf impact: 1.5s improvement in compiling angular io
refactor(compiler): introduce `EmitFlags.CodeGen`
This flag controls whether the compiler emits generated files.
It is initially calculated via `skipTemplateCodegen` from the
compiler options.

Also:
- adds a small performance improvement to not generate the files
  at all if we don’t emit generated code.
- removes `EmitFlags.Summaries` as we never used it.

@googlebot googlebot added the cla: yes label Sep 19, 2017

@tbosch tbosch requested a review from chuckjaz Sep 19, 2017

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Sep 19, 2017

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Sep 19, 2017

You can preview 8a6f053 at https://pr19275-8a6f053.ngbuilds.io/.

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Sep 19, 2017

@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Sep 19, 2017

perf(compiler): speed up watch mode
- don’t regenerate code for .d.ts files when
  an oldProgram is passed to `createProgram`
- cache `fileExists` / `getSourceFile` / `readFile` in watch mode
- refactor tests to share common code in `test_support`
- support `—diagnostic` command line to print total time
  used per watch mode compilation.
@mary-poppins

This comment has been minimized.

Show comment
Hide comment
@mary-poppins

mary-poppins commented Sep 19, 2017

@IgorMinar IgorMinar closed this in edd5f5a Sep 20, 2017

IgorMinar added a commit that referenced this pull request Sep 20, 2017

IgorMinar added a commit that referenced this pull request Sep 20, 2017

refactor(compiler): introduce `EmitFlags.CodeGen` (#19275)
This flag controls whether the compiler emits generated files.
It is initially calculated via `skipTemplateCodegen` from the
compiler options.

Also:
- adds a small performance improvement to not generate the files
  at all if we don’t emit generated code.
- removes `EmitFlags.Summaries` as we never used it.


PR Close #19275

IgorMinar added a commit that referenced this pull request Sep 20, 2017

perf(compiler): speed up watch mode (#19275)
- don’t regenerate code for .d.ts files when
  an oldProgram is passed to `createProgram`
- cache `fileExists` / `getSourceFile` / `readFile` in watch mode
- refactor tests to share common code in `test_support`
- support `—diagnostic` command line to print total time
  used per watch mode compilation.
PR Close #19275

@tbosch tbosch deleted the tbosch:perf_watch branch Oct 3, 2017

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