Skip to content
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

perf: skip getting package class name inside expo module #2487

Merged
merged 3 commits into from
Aug 31, 2024

Conversation

szymonrybczak
Copy link
Collaborator

Summary:

Recently blog post regarding performance improvements inside autolinking was published, as it turns between implementations there's a big difference.

After my investigation it is due getting package class name from classes which are implementing ReactPackage or TurboReactPackage. In past we landed improvements to this logic (read more here).

But as mentioned in the blog post the difference is still big and the root cause of this issue is because of reading hundreds of files from expo modules and trying to find classes that implements ReactPackage or TurboReactPackage, but expo modules don't implement ReactPackage or TurboReactPackage directly inside their source code, so the return value will be anyway null, so it doesn't make sense to read hundreds of files and check for classes that implements ReactPackage or TurboReactPackage.

Inside this Pull Request I've added a early return if module is expo module, following logic doesn't affect output of config command because expo modules follows other rules and are included in native build in different way.

Exception is expo package itself which contains expo-module.config.json and also implements ReactPackage or TurboReactPackage, I added appropriate condition for this case.

Benchmark:

Tested on the react-conf-app.

Before:

❯ hyperfine 'node ~/development/cli/packages/cli/build/bin.js config'
Benchmark 1: node ~/development/cli/packages/cli/build/bin.js config
  Time (mean ± σ):      2.353 s ±  0.033 s    [User: 2.067 s, System: 0.313 s]
  Range (min … max):    2.313 s …  2.408 s    10 runs

After:

❯ hyperfine 'node ~/development/cli/packages/cli/build/bin.js config'
Benchmark 1: node ~/development/cli/packages/cli/build/bin.js config
  Time (mean ± σ):     654.7 ms ±  30.7 ms    [User: 453.2 ms, System: 269.3 ms]
  Range (min … max):   620.0 ms … 711.5 ms    10 runs

Test Plan:

  1. Clone the repository and do all the required steps from the Contributing guide
  2. Run this command:
node /path/to/react-native-cli/packages/cli/build/bin.js config
  1. Output should be the same.

Checklist

  • Documentation is up to date to reflect these changes.
  • Follows commit message convention described in CONTRIBUTING.md

@thymikee thymikee requested a review from Kudo August 27, 2024 09:57
Copy link
Member

@cortinico cortinico left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. I'm just wondering if an expo module could actually have both the 'expo-module.config.json' file and an implementation of a ReactPackage. However I believe that's not the case

@szymonrybczak szymonrybczak requested a review from thymikee August 30, 2024 13:19
@thymikee thymikee merged commit 4573eca into main Aug 31, 2024
10 checks passed
@thymikee thymikee deleted the fix/exclude-expo-modules-from-autolinking branch August 31, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants