mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Summary: The performance of `_getFreeIndex` is quite terrible since the `timersID` array can get quite large when you spawn a lot of promises or timers. We profiled our application for 28 seconds on RN 0.71.11 and noticed that the `indexOf` into this array was consuming almost a second. The hermes version that we are using has a pretty slow `indexOf` compared to other engines, and the static hermes will improve it by 12x but for the time being, this is a perf issue. https://github.com/facebook/hermes/pull/1447 We avoid having to use `indexOf` by maintaining a list of the free ids. **Before - Samsung Galaxy A52 for 28 seconds of profiling**  **After - Samsung Galaxy A52 for 28 seconds of profiling**  ## Changelog: [INTERNAL] [FIXED] - Improve performance of _getFreeIndex Pull Request resolved: https://github.com/facebook/react-native/pull/48925 Test Plan: - Tests pass, promises resolve and reject correctly, setTimeout works as expected Reviewed By: javache Differential Revision: D69059102 Pulled By: cipolleschi fbshipit-source-id: d7de2c4adcf4dfc1d15e597e2a801e23c8d652aa