Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions private/react-native-fantom/config/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,32 @@
'use strict';

const baseConfig = require('../../../jest.config');
const os = require('os');
const path = require('path');

// Every Fantom worker shares a single Metro server. With unbounded
// parallelism, concurrent bundle builds pile up faster than the
// per-test DELETE eviction can free their dependency graphs. Cap
// concurrency so the number of in-flight graphs stays bounded on
// high-core machines, while still using all available CPUs on smaller
// ones. The cap pairs with the Node heap size set in scripts/fantom.sh
// (16 GB) to leave comfortable headroom over the observed peak.
function getNumCpus() /*: number */ {
if (typeof os.availableParallelism === 'function') {
return os.availableParallelism();
}
const cpus = os.cpus();
return cpus != null ? cpus.length : 1;
}

const FANTOM_MAX_WORKERS /*: number */ = Math.max(
1,
Math.min(getNumCpus() - 1, 16),
);

module.exports = {
displayName: 'fantom',
maxWorkers: FANTOM_MAX_WORKERS,
rootDir: path.resolve(__dirname, '../../..') /*:: as string */,
roots: [
'<rootDir>/packages/react-native',
Expand Down
8 changes: 7 additions & 1 deletion scripts/fantom.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,13 @@ else
export FANTOM_FORCE_OSS_BUILD=1
fi

export NODE_OPTIONS='--max-old-space-size=8192'
# The Fantom Jest process hosts a single shared Metro server. Each test
# triggers a fresh Metro bundle build whose dependency graph (transformed
# modules, source maps, inverse-deps, file-watcher subscription) lives in
# memory until the per-test DELETE evicts it. With the maxWorkers cap in
# jest.config.js (~16 in-flight bundles at peak), 16 GB gives ~40% heap
# headroom over the observed steady state of ~6 GB.
export NODE_OPTIONS='--max-old-space-size=16384'

# Parse arguments to extract custom flags
ARGS=()
Expand Down
Loading