refactor(ngcc): add debug logging for the duration of different operations (#32427)
This gives an overview of how much time is spent in each operation/phase and makes it easy to do rough comparisons of how different configurations or changes affect performance. PR Close #32427
This commit is contained in:
parent
e36e6c85ef
commit
c714330856
@ -14,6 +14,8 @@ import {ConsoleLogger, LogLevel} from './src/logging/console_logger';
|
|||||||
|
|
||||||
// CLI entry point
|
// CLI entry point
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
|
const startTime = Date.now();
|
||||||
|
|
||||||
const args = process.argv.slice(2);
|
const args = process.argv.slice(2);
|
||||||
const options =
|
const options =
|
||||||
yargs
|
yargs
|
||||||
@ -67,14 +69,22 @@ if (require.main === module) {
|
|||||||
|
|
||||||
(async() => {
|
(async() => {
|
||||||
try {
|
try {
|
||||||
|
const logger = logLevel && new ConsoleLogger(LogLevel[logLevel]);
|
||||||
|
|
||||||
await mainNgcc({
|
await mainNgcc({
|
||||||
basePath: baseSourcePath,
|
basePath: baseSourcePath,
|
||||||
propertiesToConsider,
|
propertiesToConsider,
|
||||||
targetEntryPointPath,
|
targetEntryPointPath,
|
||||||
compileAllFormats,
|
compileAllFormats,
|
||||||
logger: logLevel && new ConsoleLogger(LogLevel[logLevel]),
|
logger,
|
||||||
async: true,
|
async: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (logger) {
|
||||||
|
const duration = Math.round((Date.now() - startTime) / 1000);
|
||||||
|
logger.debug(`Run ngcc in ${duration}s.`);
|
||||||
|
}
|
||||||
|
|
||||||
process.exitCode = 0;
|
process.exitCode = 0;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error(e.stack || e.message);
|
console.error(e.stack || e.message);
|
||||||
|
@ -26,6 +26,7 @@ import {Deferred, sendMessageToWorker} from './utils';
|
|||||||
*/
|
*/
|
||||||
export class ClusterMaster {
|
export class ClusterMaster {
|
||||||
private finishedDeferred = new Deferred<void>();
|
private finishedDeferred = new Deferred<void>();
|
||||||
|
private processingStartTime: number = -1;
|
||||||
private taskAssignments = new Map<number, Task|null>();
|
private taskAssignments = new Map<number, Task|null>();
|
||||||
private taskQueue: TaskQueue;
|
private taskQueue: TaskQueue;
|
||||||
|
|
||||||
@ -67,6 +68,9 @@ export class ClusterMaster {
|
|||||||
|
|
||||||
// First, check whether all tasks have been completed.
|
// First, check whether all tasks have been completed.
|
||||||
if (this.taskQueue.allTasksCompleted) {
|
if (this.taskQueue.allTasksCompleted) {
|
||||||
|
const duration = Math.round((Date.now() - this.processingStartTime) / 1000);
|
||||||
|
this.logger.debug(`Processed tasks in ${duration}s.`);
|
||||||
|
|
||||||
return this.finishedDeferred.resolve();
|
return this.finishedDeferred.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -176,6 +180,11 @@ export class ClusterMaster {
|
|||||||
throw new Error(`Invariant violated: Worker #${workerId} came online more than once.`);
|
throw new Error(`Invariant violated: Worker #${workerId} came online more than once.`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.processingStartTime === -1) {
|
||||||
|
this.logger.debug('Processing tasks...');
|
||||||
|
this.processingStartTime = Date.now();
|
||||||
|
}
|
||||||
|
|
||||||
this.taskAssignments.set(workerId, null);
|
this.taskAssignments.set(workerId, null);
|
||||||
this.maybeDistributeWork();
|
this.maybeDistributeWork();
|
||||||
}
|
}
|
||||||
|
@ -27,11 +27,17 @@ export class SingleProcessExecutor implements Executor {
|
|||||||
createCompileFn((task, outcome) => onTaskCompleted(this.pkgJsonUpdater, task, outcome));
|
createCompileFn((task, outcome) => onTaskCompleted(this.pkgJsonUpdater, task, outcome));
|
||||||
|
|
||||||
// Process all tasks.
|
// Process all tasks.
|
||||||
|
this.logger.debug('Processing tasks...');
|
||||||
|
const startTime = Date.now();
|
||||||
|
|
||||||
while (!taskQueue.allTasksCompleted) {
|
while (!taskQueue.allTasksCompleted) {
|
||||||
const task = taskQueue.getNextTask() !;
|
const task = taskQueue.getNextTask() !;
|
||||||
compile(task);
|
compile(task);
|
||||||
taskQueue.markTaskCompleted(task);
|
taskQueue.markTaskCompleted(task);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const duration = Math.round((Date.now() - startTime) / 1000);
|
||||||
|
this.logger.debug(`Processed tasks in ${duration}s.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -141,6 +141,9 @@ export function mainNgcc(
|
|||||||
|
|
||||||
// The function for performing the analysis.
|
// The function for performing the analysis.
|
||||||
const analyzeEntryPoints: AnalyzeEntryPointsFn = () => {
|
const analyzeEntryPoints: AnalyzeEntryPointsFn = () => {
|
||||||
|
logger.debug('Analyzing entry-points...');
|
||||||
|
const startTime = Date.now();
|
||||||
|
|
||||||
const supportedPropertiesToConsider = ensureSupportedProperties(propertiesToConsider);
|
const supportedPropertiesToConsider = ensureSupportedProperties(propertiesToConsider);
|
||||||
|
|
||||||
const moduleResolver = new ModuleResolver(fileSystem, pathMappings);
|
const moduleResolver = new ModuleResolver(fileSystem, pathMappings);
|
||||||
@ -197,6 +200,11 @@ export function mainNgcc(
|
|||||||
unprocessableEntryPointPaths.map(path => `\n - ${path}`).join(''));
|
unprocessableEntryPointPaths.map(path => `\n - ${path}`).join(''));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const duration = Math.round((Date.now() - startTime) / 1000);
|
||||||
|
logger.debug(
|
||||||
|
`Analyzed ${entryPoints.length} entry-points in ${duration}s. ` +
|
||||||
|
`(Total tasks: ${tasks.length})`);
|
||||||
|
|
||||||
return getTaskQueue(inParallel, tasks, graph);
|
return getTaskQueue(inParallel, tasks, graph);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user