Skip to content

Commit f842355

Browse files
committed
more perf tracking
1 parent 3a76955 commit f842355

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
@@ -231,6 +231,8 @@ export class DataSchemaCompiler {
231231
|| f.fileName.endsWith('.yaml')
232232
|| f.fileName.endsWith('.jinja')).map(f => ({ ...f }));
233233

234+
const jinjaLoaderTimer = perfTracker.start('loadJinjaTemplates');
235+
234236
const jinjaTemplatedFiles = toCompile.filter((file) => file.fileName.endsWith('.jinja') ||
235237
(file.fileName.endsWith('.yml') || file.fileName.endsWith('.yaml')) && file.content.match(JINJA_SYNTAX));
236238

@@ -239,6 +241,8 @@ export class DataSchemaCompiler {
239241
this.loadJinjaTemplates(jinjaTemplatedFiles);
240242
}
241243

244+
jinjaLoaderTimer.end();
245+
242246
const errorsReport = new ErrorReporter(null, [], this.errorReportOptions);
243247
this.errorsReporter = errorsReport;
244248

@@ -566,6 +570,8 @@ export class DataSchemaCompiler {
566570
): Promise<(FileContent | undefined)> {
567571
try {
568572
if (getEnv('transpilationNative')) {
573+
const compileJsFileTimer = perfTracker.start('transpileJsFile (native)');
574+
569575
const reqData = {
570576
fileName: file.fileName,
571577
fileContent: file.content,
@@ -587,8 +593,12 @@ export class DataSchemaCompiler {
587593
errorsReport.addWarnings(res[0].warnings as unknown as SyntaxErrorInterface[]);
588594
errorsReport.exitFile();
589595

596+
compileJsFileTimer.end();
597+
590598
return { ...file, content: res[0].code };
591599
} else if (getEnv('transpilationWorkerThreads')) {
600+
const compileJsFileTimer = perfTracker.start('transpileJsFile (threads)');
601+
592602
const data = {
593603
fileName: file.fileName,
594604
content: file.content,
@@ -601,8 +611,12 @@ export class DataSchemaCompiler {
601611
errorsReport.addErrors(res.errors);
602612
errorsReport.addWarnings(res.warnings);
603613

614+
compileJsFileTimer.end();
615+
604616
return { ...file, content: res.content };
605617
} else {
618+
const compileJsFileTimer = perfTracker.start('transpileJsFile (inplace)');
619+
606620
const ast = parse(
607621
file.content,
608622
{
@@ -619,6 +633,9 @@ export class DataSchemaCompiler {
619633
errorsReport.exitFile();
620634

621635
const content = babelGenerator(ast, {}, file.content).code;
636+
637+
compileJsFileTimer.end();
638+
622639
return { ...file, content };
623640
}
624641
} catch (e: any) {
@@ -652,6 +669,8 @@ export class DataSchemaCompiler {
652669
}
653670

654671
if (getEnv('transpilationNative')) {
672+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (native)');
673+
655674
const reqData = {
656675
fileName: file.fileName,
657676
fileContent: file.content,
@@ -670,8 +689,12 @@ export class DataSchemaCompiler {
670689

671690
this.compiledYamlCache.set(cacheKey, res[0].code);
672691

692+
transpileYamlFileTimer.end();
693+
673694
return { ...file };
674695
} else if (getEnv('transpilationWorkerThreads')) {
696+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (threads)');
697+
675698
const data = {
676699
fileName: file.fileName,
677700
content: file.content,
@@ -689,8 +712,12 @@ export class DataSchemaCompiler {
689712

690713
this.compiledYamlCache.set(cacheKey, res.content);
691714

715+
transpileYamlFileTimer.end();
716+
692717
return { ...file };
693718
} else {
719+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (inplace)');
720+
694721
const transpiledFile = this.yamlCompiler.transpileYamlFile(file, errorsReport);
695722

696723
if (transpiledFile) {
@@ -700,6 +727,8 @@ export class DataSchemaCompiler {
700727

701728
this.compiledYamlCache.set(cacheKey, transpiledFile?.content || '');
702729

730+
transpileYamlFileTimer.end();
731+
703732
return transpiledFile;
704733
}
705734
}
@@ -714,6 +743,8 @@ export class DataSchemaCompiler {
714743
// } else if (getEnv('transpilationWorkerThreads')) {
715744
//
716745
// } else {
746+
const transpileJinjaFileTimer = perfTracker.start('transpileJinjaFile (common)');
747+
717748
const transpiledFile = await this.yamlCompiler.compileYamlWithJinjaFile(
718749
file,
719750
errorsReport,
@@ -728,6 +759,8 @@ export class DataSchemaCompiler {
728759
file.convertedToJs = true;
729760
}
730761

762+
transpileJinjaFileTimer.end();
763+
731764
return transpiledFile;
732765
// }
733766
}

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)