Skip to content

ngc watch is not incremental, runs full build #21361

Closed

Description

@alippai

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

To compile my project it takes 11 seconds for tsc (typescript@2.6), however ngc takes 25 seconds.
The watch mode is similar 3 seconds versus 10+ for a single file (component) change.
Is there a way to debug the problem or is this the desired behavior.

Expected behavior

The durations should be close

Environment


Angular version: 5.2.0-rc0
TypeScript version (both global and project): 2.6



For Tooling issues:
- Node version: 8.9.3 and 9.3.0
- Platform: Both Windows and the Linux subsystem (Ubuntu)

tsconfig:
{
  "compilerOptions": {
    "target": "ES2017",
    "module": "ES2015",
    "moduleResolution": "node",
    "sourceMap": false,
    "importHelpers": true,
    "emitDecoratorMetadata": false,
    "experimentalDecorators": true,
    "lib": [
      "es2015",
      "dom",
      "es2017.object"
    ],
    "noImplicitAny": false,
    "isolatedModules": true,
    "suppressImplicitAnyIndexErrors": true,
    "allowSyntheticDefaultImports": true,
    "allowJs": true,
    "skipLibCheck": true,
    "outDir": "../../compiled",
    "typeRoots": [
      "../../node_modules/@types/"
    ]
  },

  "files": [
    "./app.module.ts"
  ],

  "include": [
    "../../../../types/models/*.d.ts"
  ],

  "exclude": [
    "../../generated/**",
    "../../compiled/**",
    "../../node_modules/**"
  ]
}

Activity

  1. alippai commented on Jan 7, 2018

    @alippai
    ContributorAuthor
    "./node_modules/.bin/tsc" -p app/ts/tsconfig.watch.json -w
    Synchronizing program
    Files:          1186
    Lines:        100855
    Nodes:        411168
    Identifiers:  125264
    Symbols:      119669
    Types:         21711
    Memory used: 218908K
    I/O read:      0.22s
    I/O write:     0.69s
    Parse time:    3.59s
    Bind time:     1.04s
    Check time:    3.58s
    Emit time:     1.83s
    Total time:   10.04s
    10:21:07 - Compilation complete. Watching for file changes.
    
    
    10:21:12 - File change detected. Starting incremental compilation...
    
    
    Synchronizing program
    Files:          1186
    Lines:        100855
    Nodes:        411168
    Identifiers:  125264
    Symbols:       83458
    Types:            57
    Memory used: 175269K
    I/O read:      0.00s
    I/O write:     0.00s
    Parse time:    2.27s
    Bind time:     0.00s
    Check time:    0.00s
    Emit time:     0.00s
    Total time:    2.27s
    10:21:14 - Compilation complete. Watching for file changes.
    

    The same file & options:

    "./node_modules/.bin/ngc" -p app/ts/tsconfig.watch.json -w
    : Time for diagnostics: 10960ms.
    : Emitted in 16648ms
    - 1270 user ts files
    - 249 generated ts files
    - 860 generated json files
    
    : Total time: 28s
    
    : Compilation complete. Watching for file changes.
    
    : File change detected. Starting incremental compilation.
    
    : Time for diagnostics: 8575ms.
    : Emitted in 11602ms
    - 1270 user ts files
    - 249 generated ts files
    - 860 generated json files
    
    : Total time: 20s
    
    : Compilation complete. Watching for file changes.
    
  2. alippai commented on Jan 7, 2018

    @alippai
    ContributorAuthor

    There is one bug at least, the watch mode is broken in the last releases:

    const oldProgram = cachedProgram;
    // We clear out the `cachedProgram` here as a
    // program can only be used as `oldProgram` 1x
    cachedProgram = undefined;
    const compileResult = performCompilation({
    rootNames: cachedOptions.rootNames,
    options: cachedOptions.options,
    host: cachedCompilerHost,
    oldProgram: cachedProgram,
    emitCallback: host.createEmitCallback(cachedOptions.options)
    });

    The oldProgram option is always undefined.

  3. alippai commented on Jan 7, 2018

    @alippai
    ContributorAuthor

    After the fix, it's definitely better.
    ...still fishy, 200 files changed by changing only 1 angular component:

    node ./node_modules/@angular/compiler-cli/src/main.js -p app/ts/tsconfig.watch.json -w
    : Time for diagnostics: 10057ms.
    : Emitted in 10920ms
    - 1270 user ts files
    - 249 generated ts files
    - 860 generated json files
    
    : Total time: 21s
    
    : Compilation complete. Watching for file changes.
    
    : File change detected. Starting incremental compilation.
    
    : Time for diagnostics: 7021ms.
    : Emitted in 7045ms
    - 1343 user ts files
    - 99 generated ts files
    - 99 generated json files
    
    : Total time: 14s
    
    : Compilation complete. Watching for file changes.
    
  4. alippai commented on Jan 7, 2018

    @alippai
    ContributorAuthor

    3rd and 4th runs are better, but still slow:

    $ node ./node_modules/\@angular/compiler-cli/src/main.js -p app/tsconfig.watch.json -w
    : Time for diagnostics: 10827ms.
    : Emitted in 10415ms
    - 1270 user ts files
    - 249 generated ts files
    - 860 generated json files
    
    : Total time: 21s
    
    : Compilation complete. Watching for file changes.
    
    : File change detected. Starting incremental compilation.
    
    : Time for diagnostics: 7426ms.
    : Emitted in 7579ms
    - 1343 user ts files
    - 99 generated ts files
    - 99 generated json files
    
    : Total time: 15s
    
    : Compilation complete. Watching for file changes.
    
    : File change detected. Starting incremental compilation.
    
    : Time for diagnostics: 7040ms.
    : Emitted in 3325ms
    - 1 user ts files
    - 0 generated ts files
    - 0 generated json files
    
    : Total time: 10s
    
    : Compilation complete. Watching for file changes.
    
    : File change detected. Starting incremental compilation.
    
    : Time for diagnostics: 6198ms.
    : Emitted in 4309ms
    - 1 user ts files
    - 0 generated ts files
    - 0 generated json files
    
    : Total time: 11s
    
    : Compilation complete. Watching for file changes.
    
  5. alippai commented on Jan 8, 2018

    @alippai
    ContributorAuthor

    The last change results in smaller generated code, which is unexpected for me. @IgorMinar or @tbosch who is familiar with this piece of code?

  6. added
    area: coreIssues related to the framework runtime
    on Jan 8, 2018
  7. changed the title [-]TSC is faster than NGC[/-] [+]ngc watch is not incremental, runs full build[/+] on Jan 9, 2018
  8. 11 remaining items

  9. added a commit that references this issue on Mar 22, 2018
    7b2e1f1
  10. alippai commented on May 31, 2018

    @alippai
    ContributorAuthor

    @IgorMinar any updates? One of the two PRs is a single word typo, helps to make the watch a magnitude faster.

  11. alippai commented on Jun 16, 2018

    @alippai
    ContributorAuthor

    This is not something what should happen in open source. Maintaining code quality and having strategic goals in development is one thing, the intentional total lack of communication is an other. Not just not being able to fix a clear typo affecting the only compiler feature mentioned in Angular 5's release blog post (in 6 months!), but ignoring a contributors very first PR. This is not welcoming or inclusive. Better I stick to MS+FB+other open source projects, but not Google's next time.

    I really appreciate your hard work, the amount of expertise and work you share is wonderful and unique. You really help everybody. It's just not the open source project I expected it to be.

  12. sod commented on Aug 20, 2018

    @sod
    Contributor

    angular-cli or @ngtools/webpack doesn't rely on this code, so I guess ngc --watch is kind of in a blind spot.

    They have written off this compiler already as they write a new compiler (ivy) that can run file2file instead of managing the hole project. At least they have to if they want to leverage the power of bazel.

    Lets hope ivy works just like typescript. Can compile file by file and run diagnostics in a separate thread. So compile time comes done to milliseconds instead of seconds.

  13. added
    area: compilerIssues related to `ngc`, Angular's template compiler
    and removed
    area: coreIssues related to the framework runtime
    on Mar 12, 2020
  14. alxhub commented on May 28, 2020

    @alxhub
    Member

    Closing as fixed. @alippai's fix was merged in c6e5b97.

  15. angular-automatic-lock-bot commented on Jun 29, 2020

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  16. locked and limited conversation to collaborators on Jun 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions