Hermes seems to take longer to process large promises inside React Native
Description
Hermes seems to take longer to process large promises inside React Native when compared to other JavaScript engines such as JavaScriptCore (Android) and Chakra (Windows).
I have recently reported this issue with the Hermes engine at https://github.com/facebook/hermes/issues/1024. However, after setting up a command line comparison vs React Native, it would appear that there is some configuration or integration with Hermes that is causing the slowdown to occur within React Native and not the command line. I'm not sure if this is related some of the diagnostic hooks or some metro configuration.
The issue persists in both Debug and Release, see "Steps to reproduce".
Please note, my team's concern is primarily with the Release performance, any workaround would be appreciated.
React Native Version
0.72.6
Output of npx react-native info
info Fetching system and libraries information... System: OS: Windows 10 10.0.19044 CPU: (16) x64 Intel(R) Core(TM) i9-10885H CPU @ 2.40GHz Memory: 16.42 GB / 31.75 GB Binaries: Node: version: 20.9.0 path: C:\Program Files\nodejs\node.EXE Yarn: version: 1.22.19 path: C:\Program Files (x86)\Yarn\bin\yarn.CMD npm: version: 10.1.0 path: C:\Program Files\nodejs\npm.CMD Watchman: Not Found SDKs: Android SDK: Not Found Windows SDK: AllowDevelopmentWithoutDevLicense: Enabled AllowAllTrustedApps: Enabled Versions: - 10.0.19041.0 - 10.0.22000.0 - 10.0.22621.0 IDEs: Android Studio: AI-223.8836.35.2231.10811636 Visual Studio: - 17.4.33829.165 (Visual Studio Enterprise 2022) Languages: Java: version: 11.0.20 path: C:\Program Files\Microsoft\jdk-11.0.20.8-hotspot\bin\javac.EXE Ruby: Not Found npmPackages: "@react-native-community/cli": Not Found react: installed: 18.2.0 wanted: 18.2.0 react-native: installed: 0.72.6 wanted: 0.72.6 react-native-windows: installed: 0.72.16 wanted: 0.72.16 npmGlobalPackages: "react-native": Not Found Android: hermesEnabled: true newArchEnabled: false iOS: hermesEnabled: Not found newArchEnabled: Not found
Steps to reproduce
- Clone hermes-promise-test, following the readme there. Note: the project contains a shared git submodule for testing.
- Install and run for Windows or Android via
yarn installandyarn react-native start(oryarn react-native run-android). - Click the "Mock Data with Nested Promises" button.
- Choose the 10K button
- Click on Format to trigger the Nested promises chain, which simply changes the casing on the 10K dataset.
If you use Hermes directly, the time will be about 7x that of JavaScriptCore (Android) or Chakra (Windows).
However, if you pull the command line version hermes-promise-cli and execute it with Hermes directly, Hermes will resolve these within 600 ms or less and will outperform Chakra on the command line.
Snack, screenshot, or link to a repository
- hermes-promise-test for React Native testing.
- hermes-promise-cli for command line testing.
- See https://github.com/facebook/hermes/issues/1024 for the companion issue.
Screenshots
Source: facebook/hermes