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

Use topologicalSort with Identifiable on ResolvedTarget #7211

Merged
merged 2 commits into from
Jan 2, 2024

Conversation

MaxDesiatov
Copy link
Contributor

Motivation:

A serious performance regression was introduced for deep target dependency graphs in #7160. After converting ResolvedTarget to a value type, its synthesized Hashable conformance traversed the whole dependency tree multiple times when using topologicalSort. This made package resolution seemingly hang for packages that had a lot of nested target graphs.

Modifications:

We already have an implementation of topologicalSort on Identifiable, so we're using that now instead. I've also added a performance test for this in PackageGraphPerfTests to prevent future regressions in this area.

Result:

Resolved rdar://119807385.

Fix fixes a serious performance regression introduced for deep target dependency graphs in #7160. After converting `ResolvedTarget` to a value type, its synthesized `Hashable` conformance traversed the whole dependency tree multiple times when using `topologicalSort`. This made package resolution seemingly hang for packages that had a lot of nested target graphs.

We already have an implementation of `topologicalSort` on `Identifiable`, thus we should use that instead. I've also added a performance test for this in `PackageGraphPerfTests` to prevent future regressions in this area.
@MaxDesiatov MaxDesiatov added bug performance Performance optimizations and improvements modules graph Modules dependency resolution labels Dec 20, 2023
@MaxDesiatov MaxDesiatov self-assigned this Dec 20, 2023
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

import PackageGraph
import PackageModel

extension ResolvedTarget {
Copy link
Contributor Author

@MaxDesiatov MaxDesiatov Dec 20, 2023

Choose a reason for hiding this comment

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

Moved from ResolvedTargetTests for reuse in perf tests.

@MaxDesiatov MaxDesiatov enabled auto-merge (squash) December 20, 2023 18:17
@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test

@MaxDesiatov
Copy link
Contributor Author

@swift-ci test windows

@MaxDesiatov MaxDesiatov merged commit 1341ecd into main Jan 2, 2024
@MaxDesiatov MaxDesiatov deleted the maxd/identifiable-topological-sort branch January 2, 2024 06:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug modules graph Modules dependency resolution performance Performance optimizations and improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants