From d7efc45c0498b1622182e56a9093ee3e2413660a Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Fri, 28 Feb 2020 08:53:07 +0100 Subject: [PATCH] perf(ngcc): only create tasks for non-processed formats (#35719) Change the behaviour in `analyzeEntryPoints` to only create tasks for non-processed formats. PR Close #35719 --- packages/compiler-cli/ngcc/src/execution/api.ts | 5 +---- packages/compiler-cli/ngcc/src/main.ts | 15 +++++++-------- .../ngcc/test/execution/cluster/worker_spec.ts | 9 +-------- 3 files changed, 9 insertions(+), 20 deletions(-) diff --git a/packages/compiler-cli/ngcc/src/execution/api.ts b/packages/compiler-cli/ngcc/src/execution/api.ts index bee2e94354..be8fd5813f 100644 --- a/packages/compiler-cli/ngcc/src/execution/api.ts +++ b/packages/compiler-cli/ngcc/src/execution/api.ts @@ -61,7 +61,7 @@ export interface Task extends JsonObject { /** * The list of all format properties (including `task.formatProperty`) that should be marked as - * processed once the taksk has been completed, because they point to the format-path that will be + * processed once the task has been completed, because they point to the format-path that will be * processed as part of the task. */ formatPropertiesToMarkAsProcessed: EntryPointJsonProperty[]; @@ -75,9 +75,6 @@ export type TaskCompletedCallback = (task: Task, outcome: TaskProcessingOutcome) /** Represents the outcome of processing a `Task`. */ export const enum TaskProcessingOutcome { - /** The target format property was already processed - didn't have to do anything. */ - AlreadyProcessed, - /** Successfully processed the target format property. */ Processed, } diff --git a/packages/compiler-cli/ngcc/src/main.ts b/packages/compiler-cli/ngcc/src/main.ts index a335afb665..ee21f09487 100644 --- a/packages/compiler-cli/ngcc/src/main.ts +++ b/packages/compiler-cli/ngcc/src/main.ts @@ -33,7 +33,7 @@ import {ParallelTaskQueue} from './execution/task_selection/parallel_task_queue' import {SerialTaskQueue} from './execution/task_selection/serial_task_queue'; import {ConsoleLogger, LogLevel} from './logging/console_logger'; import {Logger} from './logging/logger'; -import {hasBeenProcessed, markAsProcessed} from './packages/build_marker'; +import {hasBeenProcessed} from './packages/build_marker'; import {NgccConfiguration} from './packages/configuration'; import {EntryPoint, EntryPointJsonProperty, EntryPointPackageJson, SUPPORTED_FORMAT_PROPERTIES, getEntryPointFormat} from './packages/entry_point'; import {makeEntryPointBundle} from './packages/entry_point_bundle'; @@ -207,6 +207,12 @@ export function mainNgcc( } for (const formatProperty of propertiesToProcess) { + if (hasBeenProcessed(entryPoint.packageJson, formatProperty)) { + // The format-path which the property maps to is already processed - nothing to do. + logger.debug(`Skipping ${entryPoint.name} : ${formatProperty} (already compiled).`); + continue; + } + const formatPropertiesToMarkAsProcessed = equivalentPropertiesMap.get(formatProperty) !; tasks.push({entryPoint, formatProperty, formatPropertiesToMarkAsProcessed, processDts}); @@ -256,13 +262,6 @@ export function mainNgcc( `${formatProperty} (formatPath: ${formatPath} | format: ${format})`); } - // The format-path which the property maps to is already processed - nothing to do. - if (hasBeenProcessed(packageJson, formatProperty)) { - logger.debug(`Skipping ${entryPoint.name} : ${formatProperty} (already compiled).`); - onTaskCompleted(task, TaskProcessingOutcome.AlreadyProcessed); - return; - } - const bundle = makeEntryPointBundle( fileSystem, entryPoint, formatPath, isCore, format, processDts, pathMappings, true, enableI18nLegacyMessageIdFormat); diff --git a/packages/compiler-cli/ngcc/test/execution/cluster/worker_spec.ts b/packages/compiler-cli/ngcc/test/execution/cluster/worker_spec.ts index 4d1f3a380f..201d469bb5 100644 --- a/packages/compiler-cli/ngcc/test/execution/cluster/worker_spec.ts +++ b/packages/compiler-cli/ngcc/test/execution/cluster/worker_spec.ts @@ -58,15 +58,8 @@ describe('ClusterWorker', () => { new ClusterWorker(mockLogger, createCompileFnSpy); const onTaskCompleted: TaskCompletedCallback = createCompileFnSpy.calls.argsFor(0)[0]; - onTaskCompleted(null as any, TaskProcessingOutcome.AlreadyProcessed); - expect(processSendSpy).toHaveBeenCalledTimes(1); - expect(processSendSpy).toHaveBeenCalledWith({ - type: 'task-completed', - outcome: TaskProcessingOutcome.AlreadyProcessed, - }); - onTaskCompleted(null as any, TaskProcessingOutcome.Processed); - expect(processSendSpy).toHaveBeenCalledTimes(2); + expect(processSendSpy).toHaveBeenCalledTimes(1); expect(processSendSpy).toHaveBeenCalledWith({ type: 'task-completed', outcome: TaskProcessingOutcome.Processed,