Skip to content

Commit 00d1bf1

Browse files
committed
more perf tracking
1 parent e7864a7 commit 00d1bf1

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -636,6 +636,8 @@ export class DataSchemaCompiler {
636636
): Promise<(FileContent | undefined)> {
637637
try {
638638
if (getEnv('transpilationNative')) {
639+
const compileJsFileTimer = perfTracker.start('transpileJsFile (native)');
640+
639641
const reqData = {
640642
fileName: file.fileName,
641643
fileContent: file.content,
@@ -657,8 +659,12 @@ export class DataSchemaCompiler {
657659
errorsReport.addWarnings(res[0].warnings as unknown as SyntaxErrorInterface[]);
658660
errorsReport.exitFile();
659661

662+
compileJsFileTimer.end();
663+
660664
return { ...file, content: res[0].code };
661665
} else if (getEnv('transpilationWorkerThreads')) {
666+
const compileJsFileTimer = perfTracker.start('transpileJsFile (threads)');
667+
662668
const data = {
663669
fileName: file.fileName,
664670
content: file.content,
@@ -671,8 +677,12 @@ export class DataSchemaCompiler {
671677
errorsReport.addErrors(res.errors);
672678
errorsReport.addWarnings(res.warnings);
673679

680+
compileJsFileTimer.end();
681+
674682
return { ...file, content: res.content };
675683
} else {
684+
const compileJsFileTimer = perfTracker.start('transpileJsFile (inplace)');
685+
676686
const ast = parse(
677687
file.content,
678688
{
@@ -689,6 +699,9 @@ export class DataSchemaCompiler {
689699
errorsReport.exitFile();
690700

691701
const content = babelGenerator(ast, {}, file.content).code;
702+
703+
compileJsFileTimer.end();
704+
692705
return { ...file, content };
693706
}
694707
} catch (e: any) {
@@ -721,6 +734,8 @@ export class DataSchemaCompiler {
721734
}
722735

723736
if (getEnv('transpilationNative')) {
737+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (native)');
738+
724739
const reqData = {
725740
fileName: file.fileName,
726741
fileContent: file.content,
@@ -736,8 +751,12 @@ export class DataSchemaCompiler {
736751

737752
this.compiledYamlCache.set(cacheKey, res[0].code);
738753

754+
transpileYamlFileTimer.end();
755+
739756
return { ...file, content: res[0].code };
740757
} else if (getEnv('transpilationWorkerThreads')) {
758+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (threads)');
759+
741760
const data = {
742761
fileName: file.fileName,
743762
content: file.content,
@@ -754,12 +773,18 @@ export class DataSchemaCompiler {
754773

755774
this.compiledYamlCache.set(cacheKey, res.content);
756775

776+
transpileYamlFileTimer.end();
777+
757778
return { ...file };
758779
} else {
780+
const transpileYamlFileTimer = perfTracker.start('transpileYamlFile (inplace)');
781+
759782
const transpiledFile = this.yamlCompiler.transpileYamlFile(file, errorsReport);
760783

761784
this.compiledYamlCache.set(cacheKey, transpiledFile?.content || '');
762785

786+
transpileYamlFileTimer.end();
787+
763788
return transpiledFile;
764789
}
765790
}

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)