Scale the jest worker count to the machine it's running on (#83395)
Scale the jest worker count to the machine
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
// @ts-check
|
||||
/** eslint-disable-next-line import/no-commonjs */
|
||||
const { cpus } = require("os");
|
||||
|
||||
const baseConfig = require("./jest.base.conf.js");
|
||||
|
||||
// Four workers left most of a developer machine idle: on fourteen cores the
|
||||
// suite takes 390s at four workers and 200s at eight, and twelve is slower
|
||||
// again. A four-core CI runner resolves to the four workers it had before.
|
||||
const WORKER_SHARE_OF_CORES = 0.6;
|
||||
const MIN_WORKERS = 4;
|
||||
const maxWorkers = Math.max(
|
||||
MIN_WORKERS,
|
||||
Math.round(cpus().length * WORKER_SHARE_OF_CORES),
|
||||
);
|
||||
|
||||
// Heap measurement specs. They run from jest.memory.conf.js, never from the
|
||||
// default sharded run, because they need --expose-gc and a quiet heap.
|
||||
const MEMORY_TEST_PATTERN = "\\.leak\\.unit\\.spec\\.";
|
||||
@@ -23,6 +36,7 @@ const config = {
|
||||
"jest-watch-typeahead/testname",
|
||||
],
|
||||
testTimeout: 30000,
|
||||
maxWorkers,
|
||||
// CI narrows a run to the plan's spec files by pointing this at a JSON list.
|
||||
...(process.env.JEST_TEST_PATHS_FILE && {
|
||||
filter: "<rootDir>/frontend/test/jest-test-paths-filter.ts",
|
||||
|
||||
@@ -498,8 +498,8 @@
|
||||
"test-timezones": "bun install && ./frontend/test/__runner__/run_timezone_tests",
|
||||
"test-memory": "node --expose-gc ./node_modules/.bin/jest --runInBand --config jest.memory.conf.js",
|
||||
"test-timezones-unit": "jest --silent --maxWorkers=4 --config jest.tz.unit.conf.js",
|
||||
"test-unit": "bun run build:cljs && jest --ignoreProjects ci-scripts --maxWorkers=4",
|
||||
"test-unit-keep-cljs": "jest --ignoreProjects ci-scripts --maxWorkers=4",
|
||||
"test-unit": "bun run build:cljs && jest --ignoreProjects ci-scripts",
|
||||
"test-unit-keep-cljs": "jest --ignoreProjects ci-scripts",
|
||||
"test-unit-watch": "bun run test-unit --watch",
|
||||
"test-unit-watch:cljs": "bun run concurrently -n 'cljs,tests' 'bun run build-watch:cljs' 'bun run test-unit-keep-cljs --watch'",
|
||||
"test-visual:loki": "NODE_ENV=development loki test --chromeFlags='--headless --disable-gpu' ",
|
||||
|
||||
Reference in New Issue
Block a user