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

Change traverseModules to return modules with their dependencies #7977

Merged
merged 1 commit into from
Sep 20, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Sep 18, 2024

Companion of swiftlang/sourcekit-lsp#1683


Opening the SourceKit-LSP workspace using a debug build of sourcekit-lsp takes about 35s because traverseModules generates about 800,000 callback calls. All SourceKit-LSP needs now are the modules and their dependencies, so we can refactor traverseModules to just return that information avoid visiting the same modules multiple times. With theses changes getting all modules and their dependencies only takes ~0.013s.

rdar://136107035

@ahoppen
Copy link
Member Author

ahoppen commented Sep 18, 2024

swiftlang/sourcekit-lsp#1683

@swift-ci Please test

/// provides the data to the caller by means of `onModule` callback. The products
/// are completely transparent to this method and are represented by their module dependencies.
/// Calls `onModule` for every module in the the package with the modules that depend on it. The products are
/// completely transparent to this method and are represented by their module dependencies.
package func traverseModules(
Copy link
Contributor

Choose a reason for hiding this comment

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

If you want to filter out all of duplicate spots where a particular module is used then all you need to do is modify depthFirstSearch to not walk into duplicate nodes, this method can stay the same.

Copy link
Member Author

Choose a reason for hiding this comment

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

Updated it to check whether we visited a node already in successors.

@ahoppen ahoppen force-pushed the traverse-modules branch 2 times, most recently from ab9e327 to 1407b2a Compare September 18, 2024 23:23
@ahoppen
Copy link
Member Author

ahoppen commented Sep 18, 2024

swiftlang/sourcekit-lsp#1683

@swift-ci Please test

Opening the SourceKit-LSP workspace using a debug build of sourcekit-lsp takes about 35s because `traverseModules` generates about 800,000 callback calls. All SourceKit-LSP needs now are the modules and their dependencies, so we can refactor `traverseModules` to visit only node once. With these changes getting all modules and their dependencies only takes ~0.013s.

rdar://136107035
@ahoppen
Copy link
Member Author

ahoppen commented Sep 19, 2024

swiftlang/sourcekit-lsp#1683

@swift-ci Please test

@ahoppen
Copy link
Member Author

ahoppen commented Sep 19, 2024

swiftlang/sourcekit-lsp#1683

@swift-ci Please test Windows

@ahoppen
Copy link
Member Author

ahoppen commented Sep 19, 2024

swiftlang/sourcekit-lsp#1683

@swift-ci Please test

@ahoppen ahoppen merged commit fc49d53 into swiftlang:main Sep 20, 2024
5 checks passed
@ahoppen ahoppen deleted the traverse-modules branch September 20, 2024 01:03
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