In larger projects, HLS often loads slowly. One of the main obstacles is that we are loading GHC options for files in strict sequential order.
I’ve attempted to improve this situation by making two changes.
Thanks to @fendor 's multiple home units support and the his issue Initial load of multiple home units is slow with lazy component loading · Issue #4381 · haskell/haskell-language-server · GitHub, which provided some directions.
- If you have multiple home units support, load as many pending files as possible at once.
- Refactor the loader to reader and writer over cache. This way, the long-loading file won’t block already loaded files, making HLS more responsive and smooth.
These changes mostly affect Cabal projects, but other types of projects might benefit from the second change as well.
The PR can be found in Decouple the session loader into reader and writer over the cache by soulomoon · Pull Request #4445 · haskell/haskell-language-server · GitHub.
I’m currently dogfooding this and getting positive results. Testing and feedback are welcome if you’re interested. This PR needs more feedback from Haskell developers to help polish it further.