perf(ivy): ngcc - exit early if the targeted package has been compiled#29740
perf(ivy): ngcc - exit early if the targeted package has been compiled#29740petebacondarwin wants to merge 2 commits into
Conversation
b69a88e to
a283b5d
Compare
Previously the console logger was being used in integration tests leading to lots of output during test runs.
Previously we always walked the whole folder tree looking for entry-points before we tested whether a target package had been processed already. This could take >10secs! This commit does a quick check of the target package before doing the full walk which brings down the execution time for ngcc in this case dramatically. ``` $ time ./node_modules/.bin/ivy-ngcc -t @angular/common/http/testing Compiling @angular/core : fesm2015 as esm2015 Compiling @angular/core : fesm5 as esm5 Compiling @angular/core : esm2015 as esm2015 Compiling @angular/core : esm5 as esm5 Compiling @angular/common/http : fesm2015 as esm2015 Compiling @angular/common/http : fesm5 as esm5 Compiling @angular/common/http : esm2015 as esm2015 Compiling @angular/common/http : esm5 as esm5 Compiling @angular/common/http/testing : fesm2015 as esm2015 Compiling @angular/common/http/testing : fesm5 as esm5 Compiling @angular/common/http/testing : esm2015 as esm2015 Compiling @angular/common/http/testing : esm5 as esm5 real 0m19.766s user 0m28.533s sys 0m2.262s ``` ``` $ time ./node_modules/.bin/ivy-ngcc -t @angular/common/http/testing The target entry-point has already been processed real 0m0.666s user 0m0.605s sys 0m0.113s ```
a283b5d to
86c941c
Compare
| import {EntryPointJsonProperty, EntryPointPackageJson, SUPPORTED_FORMAT_PROPERTIES} from '../../src/packages/entry_point'; | ||
| import {MockLogger} from '../helpers/mock_logger'; | ||
|
|
||
| const _ = AbsoluteFsPath.from; |
There was a problem hiding this comment.
In unit tests I have to create AbsoluteFsPaths from strings all over the place, so I got into a habit of aliasing AbsoluteFsPath.from() to _() to make the tests less verbose.
I realise that in this file I only use it once so perhaps that isn't necessary. :-)
There was a problem hiding this comment.
I typically associate _ with lodash or underscore 😜.
There was a problem hiding this comment.
That's so 1990s :-P
Check out https://github.com/angular/angular/blob/master/packages/compiler-cli/ngcc/test/packages/dependency_host_spec.ts for an example of this being actually useful.
| return createNewEntryPointFormats ? new NewEntryPointFileWriter() : new InPlaceFileWriter(); | ||
| } | ||
|
|
||
| function hasProcessedTargetEntryPoint( |
#29740) Previously we always walked the whole folder tree looking for entry-points before we tested whether a target package had been processed already. This could take >10secs! This commit does a quick check of the target package before doing the full walk which brings down the execution time for ngcc in this case dramatically. ``` $ time ./node_modules/.bin/ivy-ngcc -t @angular/common/http/testing Compiling @angular/core : fesm2015 as esm2015 Compiling @angular/core : fesm5 as esm5 Compiling @angular/core : esm2015 as esm2015 Compiling @angular/core : esm5 as esm5 Compiling @angular/common/http : fesm2015 as esm2015 Compiling @angular/common/http : fesm5 as esm5 Compiling @angular/common/http : esm2015 as esm2015 Compiling @angular/common/http : esm5 as esm5 Compiling @angular/common/http/testing : fesm2015 as esm2015 Compiling @angular/common/http/testing : fesm5 as esm5 Compiling @angular/common/http/testing : esm2015 as esm2015 Compiling @angular/common/http/testing : esm5 as esm5 real 0m19.766s user 0m28.533s sys 0m2.262s ``` ``` $ time ./node_modules/.bin/ivy-ngcc -t @angular/common/http/testing The target entry-point has already been processed real 0m0.666s user 0m0.605s sys 0m0.113s ``` PR Close #29740
gkalpak
left a comment
There was a problem hiding this comment.
Post-merge review, because...why not 😇
|
|
||
| function hasProcessedTargetEntryPoint( | ||
| targetPath: AbsoluteFsPath, propertiesToConsider: string[], compileAllFormats: boolean) { | ||
| const packageJsonPath = AbsoluteFsPath.from(resolve(targetPath, 'package.json')); |
There was a problem hiding this comment.
Since you are concerned with speed. fromUnchecked() should be (negligibly) faster (and sufficient) 😁
There was a problem hiding this comment.
I'll fix that up next time I am touching this code.
| } | ||
| } | ||
| // Either all formats need to be compiled and there were none that were unprocessed, | ||
| // Or only the one matching format needs to be compiled but there was at least one matching |
Previously the console logger was being used in integration tests leading to lots of output during test runs. PR Close angular#29740
angular#29740) Previously we always walked the whole folder tree looking for entry-points before we tested whether a target package had been processed already. This could take >10secs! This commit does a quick check of the target package before doing the full walk which brings down the execution time for ngcc in this case dramatically. ``` $ time ./node_modules/.bin/ivy-ngcc -t @angular/common/http/testing Compiling @angular/core : fesm2015 as esm2015 Compiling @angular/core : fesm5 as esm5 Compiling @angular/core : esm2015 as esm2015 Compiling @angular/core : esm5 as esm5 Compiling @angular/common/http : fesm2015 as esm2015 Compiling @angular/common/http : fesm5 as esm5 Compiling @angular/common/http : esm2015 as esm2015 Compiling @angular/common/http : esm5 as esm5 Compiling @angular/common/http/testing : fesm2015 as esm2015 Compiling @angular/common/http/testing : fesm5 as esm5 Compiling @angular/common/http/testing : esm2015 as esm2015 Compiling @angular/common/http/testing : esm5 as esm5 real 0m19.766s user 0m28.533s sys 0m2.262s ``` ``` $ time ./node_modules/.bin/ivy-ngcc -t @angular/common/http/testing The target entry-point has already been processed real 0m0.666s user 0m0.605s sys 0m0.113s ``` PR Close angular#29740
|
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
This is a quick fix for webpack but there are more optimisations to be achieved on the
first time run by replacing the TS module resolver for the initial walk of the tree.
Previously we always walked the whole folder tree looking for
entry-points before we tested whether a target package had been
processed already. This could take >10secs!
This commit does a quick check of the target package before doing
the full walk which brings down the execution time for ngcc in this
case dramatically.