Skip to content

Commit

Permalink
perf(ngcc): only create tasks for non-processed formats (#35719) (#35832
Browse files Browse the repository at this point in the history
)

Change the behaviour in `analyzeEntryPoints` to only create tasks for non-processed formats.

PR Close #35719

PR Close #35832
  • Loading branch information
alan-agius4 authored and atscott committed Mar 3, 2020
1 parent 525dc6a commit 3fdd304
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 20 deletions.
5 changes: 1 addition & 4 deletions packages/compiler-cli/ngcc/src/execution/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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[];
Expand All @@ -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,
}
Expand Down
15 changes: 7 additions & 8 deletions packages/compiler-cli/ngcc/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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});

Expand Down Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 3fdd304

Please sign in to comment.