Skip to content

Index targets top-down instead of bottom up#2423

Closed
ahoppen wants to merge 1 commit into
swiftlang:mainfrom
ahoppen:index-order
Closed

Index targets top-down instead of bottom up#2423
ahoppen wants to merge 1 commit into
swiftlang:mainfrom
ahoppen:index-order

Conversation

@ahoppen

@ahoppen ahoppen commented Jan 5, 2026

Copy link
Copy Markdown
Member
  • Explanation: We originally started preparing and indexing the low-level targets in the hope that we can unblock the files of those targets as early as possible for indexing and thus get best indexing performance. Revisiting this design decision, we can actually get a ~2x speed up (SourceKit-LSP gets indexed in 2:45 instead of 5:49 minutes on my machine) in initial indexing performance by preparing indexing top-level targets first. This speed-up is for two reasons:
    • When preparing a top-level target, all of its dependencies are implicitly also prepared. That means that we don’t need to send any prepare requests to the build server for those targets, which is very advantages for SwiftPM projects, in which the constant cost in the order of 500ms (based on my memory) even for a null build.
    • The underlying build server is able to prepare dependencies of the top-level target in parallel instead of implicitly serializing them by preparing all targets in the package in dependency order.
  • Scope: Background indexing
  • Issue: n/a
  • Risk: Targets may not get prepared properly but I don’t see this happening and we should catch any issues like this in living on
  • Testing: Added/updates tests

@ahoppen ahoppen closed this Jan 5, 2026
@ahoppen ahoppen deleted the index-order branch January 5, 2026 11:26
@ahoppen ahoppen restored the index-order branch January 5, 2026 21:21
@ahoppen ahoppen reopened this Jan 5, 2026
@ahoppen ahoppen marked this pull request as draft January 5, 2026 21:21
We originally started preparing and indexing the low-level targets in the hope that we can unblock the files of those targets as early as possible for indexing and thus get best indexing performance. Revisiting this design decision, we can actually get a ~2x speed up (SourceKit-LSP gets indexed in 2:45 instead of 5:49 minutes on my machine) in initial indexing performance by preparing indexing top-level targets first. This speed-up is for two reasons:
- When preparing a top-level target, all of its dependencies are implicitly also prepared. That means that we don’t need to send any prepare requests to the build server for those targets, which is very advantages for SwiftPM projects, in which the constant cost in the order of 500ms (based on my memory) even for a null build.
- The underlying build server is able to prepare dependencies of the top-level target in parallel instead of implicitly serializing them by preparing all targets in the package in dependency order.
@ahoppen ahoppen marked this pull request as ready for review April 12, 2026 06:03
@ahoppen

ahoppen commented Apr 12, 2026

Copy link
Copy Markdown
Member Author

@swift-ci Please test

@ahoppen

ahoppen commented Jun 19, 2026

Copy link
Copy Markdown
Member Author

Closing in favor of #2684.

@ahoppen ahoppen closed this Jun 19, 2026
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