Skip to content

Commit 5e4943c

Browse files
committed
more perf tracking
1 parent a2d93de commit 5e4943c

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
@@ -225,6 +225,8 @@ export class DataSchemaCompiler {
225225
? files.filter(f => this.filesToCompile.includes(f.fileName))
226226
: files;
227227

228+
const jinjaLoaderTimer = perfTracker.start('loadJinjaTemplates');
229+
228230
const jinjaTemplatedFiles = toCompile.filter((file) => file.fileName.endsWith('.jinja') ||
229231
(file.fileName.endsWith('.yml') || file.fileName.endsWith('.yaml')) && file.content.match(JINJA_SYNTAX));
230232

@@ -233,6 +235,8 @@ export class DataSchemaCompiler {
233235
this.loadJinjaTemplates(jinjaTemplatedFiles);
234236
}
235237

238+
jinjaLoaderTimer.end();
239+
236240
const errorsReport = new ErrorReporter(null, [], this.errorReportOptions);
237241
this.errorsReporter = errorsReport;
238242

@@ -578,6 +582,8 @@ export class DataSchemaCompiler {
578582
): Promise<(FileContent | undefined)> {
579583
try {
580584
if (getEnv('transpilationNative')) {
585+
const compileJsFileTimer = perfTracker.start('transpileJsFile (native)');
586+
581587
const reqData = {
582588
fileName: file.fileName,
583589
fileContent: file.content,
@@ -599,8 +605,12 @@ export class DataSchemaCompiler {
599605
errorsReport.addWarnings(res[0].warnings as unknown as SyntaxErrorInterface[]);
600606
errorsReport.exitFile();
601607

608+
compileJsFileTimer.end();
609+
602610
return { ...file, content: res[0].code };
603611
} else if (getEnv('transpilationWorkerThreads')) {
612+
const compileJsFileTimer = perfTracker.start('transpileJsFile (threads)');
613+
604614
const data = {
605615
fileName: file.fileName,
606616
content: file.content,
@@ -613,8 +623,12 @@ export class DataSchemaCompiler {
613623
errorsReport.addErrors(res.errors);
614624
errorsReport.addWarnings(res.warnings);
615625

626+
compileJsFileTimer.end();
627+
616628
return { ...file, content: res.content };
617629
} else {
630+
const compileJsFileTimer = perfTracker.start('transpileJsFile (inplace)');
631+
618632
const ast = parse(
619633
file.content,
620634
{
@@ -631,6 +645,9 @@ export class DataSchemaCompiler {
631645
errorsReport.exitFile();
632646

633647
const content = babelGenerator(ast, {}, file.content).code;
648+
649+
compileJsFileTimer.end();
650+
634651
return { ...file, content };
635652
}
636653
} catch (e: any) {
@@ -655,6 +672,8 @@ export class DataSchemaCompiler {
655672
{ cubeNames, cubeSymbols, compilerId }: TranspileOptions
656673
): Promise<(FileContent | undefined)> {
657674
if (getEnv('transpilationNative')) {
675+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (native)');
676+
658677
const reqData = {
659678
fileName: file.fileName,
660679
fileContent: file.content,
@@ -671,8 +690,12 @@ export class DataSchemaCompiler {
671690
file.content = res[0].code;
672691
file.convertedToJs = true;
673692

693+
transpileYamlFileTimer.end();
694+
674695
return { ...file, content: res[0].code };
675696
} else if (getEnv('transpilationWorkerThreads')) {
697+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (threads)');
698+
676699
const data = {
677700
fileName: file.fileName,
678701
content: file.content,
@@ -688,15 +711,21 @@ export class DataSchemaCompiler {
688711
file.content = res.content;
689712
file.convertedToJs = true;
690713

714+
transpileYamlFileTimer.end();
715+
691716
return { ...file, content: res.content };
692717
} else {
718+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (inplace)');
719+
693720
const transpiledFile = this.yamlCompiler.transpileYamlFile(file, errorsReport);
694721

695722
if (transpiledFile) {
696723
file.content = transpiledFile.content;
697724
file.convertedToJs = true;
698725
}
699726

727+
transpileYamlFileTimer.end();
728+
700729
return transpiledFile;
701730
}
702731
}
@@ -711,6 +740,8 @@ export class DataSchemaCompiler {
711740
// } else if (getEnv('transpilationWorkerThreads')) {
712741
//
713742
// } else {
743+
const transpileJinjaFileTimer = perfTracker.start('transpileJinjaFile (common)');
744+
714745
const transpiledFile = await this.yamlCompiler.compileYamlWithJinjaFile(
715746
file,
716747
errorsReport,
@@ -725,6 +756,8 @@ export class DataSchemaCompiler {
725756
file.convertedToJs = true;
726757
}
727758

759+
transpileJinjaFileTimer.end();
760+
728761
return transpiledFile;
729762
// }
730763
}

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)