7 Commits
Author SHA1 Message Date
Rubén Norte 0f9b8e4a62 Cap maxWorkers and bump heap to bound Fantom Metro memory (#56529)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56529

Fantom runs every test through a single shared Metro server (started in
`globalSetup`). Jest's default `maxWorkers` is `numCpus - 1`, so on a
high-core box (e.g. 176 CPUs) ~175 workers fire bundle requests at Metro
concurrently. Each in-flight request makes Metro materialize a full
dependency `Graph` (transformed modules, source maps, inverse-deps,
file-watcher subscription), which is hundreds of MB.

The per-test `DELETE` eviction added in D101652820 only releases that
memory after the bundle response completes, so the simultaneous in-flight
set still blows past the previous Node `--max-old-space-size=8192` ceiling
in `scripts/fantom.sh` — the Metro process aborts with
`FATAL ERROR: Ineffective mark-compacts near heap limit` after just a
handful of test suites.

Two coordinated changes that balance throughput and safety:

- `scripts/fantom.sh`: bump the Node heap from 8 GB to 16 GB so we have
  headroom over the observed steady-state peak.
- `private/react-native-fantom/config/jest.config.js`: cap `maxWorkers`
  at `min(numCpus - 1, 16)`. With 8 workers the heap peaked at ~3 GB
  (~400 MB / worker), so 16 workers fits comfortably under a 16 GB cap
  with ~40% headroom.

This is intentionally a balance rather than a hard worker cap — bumping
the heap alone would still leave 100+ in-flight graphs racing GC, and
capping workers alone leaves throughput on the table on big machines.

Changelog: [Internal]

Reviewed By: andrewdacenko

Differential Revision: D101791795

fbshipit-source-id: 035c7235c32303f7b7f1eb05698b2a5cba90edc9
2026-04-21 06:01:11 -07:00
Rubén Norte 4ff4836a0f Automatically set --runInBand when running benchmarks
Summary:
When `--benchmarks` is passed to `yarn fantom`, automatically append
`--runInBand` to the Jest arguments. This ensures benchmarks run
sequentially in the same process, avoiding parallel test execution that
would introduce noise in performance measurements.

Changelog: [Internal]

Reviewed By: lenaic

Differential Revision: D100796022

fbshipit-source-id: b78aa44d65ef8618eec6fb08680b5b455cf2470b
2026-04-15 02:39:57 -07:00
Rubén Norte 7efb4b564e Run benchmarks in test mode by default instead of excluding them (#56418)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/56418

Changelog: [internal]

D92150163 excluded benchmark tests by default when running `yarn fantom` without `--benchmarks`. This was incorrect because it means benchmarks could silently break without being caught.

This changes the behavior so:
1. By default (without `--benchmarks`), benchmarks run in test mode (single iteration for correctness only), ensuring they do not break.
2. With `--benchmarks`, benchmarks run in full benchmark mode (multiple iterations for performance measurement).

Also renames `FANTOM_FORCE_TEST_MODE` to `FANTOM_RUN_BENCHMARKS` and `forceTestModeForBenchmarks` to `runBenchmarks` to better reflect the intent (opt-in to full benchmarks rather than opt-in to test mode).

Reviewed By: sammy-SC

Differential Revision: D100464314

fbshipit-source-id: 822cc5a25f0cdddf035616fdddf8619d27ef436a
2026-04-13 04:31:04 -07:00
Andrew Datsenko 37b6c089cb Split Fantom workflow into separate build and test jobs (#54729)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/54729

Changelog: [Internal]

- Created new build-fantom-runner action to compile the Fantom runner binary
- Modified run-fantom-tests action to download and use pre-built binary
- Updated test-all.yml workflow to run build and test as separate jobs
- Removed build dependencies and ccache configuration from test job

Reviewed By: cortinico

Differential Revision: D88012198

fbshipit-source-id: cd1c91b18cccc3c62b9edbcbeb131e80551369f1
2026-03-09 23:21:17 -07:00
Samuel Susla 677330a6d6 Exclude benchmark tests by default, add --benchmarks flag (#55725)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/55725

changelog: [internal]

By default, `yarn fantom` now excludes benchmark tests (`*-benchmark-itest.js` files) to speed up regular test runs.

Benchmark tests are typically slower and used for performance analysis rather than correctness testing. Excluding them by default improves the developer experience for everyday test runs.

To run benchmark tests, use the new `--benchmarks` flag:
```
yarn fantom --benchmarks
```

Reviewed By: andrewdacenko

Differential Revision: D92150163

fbshipit-source-id: 4c40ef1ba542c4856221373d8239ba603e8f6620
2026-02-25 03:17:00 -08:00
Rubén Norte 5c2b9eda69 Refactor runner to use a single instance of Metro for each run (#52777)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52777

Changelog: [internal]

This significantly speeds up test execution in Fantom (around 2x in OSS and 6x at Meta) by starting a Metro server before all tests runs and reusing it across all tests to build test bundles, instead of spinning up a new Metro instance every time we run each test.

The architecture change (also considering the previous change in buck prebuilds) looks like this:
{F1980689532}

This is how is impacts execution times (compared to the baseline):
* OSS
  * Before: 62s {F1980564286}
  * After: 30s (**2x faster**) {F1980564265}

Reviewed By: andrewdacenko

Differential Revision: D78741903

fbshipit-source-id: b209f88925e49cc2a2067e8df9b7fa9a29b4c8d2
2025-08-04 05:56:51 -07:00
Andrew Datsenko d0770ce425 Introduce isOSS (#52222)
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52222

Changelog: [Internal]
Introduce environment option to force usage of OSS fantom test runner.
If env is not set - check for BUCK file in tester which is checked in for FB but not for OSS.

Reviewed By: rubennorte

Differential Revision: D77160761

fbshipit-source-id: 1701ff140ff2be1bbeacfb4305e9f89089cacb42
2025-06-26 11:03:20 -07:00