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

Opening the sourcekit-lsp package takes about 5 seconds to initialize until LSP-based functionality starts to be come available #1181

Open
ahoppen opened this issue Apr 17, 2024 · 4 comments

Comments

@ahoppen
Copy link
Collaborator

ahoppen commented Apr 17, 2024

Oh, sorry. Taking this back. The issue appears to be that initializing sourcekit-lsp takes about 3 seconds when opening sourcekit-lsp and opening the first document takes another 2 seconds (SwiftPM is doing something around dependency loading). Attaching a log of sourcekit-lsp serve initialization.

Possible solutions here could include:

  • Figure out why initializing the SwiftPMWorkspace takes 3 seconds during initialization
  • Not wait for the initialization of SwiftPMWorkspace to finish before returning from the InitializeRequest
  • Figure out why we are doing package loading during the textDocument/didOpen notification
  • Time out during build settings retrieval, open file with fallback build settings and re-open it when real build settings become available.

It could also be that this is competing for the build directory lock with package loading that is started by the Swift extension, which means that package initialization can’t start until that package resolve is done.

@ahoppen
Copy link
Collaborator Author

ahoppen commented Apr 17, 2024

Tracked in Apple’s issue tracker as rdar://126644596

@adam-fowler
Copy link
Contributor

Competing for the lock sounds very possible.

@z2oh
Copy link
Contributor

z2oh commented May 14, 2024

Not sure if this is the same issue, but I've noticed what I believe to be a regression (on Windows) where initialization in a large compilation database project takes almost 3 minutes.

Received response 'initialize - (0)' in 166488ms

I haven't dug into this too deeply yet, if this issue is scoped just to SwiftPMWorkspace then my issue could be unrelated.

The time it takes here seems to scale with project size, initializing a HelloWorld CMake project took 7174ms.

@ahoppen
Copy link
Collaborator Author

ahoppen commented May 14, 2024

I don’t think that’s related. The issue is about SwiftPMWorkspace doing work (like resolving package dependencies) and SourceKit-LSP shouldn’t get into that path if your project doesn’t have a Package.swift.

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

No branches or pull requests

3 participants