Skip to content

Commit 812efec

Browse files
authored
feat(schema-compiler): Reduce memory usage after compilation is done (#9890)
* feat(schema-compiler): Reduce memory usage after compilation is done * fix yarn.lock
1 parent d0554d6 commit 812efec

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

packages/cubejs-schema-compiler/src/compiler/CubeDictionary.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,8 @@ export class CubeDictionary {
1313
resolveCube(cubeName) {
1414
return this.byId[cubeName];
1515
}
16+
17+
free() {
18+
this.byId = {};
19+
}
1620
}

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,15 @@ export class CubeSymbols {
214214
this.evaluateViews = evaluateViews;
215215
}
216216

217+
public free() {
218+
this.symbols = {};
219+
this.builtCubes = {};
220+
this.cubeDefinitions = {};
221+
this.funcArgumentsValues = {};
222+
this.cubeList = [];
223+
this.resolveSymbolsCallContext = undefined;
224+
}
225+
217226
public compile(cubes: CubeDefinition[], errorReporter: ErrorReporter) {
218227
this.cubeDefinitions = Object.fromEntries(
219228
cubes.map((c): [string, CubeDefinition] => [c.name, c])

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,9 @@ export class DataSchemaCompiler {
335335
if (!this.omitErrors) {
336336
this.throwIfAnyErrors();
337337
}
338+
// Free unneeded resources
339+
this.cubeDictionary.free();
340+
this.cubeSymbols.free();
338341
return res;
339342
});
340343
}

yarn.lock

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7644,15 +7644,15 @@
76447644
"@smithy/util-uri-escape" "^4.0.0"
76457645
tslib "^2.6.2"
76467646

7647-
"@smithy/querystring-parser@^4.0.5":
7647+
"@smithy/querystring-parser@^4.0.1", "@smithy/querystring-parser@^4.0.5":
76487648
version "4.0.5"
76497649
resolved "https://registry.yarnpkg.com/@smithy/querystring-parser/-/querystring-parser-4.0.5.tgz#95706e56aa769f09dc8922d1b19ffaa06946e252"
76507650
integrity sha512-6SV7md2CzNG/WUeTjVe6Dj8noH32r4MnUeFKZrnVYsQxpGSIcphAanQMayi8jJLZAWm6pdM9ZXvKCpWOsIGg0w==
76517651
dependencies:
76527652
"@smithy/types" "^4.3.2"
76537653
tslib "^2.6.2"
76547654

7655-
"@smithy/service-error-classification@^4.0.7":
7655+
"@smithy/service-error-classification@^4.0.1", "@smithy/service-error-classification@^4.0.7":
76567656
version "4.0.7"
76577657
resolved "https://registry.yarnpkg.com/@smithy/service-error-classification/-/service-error-classification-4.0.7.tgz#24072198a8c110d29677762162a5096e29eb4862"
76587658
integrity sha512-XvRHOipqpwNhEjDf2L5gJowZEm5nsxC16pAZOeEcsygdjv9A2jdOh3YoDQvOXBGTsaJk6mNWtzWalOB9976Wlg==

0 commit comments

Comments
 (0)