From 6fa3aade1dc4cd819d311864cf0a3b6a0f6031e3 Mon Sep 17 00:00:00 2001 From: Michael Kriese <michael.kriese@visualon.de> Date: Wed, 31 Aug 2022 16:44:04 +0200 Subject: [PATCH] test: reduce jest memory (#17547) --- jest.config.ts | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/jest.config.ts b/jest.config.ts index 9c1411e07b..76464c3ef7 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -1,4 +1,5 @@ import os from 'os'; +import v8 from 'v8'; import type { InitialOptionsTsJest } from 'ts-jest/dist/types'; const ci = !!process.env.CI; @@ -8,21 +9,31 @@ type JestConfig = InitialOptionsTsJest & { workerIdleMemoryLimit?: string; }; +const cpus = os.cpus(); +const mem = os.totalmem(); +const stats = v8.getHeapStatistics(); + +process.stderr.write(`Host stats: + Cpus: ${cpus.length} + Memory: ${(mem / 1024 / 1024 / 1024).toFixed(2)} GB + HeapLimit: ${(stats.heap_size_limit / 1024 / 1024 / 1024).toFixed(2)} GB +`); + /** * https://docs.github.com/en/actions/using-github-hosted-runners/about-github-hosted-runners#supported-runners-and-hardware-resources + * Currently it seems the runner only have 4GB */ function jestGithubRunnerSpecs(): JestConfig { - if (os.platform() === 'darwin') { - // - return { - maxWorkers: 2, - workerIdleMemoryLimit: '4GB', - }; - } + // if (os.platform() === 'darwin') { + // return { + // maxWorkers: 2, + // workerIdleMemoryLimit: '4GB', + // }; + // } return { maxWorkers: 2, - workerIdleMemoryLimit: '2GB', + workerIdleMemoryLimit: '1500MB', // '2GB', }; } -- GitLab