From 5fee0e24a613f512c4e2c1b706bc6cc49080faae Mon Sep 17 00:00:00 2001 From: Jeremy Rifkin <51220084+jeremy-rifkin@users.noreply.github.com> Date: Mon, 27 Feb 2023 18:05:41 -0500 Subject: [PATCH] Temporarily collect metrics on job time and queue time (#4790) Collecting raw data points for job time and queue time for a few days. Briefly discussed with Matt, will be reverting in a few days. --- lib/base-compiler.ts | 2 +- lib/compilation-env.ts | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/base-compiler.ts b/lib/base-compiler.ts index e9f411566..0e4da1843 100644 --- a/lib/base-compiler.ts +++ b/lib/base-compiler.ts @@ -334,7 +334,7 @@ export class BaseCompiler implements ICompiler { const key = this.getCompilerCacheKey(compiler, args, options); let result = await this.env.compilerCacheGet(key as any); if (!result) { - result = await this.env.enqueue(async () => await exec.execute(compiler, args, options)); + result = await this.env.enqueue(async () => await exec.execute(compiler, args, options), true); if (result.okToCache) { this.env .compilerCachePut(key as any, result, undefined) diff --git a/lib/compilation-env.ts b/lib/compilation-env.ts index dc5f9155d..c01c85494 100644 --- a/lib/compilation-env.ts +++ b/lib/compilation-env.ts @@ -151,8 +151,21 @@ export class CompilationEnvironment { return this.executableCache.put(key, fs.readFileSync(filepath)); } - enqueue(job: Job) { - return this.compilationQueue.enqueue(job); + enqueue(job: Job, silent?: boolean) { + const enqueue_time = performance.now(); + return this.compilationQueue.enqueue(async () => { + const launch_time = performance.now(); + const res = await job(); + const finish_time = performance.now(); + if (!silent) { + logger.info( + `(compilation wall clock time: ${Math.round(finish_time - launch_time)} ms, queue time: ${ + launch_time - enqueue_time + } ms)`, + ); + } + return res; + }); } findBadOptions(options: string[]) {