[clangd] ClangdScheduler & LLVM ThreadPool

Hi all,

I am wondering about the fact that there is an implementation of asynchronous message queue (ClangdScheduler) in clangd which in principle is similar to what ThreadPool in LLVM Support does. I just wanted to ask what other people think about possibility of using ThreadPool in clangd as we could potentially spare some resources on maintaining only one version. It’s not a lot of code and those two implementations are not exactly the same so some one-time effort would be needed but it still might be worthwhile.




Hi Jan,

Implementation used in clangd is a little specific to clangd, e.g. it allows to add requests to both ends of the queue (to allow high-priority ops like completion to be run before everything else).
We’ll also be moving away from ThreadPool-like interface for ClangdScheduler to better handle the resources we use and minimize unneeded pauses (e.g., we wait() for ASTs to parse on the worker threads, keeping workers from doing useful work).

I’m currently working on revamped threading implementation in clangd, so I suggest waiting before it lands. (I’ll make sure to update this thread when it does).
I’ll also keep an eye on whether we would be able to reuse the ThreadPool in the new implementation.

Hi Ilya,

Thank you for your feedback. I am not really rushing to rewrite ClangdScheduler I was mostly just curious about the possibility.

I am looking forward to your new threading implementation!