Skip to content

perf: improve auto linking performance #2670

Merged
thymikee merged 5 commits into
mainfrom
perf/autolink
Jun 9, 2025
Merged

perf: improve auto linking performance #2670
thymikee merged 5 commits into
mainfrom
perf/autolink

Conversation

@thymikee

@thymikee thymikee commented Jun 5, 2025

Copy link
Copy Markdown
Member

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
@thymikee thymikee merged commit cb27cf0 into main Jun 9, 2025
4 of 8 checks passed
@thymikee thymikee deleted the perf/autolink branch June 9, 2025 15:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants