Skip to content

Commit 5680972

Browse files
committed
more perf tracking
1 parent 69e9fbc commit 5680972

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
@@ -221,6 +221,8 @@ export class DataSchemaCompiler {
221221
? files.filter(f => this.filesToCompile.includes(f.fileName))
222222
: files;
223223

224+
const jinjaLoaderTimer = perfTracker.start('loadJinjaTemplates');
225+
224226
const jinjaTemplatedFiles = toCompile.filter((file) => file.fileName.endsWith('.jinja') ||
225227
(file.fileName.endsWith('.yml') || file.fileName.endsWith('.yaml')) && file.content.match(JINJA_SYNTAX));
226228

@@ -229,6 +231,8 @@ export class DataSchemaCompiler {
229231
this.loadJinjaTemplates(jinjaTemplatedFiles);
230232
}
231233

234+
jinjaLoaderTimer.end();
235+
232236
const errorsReport = new ErrorReporter(null, [], this.errorReportOptions);
233237
this.errorsReporter = errorsReport;
234238

@@ -555,6 +559,8 @@ export class DataSchemaCompiler {
555559
): Promise<(FileContent | undefined)> {
556560
try {
557561
if (getEnv('transpilationNative')) {
562+
const compileJsFileTimer = perfTracker.start('transpileJsFile (native)');
563+
558564
const reqData = {
559565
fileName: file.fileName,
560566
fileContent: file.content,
@@ -576,8 +582,12 @@ export class DataSchemaCompiler {
576582
errorsReport.addWarnings(res[0].warnings as unknown as SyntaxErrorInterface[]);
577583
errorsReport.exitFile();
578584

585+
compileJsFileTimer.end();
586+
579587
return { ...file, content: res[0].code };
580588
} else if (getEnv('transpilationWorkerThreads')) {
589+
const compileJsFileTimer = perfTracker.start('transpileJsFile (threads)');
590+
581591
const data = {
582592
fileName: file.fileName,
583593
content: file.content,
@@ -590,8 +600,12 @@ export class DataSchemaCompiler {
590600
errorsReport.addErrors(res.errors);
591601
errorsReport.addWarnings(res.warnings);
592602

603+
compileJsFileTimer.end();
604+
593605
return { ...file, content: res.content };
594606
} else {
607+
const compileJsFileTimer = perfTracker.start('transpileJsFile (inplace)');
608+
595609
const ast = parse(
596610
file.content,
597611
{
@@ -608,6 +622,9 @@ export class DataSchemaCompiler {
608622
errorsReport.exitFile();
609623

610624
const content = babelGenerator(ast, {}, file.content).code;
625+
626+
compileJsFileTimer.end();
627+
611628
return { ...file, content };
612629
}
613630
} catch (e: any) {
@@ -632,6 +649,8 @@ export class DataSchemaCompiler {
632649
{ cubeNames, cubeSymbols, compilerId }: TranspileOptions
633650
): Promise<(FileContent | undefined)> {
634651
if (getEnv('transpilationNative')) {
652+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (native)');
653+
635654
const reqData = {
636655
fileName: file.fileName,
637656
fileContent: file.content,
@@ -648,8 +667,12 @@ export class DataSchemaCompiler {
648667
file.content = res[0].code;
649668
file.convertedToJs = true;
650669

670+
transpileYamlFileTimer.end();
671+
651672
return { ...file, content: res[0].code };
652673
} else if (getEnv('transpilationWorkerThreads')) {
674+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (threads)');
675+
653676
const data = {
654677
fileName: file.fileName,
655678
content: file.content,
@@ -665,15 +688,21 @@ export class DataSchemaCompiler {
665688
file.content = res.content;
666689
file.convertedToJs = true;
667690

691+
transpileYamlFileTimer.end();
692+
668693
return { ...file, content: res.content };
669694
} else {
695+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (inplace)');
696+
670697
const transpiledFile = this.yamlCompiler.transpileYamlFile(file, errorsReport);
671698

672699
if (transpiledFile) {
673700
file.content = transpiledFile.content;
674701
file.convertedToJs = true;
675702
}
676703

704+
transpileYamlFileTimer.end();
705+
677706
return transpiledFile;
678707
}
679708
}
@@ -688,6 +717,8 @@ export class DataSchemaCompiler {
688717
// } else if (getEnv('transpilationWorkerThreads')) {
689718
//
690719
// } else {
720+
const transpileJinjaFileTimer = perfTracker.start('transpileJinjaFile (common)');
721+
691722
const transpiledFile = await this.yamlCompiler.compileYamlWithJinjaFile(
692723
file,
693724
errorsReport,
@@ -702,6 +733,8 @@ export class DataSchemaCompiler {
702733
file.convertedToJs = true;
703734
}
704735

736+
transpileJinjaFileTimer.end();
737+
705738
return transpiledFile;
706739
// }
707740
}

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)