facebook / facebook/hermes

Hermes seems to take longer to process large promises inside React Native

Open
#1,573 12 comments 2 reactions 0 assignees View on GitHub
Needs: Triage :mag: Tech: Hermes
Dominant language
JavaScript
Stars
11.3k
Forks
859
Avg merge
1h 30m
Merged PRs (30d)
3

Description

### 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

1. Clone [hermes-promise-test](https://github.com/AlexLablaiksSAP/hermes-promise-test), following the readme there. Note: the project contains a shared git submodule for testing.
2. Install and run for Windows or Android via `yarn install` and `yarn react-native start` (or `yarn react-native run-android`).
3. Click the "Mock Data with Nested Promises" button.
4. Choose the 10K button
5. 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](https://github.com/AlexLablaiksSAP/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](https://github.com/AlexLablaiksSAP/hermes-promise-test) for React Native testing.
- [hermes-promise-cli](https://github.com/AlexLablaiksSAP/hermes-promise-cli) for command line testing.
- See https://github.com/facebook/hermes/issues/1024 for the companion issue.

Screenshots
![hermes-rel](https://github.com/facebook/hermes/assets/12348315/7ca82e09-d565-48f0-ad08-c0f528f4f825)
![javascriptcore-rel](https://github.com/facebook/hermes/assets/12348315/969b5b86-c38d-4b8f-a794-ebfa2ddf4b87)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.