@@ -23,7 +23,6 @@ import { CompilerInterface } from './PrepareCompiler';
23
23
import { YamlCompiler } from './YamlCompiler' ;
24
24
import { CubeDictionary } from './CubeDictionary' ;
25
25
import { CompilerCache } from './CompilerCache' ;
26
- import { perfTracker } from './PerfTracker' ;
27
26
28
27
const ctxFileStorage = new AsyncLocalStorage < FileContent > ( ) ;
29
28
@@ -215,18 +214,13 @@ export class DataSchemaCompiler {
215
214
protected async doCompile ( ) {
216
215
const files = await this . repository . dataSchemaFiles ( ) ;
217
216
218
- console . log ( `Compiling ${ files . length } files...` ) ;
219
- const compileTimer = perfTracker . start ( 'doCompile' , true ) ;
220
-
221
217
this . pythonContext = await this . loadPythonContext ( files , 'globals.py' ) ;
222
218
this . yamlCompiler . initFromPythonContext ( this . pythonContext ) ;
223
219
224
220
const toCompile = this . filesToCompile ?. length
225
221
? files . filter ( f => this . filesToCompile . includes ( f . fileName ) )
226
222
: files ;
227
223
228
- const jinjaLoaderTimer = perfTracker . start ( 'loadJinjaTemplates' ) ;
229
-
230
224
const jinjaTemplatedFiles = toCompile . filter ( ( file ) => file . fileName . endsWith ( '.jinja' ) ||
231
225
( file . fileName . endsWith ( '.yml' ) || file . fileName . endsWith ( '.yaml' ) ) && file . content . match ( JINJA_SYNTAX ) ) ;
232
226
@@ -235,8 +229,6 @@ export class DataSchemaCompiler {
235
229
this . loadJinjaTemplates ( jinjaTemplatedFiles ) ;
236
230
}
237
231
238
- jinjaLoaderTimer . end ( ) ;
239
-
240
232
const errorsReport = new ErrorReporter ( null , [ ] , this . errorReportOptions ) ;
241
233
this . errorsReporter = errorsReport ;
242
234
@@ -254,8 +246,6 @@ export class DataSchemaCompiler {
254
246
}
255
247
256
248
const transpile = async ( stage : CompileStage ) : Promise < FileContent [ ] > => {
257
- const transpileTimer = perfTracker . start ( `transpilation-stage-${ stage } ` ) ;
258
-
259
249
let cubeNames : string [ ] = [ ] ;
260
250
let cubeSymbols : Record < string , Record < string , boolean > > = { } ;
261
251
let transpilerNames : string [ ] = [ ] ;
@@ -322,8 +312,6 @@ export class DataSchemaCompiler {
322
312
results = await Promise . all ( toCompile . map ( f => this . transpileFile ( f , errorsReport , { } ) ) ) ;
323
313
}
324
314
325
- transpileTimer . end ( ) ;
326
-
327
315
return results . filter ( f => ! ! f ) as FileContent [ ] ;
328
316
} ;
329
317
@@ -420,8 +408,6 @@ export class DataSchemaCompiler {
420
408
} ) ;
421
409
422
410
const compilePhase = async ( compilers : CompileCubeFilesCompilers , stage : 0 | 1 | 2 | 3 ) => {
423
- const compilePhaseTimer = perfTracker . start ( `compilation-phase-${ stage } ` ) ;
424
-
425
411
// clear the objects for the next phase
426
412
cubes = [ ] ;
427
413
exports = { } ;
@@ -430,9 +416,7 @@ export class DataSchemaCompiler {
430
416
asyncModules = [ ] ;
431
417
transpiledFiles = await transpile ( stage ) ;
432
418
433
- const res = this . compileCubeFiles ( cubes , contexts , compiledFiles , asyncModules , compilers , transpiledFiles , errorsReport ) ;
434
- compilePhaseTimer . end ( ) ;
435
- return res ;
419
+ return this . compileCubeFiles ( cubes , contexts , compiledFiles , asyncModules , compilers , transpiledFiles , errorsReport ) ;
436
420
} ;
437
421
438
422
return compilePhase ( { cubeCompilers : this . cubeNameCompilers } , 0 )
@@ -468,12 +452,6 @@ export class DataSchemaCompiler {
468
452
} else if ( transpilationWorkerThreads && this . workerPool ) {
469
453
this . workerPool . terminate ( ) ;
470
454
}
471
-
472
- // End overall compilation timing and print performance report
473
- compileTimer . end ( ) ;
474
- setImmediate ( ( ) => {
475
- perfTracker . printReport ( ) ;
476
- } ) ;
477
455
} ) ;
478
456
}
479
457
@@ -504,7 +482,6 @@ export class DataSchemaCompiler {
504
482
505
483
const jinjaEngine = this . yamlCompiler . getJinjaEngine ( ) ;
506
484
507
- // XXX: Make this as bulk operation in the native side
508
485
files . forEach ( ( file ) => {
509
486
jinjaEngine . loadTemplate ( file . fileName , file . content ) ;
510
487
} ) ;
@@ -538,8 +515,6 @@ export class DataSchemaCompiler {
538
515
errorsReport : ErrorReporter ,
539
516
{ cubeNames, cubeSymbols, contextSymbols, transpilerNames, compilerId, stage } : TranspileOptions
540
517
) : Promise < ( FileContent | undefined ) [ ] > {
541
- const compileJsFileTimer = perfTracker . start ( 'transpileJsFilesBulk (native)' ) ;
542
-
543
518
// for bulk processing this data may be optimized even more by passing transpilerNames, compilerId only once for a bulk
544
519
// but this requires more complex logic to be implemented in the native side.
545
520
// And comparing to the file content sizes, a few bytes of JSON data is not a big deal here
@@ -559,8 +534,6 @@ export class DataSchemaCompiler {
559
534
} ) ) ;
560
535
const res = await transpileJs ( reqDataArr ) ;
561
536
562
- compileJsFileTimer . end ( ) ;
563
-
564
537
return files . map ( ( file , index ) => {
565
538
errorsReport . inFile ( file ) ;
566
539
if ( ! res [ index ] ) { // This should not happen in theory but just to be safe
@@ -582,8 +555,6 @@ export class DataSchemaCompiler {
582
555
) : Promise < ( FileContent | undefined ) > {
583
556
try {
584
557
if ( getEnv ( 'transpilationNative' ) ) {
585
- const compileJsFileTimer = perfTracker . start ( 'transpileJsFile (native)' ) ;
586
-
587
558
const reqData = {
588
559
fileName : file . fileName ,
589
560
fileContent : file . content ,
@@ -605,12 +576,8 @@ export class DataSchemaCompiler {
605
576
errorsReport . addWarnings ( res [ 0 ] . warnings as unknown as SyntaxErrorInterface [ ] ) ;
606
577
errorsReport . exitFile ( ) ;
607
578
608
- compileJsFileTimer . end ( ) ;
609
-
610
579
return { ...file , content : res [ 0 ] . code } ;
611
580
} else if ( getEnv ( 'transpilationWorkerThreads' ) ) {
612
- const compileJsFileTimer = perfTracker . start ( 'transpileJsFile (threads)' ) ;
613
-
614
581
const data = {
615
582
fileName : file . fileName ,
616
583
content : file . content ,
@@ -623,12 +590,8 @@ export class DataSchemaCompiler {
623
590
errorsReport . addErrors ( res . errors ) ;
624
591
errorsReport . addWarnings ( res . warnings ) ;
625
592
626
- compileJsFileTimer . end ( ) ;
627
-
628
593
return { ...file , content : res . content } ;
629
594
} else {
630
- const compileJsFileTimer = perfTracker . start ( 'transpileJsFile (inplace)' ) ;
631
-
632
595
const ast = parse (
633
596
file . content ,
634
597
{
@@ -646,8 +609,6 @@ export class DataSchemaCompiler {
646
609
647
610
const content = babelGenerator ( ast , { } , file . content ) . code ;
648
611
649
- compileJsFileTimer . end ( ) ;
650
-
651
612
return { ...file , content } ;
652
613
}
653
614
} catch ( e : any ) {
@@ -672,8 +633,6 @@ export class DataSchemaCompiler {
672
633
{ cubeNames, cubeSymbols, compilerId } : TranspileOptions
673
634
) : Promise < ( FileContent | undefined ) > {
674
635
if ( getEnv ( 'transpilationNative' ) ) {
675
- const transpileYamlFileTimer = perfTracker . start ( 'transpileYamlFile (native)' ) ;
676
-
677
636
const reqData = {
678
637
fileName : file . fileName ,
679
638
fileContent : file . content ,
@@ -690,12 +649,8 @@ export class DataSchemaCompiler {
690
649
file . content = res [ 0 ] . code ;
691
650
file . convertedToJs = true ;
692
651
693
- transpileYamlFileTimer . end ( ) ;
694
-
695
652
return { ...file , content : res [ 0 ] . code } ;
696
653
} else if ( getEnv ( 'transpilationWorkerThreads' ) ) {
697
- const transpileYamlFileTimer = perfTracker . start ( 'transpileYamlFile (threads)' ) ;
698
-
699
654
const data = {
700
655
fileName : file . fileName ,
701
656
content : file . content ,
@@ -711,21 +666,15 @@ export class DataSchemaCompiler {
711
666
file . content = res . content ;
712
667
file . convertedToJs = true ;
713
668
714
- transpileYamlFileTimer . end ( ) ;
715
-
716
669
return { ...file , content : res . content } ;
717
670
} else {
718
- const transpileYamlFileTimer = perfTracker . start ( 'transpileYamlFile (inplace)' ) ;
719
-
720
671
const transpiledFile = this . yamlCompiler . transpileYamlFile ( file , errorsReport ) ;
721
672
722
673
if ( transpiledFile ) {
723
674
file . content = transpiledFile . content ;
724
675
file . convertedToJs = true ;
725
676
}
726
677
727
- transpileYamlFileTimer . end ( ) ;
728
-
729
678
return transpiledFile ;
730
679
}
731
680
}
@@ -735,8 +684,6 @@ export class DataSchemaCompiler {
735
684
errorsReport : ErrorReporter ,
736
685
options : TranspileOptions
737
686
) : Promise < ( FileContent | undefined ) > {
738
- const transpileJinjaFileTimer = perfTracker . start ( 'transpileJinjaFile (common)' ) ;
739
-
740
687
const renderedFile = await this . yamlCompiler . renderTemplate (
741
688
file ,
742
689
this . standalone ? { } : this . cloneCompileContextWithGetterAlias ( this . compileContext ) ,
@@ -749,8 +696,6 @@ export class DataSchemaCompiler {
749
696
// avoiding costly YAML/Python parsing again.
750
697
file . content = renderedFile . content ;
751
698
752
- transpileJinjaFileTimer . end ( ) ;
753
-
754
699
return this . transpileYamlFile ( file , errorsReport , options ) ;
755
700
}
756
701
@@ -807,26 +752,18 @@ export class DataSchemaCompiler {
807
752
compiledFiles [ file . fileName ] = true ;
808
753
809
754
if ( file . convertedToJs ) {
810
- const compileJsFileTimer = perfTracker . start ( 'compileJsFile (convertedToJs)' ) ;
811
755
this . compileJsFile ( file , errorsReport ) ;
812
- compileJsFileTimer . end ( ) ;
813
756
} else if ( file . fileName . endsWith ( '.js' ) ) {
814
- const compileJsFileTimer = perfTracker . start ( 'compileJsFile' ) ;
815
757
this . compileJsFile ( file , errorsReport , { doSyntaxCheck } ) ;
816
- compileJsFileTimer . end ( ) ;
817
758
} else if ( file . fileName . endsWith ( '.yml.jinja' ) || file . fileName . endsWith ( '.yaml.jinja' ) ||
818
759
( file . fileName . endsWith ( '.yml' ) || file . fileName . endsWith ( '.yaml' ) ) &&
819
760
file . content . match ( JINJA_SYNTAX )
820
761
) {
821
- const compileJinjaFileTimer = perfTracker . start ( 'compileJinjaFile (actually js)' ) ;
822
762
// original jinja/yaml file was already transpiled into js
823
763
this . compileJsFile ( file , errorsReport ) ;
824
- compileJinjaFileTimer . end ( ) ;
825
764
} else if ( file . fileName . endsWith ( '.yml' ) || file . fileName . endsWith ( '.yaml' ) ) {
826
- const compileYamlFileTimer = perfTracker . start ( 'compileYamlFile (actually js)' ) ;
827
765
// original yaml file was already transpiled into js
828
766
this . compileJsFile ( file , errorsReport ) ;
829
- compileYamlFileTimer . end ( ) ;
830
767
}
831
768
}
832
769
0 commit comments