Skip to content

Commit d7efc45

Browse files
alan-agius4atscott
authored andcommitted
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
1 parent dc40a93 commit d7efc45

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

packages/compiler-cli/ngcc/src/execution/api.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export interface Task extends JsonObject {
6161

6262
/**
6363
* The list of all format properties (including `task.formatProperty`) that should be marked as
64-
* processed once the taksk has been completed, because they point to the format-path that will be
64+
* processed once the task has been completed, because they point to the format-path that will be
6565
* processed as part of the task.
6666
*/
6767
formatPropertiesToMarkAsProcessed: EntryPointJsonProperty[];
@@ -75,9 +75,6 @@ export type TaskCompletedCallback = (task: Task, outcome: TaskProcessingOutcome)
7575

7676
/** Represents the outcome of processing a `Task`. */
7777
export const enum TaskProcessingOutcome {
78-
/** The target format property was already processed - didn't have to do anything. */
79-
AlreadyProcessed,
80-
8178
/** Successfully processed the target format property. */
8279
Processed,
8380
}

packages/compiler-cli/ngcc/src/main.ts

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ import {ParallelTaskQueue} from './execution/task_selection/parallel_task_queue'
3333
import {SerialTaskQueue} from './execution/task_selection/serial_task_queue';
3434
import {ConsoleLogger, LogLevel} from './logging/console_logger';
3535
import {Logger} from './logging/logger';
36-
import {hasBeenProcessed, markAsProcessed} from './packages/build_marker';
36+
import {hasBeenProcessed} from './packages/build_marker';
3737
import {NgccConfiguration} from './packages/configuration';
3838
import {EntryPoint, EntryPointJsonProperty, EntryPointPackageJson, SUPPORTED_FORMAT_PROPERTIES, getEntryPointFormat} from './packages/entry_point';
3939
import {makeEntryPointBundle} from './packages/entry_point_bundle';
@@ -207,6 +207,12 @@ export function mainNgcc(
207207
}
208208

209209
for (const formatProperty of propertiesToProcess) {
210+
if (hasBeenProcessed(entryPoint.packageJson, formatProperty)) {
211+
// The format-path which the property maps to is already processed - nothing to do.
212+
logger.debug(`Skipping ${entryPoint.name} : ${formatProperty} (already compiled).`);
213+
continue;
214+
}
215+
210216
const formatPropertiesToMarkAsProcessed = equivalentPropertiesMap.get(formatProperty) !;
211217
tasks.push({entryPoint, formatProperty, formatPropertiesToMarkAsProcessed, processDts});
212218

@@ -256,13 +262,6 @@ export function mainNgcc(
256262
`${formatProperty} (formatPath: ${formatPath} | format: ${format})`);
257263
}
258264

259-
// The format-path which the property maps to is already processed - nothing to do.
260-
if (hasBeenProcessed(packageJson, formatProperty)) {
261-
logger.debug(`Skipping ${entryPoint.name} : ${formatProperty} (already compiled).`);
262-
onTaskCompleted(task, TaskProcessingOutcome.AlreadyProcessed);
263-
return;
264-
}
265-
266265
const bundle = makeEntryPointBundle(
267266
fileSystem, entryPoint, formatPath, isCore, format, processDts, pathMappings, true,
268267
enableI18nLegacyMessageIdFormat);

packages/compiler-cli/ngcc/test/execution/cluster/worker_spec.ts

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,15 +58,8 @@ describe('ClusterWorker', () => {
5858
new ClusterWorker(mockLogger, createCompileFnSpy);
5959
const onTaskCompleted: TaskCompletedCallback = createCompileFnSpy.calls.argsFor(0)[0];
6060

61-
onTaskCompleted(null as any, TaskProcessingOutcome.AlreadyProcessed);
62-
expect(processSendSpy).toHaveBeenCalledTimes(1);
63-
expect(processSendSpy).toHaveBeenCalledWith({
64-
type: 'task-completed',
65-
outcome: TaskProcessingOutcome.AlreadyProcessed,
66-
});
67-
6861
onTaskCompleted(null as any, TaskProcessingOutcome.Processed);
69-
expect(processSendSpy).toHaveBeenCalledTimes(2);
62+
expect(processSendSpy).toHaveBeenCalledTimes(1);
7063
expect(processSendSpy).toHaveBeenCalledWith({
7164
type: 'task-completed',
7265
outcome: TaskProcessingOutcome.Processed,

0 commit comments

Comments
 (0)