Skip to content

Commit 1fb23aa

Browse files
committed
more perf tracking
1 parent b518579 commit 1fb23aa

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

packages/cubejs-schema-compiler/src/compiler/DataSchemaCompiler.ts

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,8 @@ export class DataSchemaCompiler {
227227
? files.filter(f => this.filesToCompile.includes(f.fileName)).map(f => ({ ...f }))
228228
: files.map(f => ({ ...f }));
229229

230+
const jinjaLoaderTimer = perfTracker.start('loadJinjaTemplates');
231+
230232
const jinjaTemplatedFiles = toCompile.filter((file) => file.fileName.endsWith('.jinja') ||
231233
(file.fileName.endsWith('.yml') || file.fileName.endsWith('.yaml')) && file.content.match(JINJA_SYNTAX));
232234

@@ -235,6 +237,8 @@ export class DataSchemaCompiler {
235237
this.loadJinjaTemplates(jinjaTemplatedFiles);
236238
}
237239

240+
jinjaLoaderTimer.end();
241+
238242
const errorsReport = new ErrorReporter(null, [], this.errorReportOptions);
239243
this.errorsReporter = errorsReport;
240244

@@ -562,6 +566,8 @@ export class DataSchemaCompiler {
562566
): Promise<(FileContent | undefined)> {
563567
try {
564568
if (getEnv('transpilationNative')) {
569+
const compileJsFileTimer = perfTracker.start('transpileJsFile (native)');
570+
565571
const reqData = {
566572
fileName: file.fileName,
567573
fileContent: file.content,
@@ -583,8 +589,12 @@ export class DataSchemaCompiler {
583589
errorsReport.addWarnings(res[0].warnings as unknown as SyntaxErrorInterface[]);
584590
errorsReport.exitFile();
585591

592+
compileJsFileTimer.end();
593+
586594
return { ...file, content: res[0].code };
587595
} else if (getEnv('transpilationWorkerThreads')) {
596+
const compileJsFileTimer = perfTracker.start('transpileJsFile (threads)');
597+
588598
const data = {
589599
fileName: file.fileName,
590600
content: file.content,
@@ -597,8 +607,12 @@ export class DataSchemaCompiler {
597607
errorsReport.addErrors(res.errors);
598608
errorsReport.addWarnings(res.warnings);
599609

610+
compileJsFileTimer.end();
611+
600612
return { ...file, content: res.content };
601613
} else {
614+
const compileJsFileTimer = perfTracker.start('transpileJsFile (inplace)');
615+
602616
const ast = parse(
603617
file.content,
604618
{
@@ -615,6 +629,9 @@ export class DataSchemaCompiler {
615629
errorsReport.exitFile();
616630

617631
const content = babelGenerator(ast, {}, file.content).code;
632+
633+
compileJsFileTimer.end();
634+
618635
return { ...file, content };
619636
}
620637
} catch (e: any) {
@@ -648,6 +665,8 @@ export class DataSchemaCompiler {
648665
}
649666

650667
if (getEnv('transpilationNative')) {
668+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (native)');
669+
651670
const reqData = {
652671
fileName: file.fileName,
653672
fileContent: file.content,
@@ -666,8 +685,12 @@ export class DataSchemaCompiler {
666685

667686
this.compiledYamlCache.set(cacheKey, res[0].code);
668687

688+
transpileYamlFileTimer.end();
689+
669690
return { ...file };
670691
} else if (getEnv('transpilationWorkerThreads')) {
692+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (threads)');
693+
671694
const data = {
672695
fileName: file.fileName,
673696
content: file.content,
@@ -685,8 +708,12 @@ export class DataSchemaCompiler {
685708

686709
this.compiledYamlCache.set(cacheKey, res.content);
687710

711+
transpileYamlFileTimer.end();
712+
688713
return { ...file };
689714
} else {
715+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (inplace)');
716+
690717
const transpiledFile = this.yamlCompiler.transpileYamlFile(file, errorsReport);
691718

692719
if (transpiledFile) {
@@ -696,6 +723,8 @@ export class DataSchemaCompiler {
696723

697724
this.compiledYamlCache.set(cacheKey, transpiledFile?.content || '');
698725

726+
transpileYamlFileTimer.end();
727+
699728
return transpiledFile;
700729
}
701730
}
@@ -710,6 +739,8 @@ export class DataSchemaCompiler {
710739
// } else if (getEnv('transpilationWorkerThreads')) {
711740
//
712741
// } else {
742+
const transpileJinjaFileTimer = perfTracker.start('transpileJinjaFile (common)');
743+
713744
const transpiledFile = await this.yamlCompiler.compileYamlWithJinjaFile(
714745
file,
715746
errorsReport,
@@ -724,6 +755,8 @@ export class DataSchemaCompiler {
724755
file.convertedToJs = true;
725756
}
726757

758+
transpileJinjaFileTimer.end();
759+
727760
return transpiledFile;
728761
// }
729762
}

packages/cubejs-schema-compiler/src/compiler/YamlCompiler.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import { nonStringFields } from './CubeValidator';
1919
import { ErrorReporter } from './ErrorReporter';
2020
import { camelizeCube } from './utils';
2121
import { CompileContext } from './DataSchemaCompiler';
22+
import { perfTracker } from './PerfTracker';
2223

2324
type EscapeStateStack = {
2425
inFormattedStr?: boolean;
@@ -72,7 +73,10 @@ export class YamlCompiler {
7273
): Promise<FileContent | undefined> {
7374
const renderedFile = await this.renderTemplate(file, compileContext, pythonContext);
7475

75-
return this.transpileYamlFile(renderedFile, errorsReport);
76+
const transpileJinjaFileTimer2 = perfTracker.start('compile Jinja - transpileYamlFile');
77+
const res = this.transpileYamlFile(renderedFile, errorsReport);
78+
transpileJinjaFileTimer2.end();
79+
return res;
7680
}
7781

7882
public transpileYamlFile(

0 commit comments

Comments
 (0)