SourceKit-LSP CPU spinning and libdispatch complications

@owenv could you share a way to repro those hangs?

FWIW we should probably converge onto a single approach there and here. JSONRPCConnection is a pretty thin wrapper around the subprocess, so if swift-subprocess is the plan there then maybe we should also be doing it here, unless I’m missing something (hopefully it’s not DispatchIO based as then we’re back to the original problem..). All the wrapper needs is post data to stdin, realtime handler of stdout and a way to properly handling close()

And btw I did end up running into issues with close() during local testing as there is a specific test testCloseRace here which catches an issue that I’m yet to investigate

My issue with close() turned out to be a user error (missing ioGroup.leave())

I uploaded the last version of the code to Prototype pipe handling without dispatch IO by roman-bcny · Pull Request #2315 · swiftlang/sourcekit-lsp · GitHub and sent that for review. It’s using availableData and I’m not seeing issues with parallel tests locally. If someone can provide a repro of availableData misbehaving I can try to dig into that as well.

PS. Github didn’t notify me about those comments some of you left on my draft PR so I only saw them today after uploading my latest changes!

1 Like