Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53071
Changelog: [internal]
The current API to take JS heap snapshots has some problems:
1. Ergonomics: it requires you to input the filepath where you want to store the snapshot. This isn't aligned with the behavior we have for JS traces where the output path is provided to you.
2. It doesn't work in optimized builds, as it requires a specific option in Hermes.
For 1), this replaces `Fantom.saveJSMemoryHeapSnapshot(filePath)` with `Fantom.takeJSMemoryHeapSnapshot()` that outputs the snapshot in a predefined path and prints it to the console.
For 2), this adds a new environment variable to force building Hermes with memory instrumentation (`FANTOM_ENABLE_JS_MEMORY_INSTRUMENTATION`). This is exposed as an option and not set by default because it has a performance overhead at runtime that we don't want to pay (especially in benchmarks).
This option only works when using Buck in development, because we want to generate this new binary type on demand when necessary, instead of making it part of the prebuilts we do before running tests in OSS and CI.
Reviewed By: lenaic
Differential Revision: D79642314
fbshipit-source-id: a2980616a495bd6dca29c0709a9581db6fb3f2cc
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52827
Changelog: [internal]
This adds **support for creating Hermes/JS sampling profiler traces in Fantom**, which is especially useful when running benchmarks.
Usage:
```
FANTOM_PROFILE_JS=1 yarn fantom Animated-benchmark
```
Output:
{F1980642216}
After this, the trace is fully symbolicated.
Can be opened directly in Google Chrome:
{F1980642229}
Or in the built-in viewer in VSCode:
{F1980642242} {F1980642240} {F1980642241}
When collapsing frames in the Flame Chart viewer in VSCode, we can quickly identify opportunities for optimizations.
This also supports multi-config environments. In that case, trace file names are created using a short representation of the configuration.
User guide for benchmarks in Fantom, including how to use this, will be done in a future diff.
NOTE: This still doesn't work in OSS because we don't support optimized mode there. In dev mode, there's a segmentation fault coming from this line: `hermesRuntime->sampledTraceToStreamInDevToolsFormat(fileStream)`
Reviewed By: sammy-SC
Differential Revision: D78905646
fbshipit-source-id: 382ddd5034db601309bd118cedde2fe0d57fde98
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53034
Changelog: [internal]
This is just a refactor to make sure that the constants we pass from the Fantom runner to its runtime are correct by using Flow to typecheck it.
Reviewed By: andrewdacenko
Differential Revision: D79565574
fbshipit-source-id: cbbab9cdec5ef5b3c82b929b8939c76c0ef41823
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/53010
Changelog: [internal]
Exposing this value so we can disable some tests in some scenarios in a following this.
Reviewed By: cipolleschi
Differential Revision: D79510481
fbshipit-source-id: 632d9a008943ed40c24878b5561065b6ede1d689
Summary:
Pull Request resolved: https://github.com/facebook/react-native/pull/52759
Changelog: [internal]
This introduces a new environment variable for Fantom to disable benchmarks (`FANTOM_FORCE_TEST_MODE`), without having to run in CI mode.
Reviewed By: rshest
Differential Revision: D78672864
fbshipit-source-id: ef445bd8b36703594658529da2436c75d5b87179