3x Performance drop vs JSC in some tasks
- Dominant language
- JavaScript
- Stars
- 11.3k
- Forks
- 859
- Avg merge
- 1h 30m
- Merged PRs (30d)
- 3
Description
## Bug Description
It appears that using formatjs `Intl` polyfills can be very slow while using Hermes. I forked @karol-bisztyga's repro from #471 to show an issue with formatting dates.
Hermes is up to 3 times slower than JSC, and it makes working with i18n/timezoned dates almost impossible. It takes around 5-20ms to format one single date(!).
The same benchmark using JSC instead of Hermes on Android seems about 2-3 times faster.
Hermes version: 0.37.0
React Native version (if any): 0.64
OS version (if any): Android
Platform (most likely one of arm64-v8a, armeabi-v7a, x86, x86_64):
## Steps To Reproduce
Here's a repro on both engines:
https://github.com/andreialecu/hermes-repro/tree/jsc-intl
https://github.com/andreialecu/hermes-repro/tree/hermes-intl
see: https://github.com/andreialecu/hermes-repro/blob/hermes-intl/App.js
JSC on M1 (Android Emulator):
```
{
"dateTimeFormat": [919, 175, 162, 158, 147, 159, 154, 149, 156, 148],
"local": [11, 0, 0, 1, 0, 0, 0, 0, 0, 0],
"setZone": [1381, 184, 172, 167, 155, 183, 150, 152, 151, 154],
"toLocaleString": [517, 175, 173, 165, 158, 157, 147, 148, 152, 147]
}
```
Hermes on M1 (Android Emulator):
```
{
"dateTimeFormat": [393, 373, 369, 343, 341, 349, 372, 364, 347, 343],
"local": [5, 1, 0, 0, 1, 1, 0, 1, 0, 1],
"setZone": [401, 376, 376, 355, 355, 361, 389, 379, 364, 352],
"toLocaleString": [375, 392, 368, 368, 342, 392, 367, 379, 348, 342]
}
```
Notice that the times above are using an M1 apple cpu, with an arm64 native emulator, so everything should be running native.
On a physical 2020 mid-level Android device the times are about 6-7 times slower:
Hermes on [Oppo A72](https://www.gsmarena.com/oppo_a72-10196.php):
```
{
"dateTimeFormat": [2006, 2016, 2005, 2009, 2004, 2060, 2008, 2012, 2020, 2017],
"local": [28, 3, 3, 2, 4, 2, 3, 3, 3, 3],
"setZone": [2214, 2077, 2073, 2067, 2075, 2129, 2080, 2078, 2075, 2077],
"toLocaleString": [2042, 2035, 2003, 2019, 2024, 2025, 2029, 2035, 2011, 2013]}
```
Related:
https://github.com/facebook/hermes/issues/23#issuecomment-815906036
Contributor guide
Assessment
This issue has not been assessed yet.