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

Improve performance of XcodeTarget.transitiveTargets() #77

Merged
merged 1 commit into from
Oct 10, 2018

Conversation

kastiglione
Copy link
Contributor

XcodeTarget.transitiveTargets() traverses the dependency, and builds an array result using flatMap. This wasn't showing up in traces of a small project with a smaller dependency graph, but in larger projects this hits some allocation slow paths in swift (swift_slowAlloc).

This changes the graph traversal to be iterative, and brings big performance gains. Here are before and after samples:

Before

screen shot 2018-10-08 at 4 29 15 pm

After

screen shot 2018-10-08 at 4 41 31 pm

Copy link
Collaborator

@jerrymarino jerrymarino left a comment

Choose a reason for hiding this comment

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

@kastiglione - thanks so much for the PR! LGTM

@@ -312,17 +312,25 @@ public class XcodeTarget: Hashable, Equatable {
return []
}

return unfilteredDependencies.flatMap { (xcodeTarget: XcodeTarget) -> [XcodeTarget] in
var transitiveTargets: [XcodeTarget] = []
var queue = unfilteredDependencies
Copy link
Collaborator

Choose a reason for hiding this comment

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

Nicee

Copy link
Collaborator

@jerrymarino jerrymarino left a comment

Choose a reason for hiding this comment

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

@kastiglione - thanks so much for the PR! LGTM

Sources/XCHammer/XcodeTarget.swift Show resolved Hide resolved
@jerrymarino jerrymarino merged commit 5d2f3b3 into bazel-xcode:master Oct 10, 2018
@kastiglione kastiglione deleted the perf-transitiveTargets branch October 11, 2018 03:55
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.

2 participants