Why sourcekit-lsp.exe consumes so much CPU even when idle?

Hello everyone,

My Windows app uses sourcekit-lsp. It processes requests from my app. There are not many requests, and if there is no input from the user in my app, there are no requests at all (I checked, my application is not at fault). Despite this, the sourcekit-lsp process constantly consumes ~24% of CPU power all the time, even when idle. What can cause this? What intensive calculations it does when nothing is requested from it?

Which version of sourcekit-lsp are you using? You might be hitting Issues on Windows Swift 5.9 · Issue #982 · apple/sourcekit-lsp · GitHub. That issue is present in all Swift 5.9 toolchains. Could you try if you see the same issue with a 5.10 or main development snapshot from Swift.org - Download Swift?

I am using Swift 5.9.2. Just tried both Swift 5.10 Development and Trunk Development (main) which shows version number 5.11-something. Unfortunately the problem persists in both :slightly_frowning_face:

I've tested older versions, starting from v5.6.1:

Swift version CPU usage by sourcekit-lsp
5.6.1         0%
5.6.2         not tested
5.6.3         not tested
5.7           not tested
5.7.1         not tested
5.8           0%
5.8.1         0%
5.9           24%
5.9.1         not tested
5.9.2         24%
5.10 dev      24%
trunk dev     24%

It seems the bug was introduced in version 5.9 and is still not fixed in either Swift 5.10 Development or Trunk Development (main).

1 Like

This is definitely interesting. I wonder if we can isolate this a bit further. I think that it might be possible to isolate libdispatch (though it is unlikely to be the cause as it doesn't change very much). I wonder if the issue is in SourceKit-LSP, sourcekitd, or somewhere else. Hopefully @z2oh might have some time to look into this.


Swift 5.10 is out, and the bug is still there :cry:
Please sourcekit-lsp developers take a look at this issue.

Do you know if a corresponding issue with self-contained reproduction steps tracking this exists at Issues · apple/sourcekit-lsp · GitHub? If it doesn't, would you mind filing one?

Thanks for pointing me in the right direction. I have checked the Issues · apple/sourcekit-lsp · GitHub and didn't find a corresponding issue.

I think that I will file the issue there after preparing the steps to reproduce it.

Done. Excessive CPU usage even when idle (Windows platform) · Issue #1121 · apple/sourcekit-lsp · GitHub

1 Like