-
Notifications
You must be signed in to change notification settings - Fork 645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3x Performance drop vs JSC in some tasks #495
Comments
I haven't been able to take any closer looks, but the first thing we should look at is probably whether or not you are running the polyfilled Intl or the native Intl on JSC. Most of the polyfills perform a feature detection in the first place and the Format.js does no exception: https://github.com/formatjs/formatjs/blob/65017cd5dc0b72b16e44daaf088a676c73c527c4/packages/intl-locale/should-polyfill.ts#L12 |
@Huxpro JSC for Android does not have native Intl support enabled at all as per: Additionally, the polyfills are applied directly, without calling |
I added JSC benchmark on the physical device (Oppo A72):
Meaning it takes 10ms to format one date, still slow even on JSC, although twice as fast as Hermes. This is also due to some performance problems with formatjs (formatjs/formatjs#2813), but I think it serves as a good baseline for comparing the two engines, and figuring out ways to improve Hermes. |
For completeness sake I also tried react-native-v8 Oppo A72 react-native-v8 jit off:
Oppo A72 react-native-v8 jit enabled:
Interestingly, the JIT enabled version of v8 seems to be extremely performant on this low end device. (15 times faster than Hermes) https://github.com/andreialecu/hermes-repro/tree/v8-intl |
@andreialecu Thanks for setting up and posting those benchmarks. Would you be interested in benchmarking Hermes native Intl performance? I'm curious how would that perform 😛 . Here is a link of a latest Note that it's probably not going to work with you existing app on RN 0.64 but you could also try ;) |
I tried to add the new hermes build to https://github.com/andreialecu/hermes-repro/tree/hermes-intl which is a very simple, starter, RN app. I pushed a branch here: andreialecu/hermes-repro@8ff4559 (using yarn resolutions to override it). If you want to try and see the crash. Seems to crash on startup (both real device and emulator):
I haven't yet tried it on RNTester to see if it would make any difference. However, I was able to patch the I still see some performance degradation in other parts of the app however which seem execution speed related. I haven't yet been able to profile what they are (because Hermes crashes when trying to profile, as per #491) - but it seems that if v8 with jit performs 15x faster in tasks such as this one, there could be some sort of improvement possible to Hermes. Edit: Tried RNTester but couldn't get it to compile for Android. The |
@andreialecu do you know if this is still an issue? |
Hermes Android now has |
Constructing You should cache/memoize the |
Just to note on IOS simulator i get 3x-4x faster result |
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):
Hermes on M1 (Android Emulator):
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:
Related:
#23 (comment)
The text was updated successfully, but these errors were encountered: