Skip to content

perf: improve auto linking performance #2670

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open

perf: improve auto linking performance #2670

wants to merge 5 commits into from

Conversation

thymikee
Copy link
Member

@thymikee thymikee commented Jun 5, 2025

Summary

There are multiple parts of auto linking that are slow, so I made a quick perf pass to reduce the time CLI spends on searching for native files. The biggest gain comes from optimizing findComponentDescriptors to use jsSrcsDir. For a small project with 7 common native dependencies the linking time goes from ~300ms to ~80ms. Perf and gains are bigger with more dependencies, so it's hard to asses the raw %.

before after
Screenshot 2025-06-05 at 09 48 31 Screenshot 2025-06-05 at 09 49 29

Changes are scoped to smaller commits:

  • cdabe1c - remote node_modules and pods from findManifest as we're in android folder
  • 79c494f - add android to exclude pattern in findAllPodfilePaths as it's not scoped to sourceDir
  • bbc597b - exclude .cxx from findManifest and findPackageClassName
  • 503383f - use codegen config to find component descriptors
  • d1e8f1a - avoid double invoking of native deps - when calling config, the native dependencies getters are invoked twice: first for the filtering pass, and then for stringily. Changed the filtering logic to push resolved getters of native deps instead of removing non-native dependencies

Test Plan

Make sure the projects are still properly linked

Checklist

  • Documentation is up to date.
  • Follows commit message convention described in CONTRIBUTING.md.
  • For functional changes, my test plan has linked these CLI changes into a local react-native checkout (instructions).

@thymikee thymikee requested a review from szymonrybczak as a code owner June 5, 2025 07:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant