digitallyinduced / ihp

🔥 The fastest way to build type safe web apps. IHP is a new batteries-included web framework optimized for longterm productivity and programmer happiness
https://ihp.digitallyinduced.com/
MIT License
4.92k stars 195 forks source link

Haskell extension hangs in VSCode #1209

Closed barnabasmolnar closed 2 years ago

barnabasmolnar commented 2 years ago

When using IHP, either locally inside a WSL2 distro or via a Gitpod instance, the Haskell extension in VSCode hangs for a lot of time before becoming operational. For me, it's usually 4 minutes or so but a friend of mine on a weaker PC reported loading times up to 20-30 minutes.

I've provided some logs below. Some of the actions that seem to have taken a lot of time are:

Wingman.getMetaprogramsAtSpan.TypeCheck (took 2m17s) Wingman.codeLensProvider.GetBindings (took 3m34s) RefineImports (took 3m34s)

When I'm using stack to manage my own Haskell projects, the extension seems to work fine and near instantaneously. Admittedly those projects are far smaller and have fewer files and everything... but ~4 minutes still seems very excessive to me.

Would be curious if anyone had similar issues and whether there might be a fix to speed things up.

Click to expand log ```log Found "/home/roy/Developer/personal/bookmark-app/hie.yaml" for "/home/roy/Developer/personal/bookmark-app/a" Run entered for haskell-language-server-wrapper(haskell-language-server-wrapper) Version 1.4.0.0 x86_64 ghc-8.10.7 Current directory: /home/roy/Developer/personal/bookmark-app Operating system: linux Arguments: ["--lsp"] Cradle directory: /home/roy/Developer/personal/bookmark-app Cradle type: Bios Tool versions found on the $PATH cabal: 3.6.0.0 stack: Not found ghc: 8.10.7 Consulting the cradle to get project GHC version... Project GHC version: 8.10.7 haskell-language-server exe candidates: ["haskell-language-server-8.10.7","haskell-language-server"] Launching haskell-language-server exe at:/nix/store/kq65wynaxf8f0kmrx698npsrdg63g8fy-ghc-8.10.7-with-packages/bin/haskell-language-server-8.10.7 haskell-language-server version: 1.4.0.0 (GHC: 8.10.7) (PATH: /nix/store/xpwc04nd8g9vxjvjs3p4mwbi8vfqh00r-haskell-language-server-1.4.0.0/bin/haskell-language-server) Starting (haskell-language-server)LSP server... with arguments: GhcideArguments {argsCommand = LSP, argsCwd = Nothing, argsShakeProfiling = Nothing, argsTesting = False, argsExamplePlugin = False, argsDebugOn = False, argsLogFile = Nothing, argsThreads = 0, argsProjectGhcVersion = False} with plugins: [PluginId "pragmas",PluginId "floskell",PluginId "fourmolu",PluginId "tactics",PluginId "ormolu",PluginId "stylish-haskell",PluginId "retrie",PluginId "brittany",PluginId "callHierarchy",PluginId "class",PluginId "haddockComments",PluginId "eval",PluginId "importLens",PluginId "refineImports",PluginId "moduleName",PluginId "hlint",PluginId "splice",PluginId "ghcide-hover-and-symbols",PluginId "ghcide-code-actions-imports-exports",PluginId "ghcide-code-actions-type-signatures",PluginId "ghcide-code-actions-bindings",PluginId "ghcide-code-actions-fill-holes",PluginId "ghcide-completions",PluginId "ghcide-type-lenses",PluginId "ghcide-core"] in directory: /home/roy/Developer/personal/bookmark-app Starting LSP server... If you are seeing this in a terminal, you probably should have run WITHOUT the --lsp option! Started LSP server in 0.03s setInitialDynFlags cradle: Cradle {cradleRootDir = "/home/roy/Developer/personal/bookmark-app", cradleOptsProg = CradleAction: Cabal} 2021-11-09 15:21:22.047563019 [ThreadId 5] INFO hls: Registering ide configuration: IdeConfiguration {workspaceFolders = fromList [NormalizedUri (-1027614979192674154) "file:///home/roy/Developer/personal/bookmark-app"], clientSettings = hashed Nothing} 2021-11-09 15:21:22.113315896 [ThreadId 96] INFO hls: Consulting the cradle for "Main.hs" Output from setting up the cradle Cradle {cradleRootDir = "/home/roy/Developer/personal/bookmark-app", cradleOptsProg = CradleAction: Bios} 2021-11-09 15:21:22.275097154 [ThreadId 96] INFO hls: Using interface files cache dir: /home/roy/.cache/ghcide/main-dab85eb4a271bd8d9607ae60f8f36b13c8d958a8 2021-11-09 15:21:22.275301813 [ThreadId 96] INFO hls: Making new HscEnv[main] 2021-11-09 15:21:22.324675893 [ThreadId 328] INFO hls: finish: Wingman.getIdeDynflags.GetModSummaryWithoutTimestamps (took 0.00s) 2021-11-09 15:21:22.325520979 [ThreadId 328] INFO hls: finish: ModuleName.ghcSession (took 0.00s) 2021-11-09 15:21:22.325719847 [ThreadId 324] INFO hls: finish: Wingman.getIdeDynflags.GetModSummaryWithoutTimestamps (took 0.00s) 2021-11-09 15:21:22.326199157 [ThreadId 319] INFO hls: finish: ModuleName.ghcSession (took 0.00s) 2021-11-09 15:21:22.326433995 [ThreadId 139] INFO hls: finish: ModuleName.GetParsedModule (took 0.00s) 2021-11-09 15:21:22.326800403 [ThreadId 323] INFO hls: finish: ModuleName.GetParsedModule (took 0.00s) 2021-11-09 15:21:22.330091861 [ThreadId 379] INFO hls: finish: eval.GetParsedModuleWithComments (took 0.01s) 2021-11-09 15:21:22.330184467 [ThreadId 380] INFO hls: finish: eval.GetParsedModuleWithComments (took 0.00s) 2021-11-09 15:21:22.330690486 [ThreadId 387] INFO hls: finish: Wingman.codeLensProvider.GetAnnotatedParsedSource (took 0.00s) 2021-11-09 15:21:22.330752136 [ThreadId 386] INFO hls: finish: Wingman.codeLensProvider.GetAnnotatedParsedSource (took 0.00s) 2021-11-09 15:24:56.248121566 [ThreadId 651] INFO hls: finish: codeLens.TypeCheck (took 3m34s) 2021-11-09 15:24:56.248127775 [ThreadId 652] INFO hls: finish: codeLens.TypeCheck (took 3m34s) 2021-11-09 15:24:56.248561625 [ThreadId 655] INFO hls: finish: Wingman.getMetaprogramsAtSpan.TypeCheck (took 2m17s) 2021-11-09 15:24:56.248581634 [ThreadId 656] INFO hls: finish: Wingman.getMetaprogramsAtSpan.TypeCheck (took 33.42s) 2021-11-09 15:24:56.248629944 [ThreadId 657] INFO hls: finish: Wingman.getMetaprogramsAtSpan.TypeCheck (took 31.67s) 2021-11-09 15:24:56.248838763 [ThreadId 666] INFO hls: finish: (took 3m34s) 2021-11-09 15:24:56.248998323 [ThreadId 667] INFO hls: finish: (took 3m34s) 2021-11-09 15:24:56.250996724 [ThreadId 700] INFO hls: finish: Wingman.codeLensProvider.GetBindings (took 3m34s) 2021-11-09 15:24:56.251188693 [ThreadId 702] INFO hls: finish: codeLens.GetBindings (took 0.00s) 2021-11-09 15:24:56.25184629 [ThreadId 703] INFO hls: finish: codeLens.GetBindings (took 0.00s) 2021-11-09 15:24:56.252512226 [ThreadId 699] INFO hls: finish: Wingman.codeLensProvider.GetBindings (took 3m34s) 2021-11-09 15:24:56.252829056 [ThreadId 704] INFO hls: finish: Wingman.emptyCaseScrutinees.TypeCheck (took 0.00s) 2021-11-09 15:24:56.252948795 [ThreadId 713] INFO hls: finish: Wingman.emptyCaseScrutinees.TypeCheck (took 0.00s) 2021-11-09 15:24:56.252975745 [ThreadId 715] INFO hls: finish: Wingman.emptyCaseScrutinees.GhcSessionDeps (took 0.00s) 2021-11-09 15:24:56.253053554 [ThreadId 720] INFO hls: finish: codeLens.GetGlobalBindingTypeSigs (took 0.00s) 2021-11-09 15:24:56.253112739 [ThreadId 719] INFO hls: finish: codeLens.GetGlobalBindingTypeSigs (took 0.00s) 2021-11-09 15:24:56.253022144 [ThreadId 717] INFO hls: finish: Wingman.emptyCaseScrutinees.GhcSessionDeps (took 0.00s) 2021-11-09 15:24:56.277750874 [ThreadId 778] INFO hls: finish: RefineImports (took 3m34s) 2021-11-09 15:24:56.277771453 [ThreadId 779] INFO hls: finish: RefineImports (took 3m34s) ```
mpscholten commented 2 years ago

Thanks for creating this issue 👍 I think quite a few people already reported similiar problems on Slack.

Maybe you could also open an issue on the Haskell Language Server, linking back to this issue? I think we should definitly also have this issue on the IHP issue tracker here as it's affecting the overall experience, but likely the HLS devs can do more to fix this issue :)

zacwood9 commented 2 years ago

I experience this on WSL2 but interestingly not MacOS. Same project but it works very quick on macOS but takes 5+ minutes on WSL2. Just adding my experience here too

tothatt81 commented 2 years ago

I have similar experience. It works fine on Mac but HLS takes a lot of time to start on WSL2. I even tried to disable some HLS plugins (like Wingman) but that didn't help for me.

HugoPeters1024 commented 2 years ago

I have this issue while actually booting ubuntu without any virtualization, so it may not be only an issue with WSL

mpscholten commented 2 years ago

It would be nice if everyone of you could file an issue at https://github.com/haskell/haskell-language-server with the details you shared here :) Maybe you can also link to this issue here from the HLS repo issue

barnabasmolnar commented 2 years ago

Done: https://github.com/haskell/haskell-language-server/issues/2340

mpscholten commented 2 years ago

Closing this as it looks like the issue is fixed with v0.18 :) feel free to reopen if you stumble across new issues with HLS.

inspectiontopic commented 2 years ago

Processing 31/32 or something similar appears, and the Haskell extension hangs. The issue occurs multiple times in an hour while editing code in a newly created project with ihp-new. I use pkill to kill HLS. Here is the environment.

IHP v0.19.0
Haskell for Visual Studio Code v2.2.0
Visual Studio Code 1.68.1
Ubuntu 20.04

Here is a log.

2022-06-21 09:36:03.158685019 [ThreadId 17134] INFO hls:    finish: Wingman.getIdeDynflags.GetModSummaryWithoutTimestamps (took 0.00s)
2022-06-21 09:36:03.158789395 [ThreadId 17135] INFO hls:    finish: Wingman.judgementForHole.GetHieAst (took 0.00s)
2022-06-21 09:36:03.158872665 [ThreadId 17136] INFO hls:    finish: Wingman.judgementForHole.GetBindings (took 0.00s)
2022-06-21 09:36:03.158941029 [ThreadId 17137] INFO hls:    finish: Wingman.judgementForHole.TypeCheck (took 0.00s)
2022-06-21 09:36:03.159005734 [ThreadId 17138] INFO hls:    finish: Wingman.judgementForHole.GhcSessionDeps (took 0.00s)
2022-06-21 09:36:03.325814303 [ThreadId 17167] INFO hls:    finish: Completion (took 0.00s)
2022-06-21 09:36:03.501385144 [ThreadId 17382] INFO hls:    finish: Completion (took 0.00s)
[Info  - 9:37:15 AM] Connection to server got closed. Server will restart.

The troubleshooting guide didn't help. https://ihp.digitallyinduced.com/Guide/editors.html#vscode-haskell-language-server-troubleshooting

mpscholten commented 2 years ago

Thanks for reporting.

Maybe you could open an issue on the Haskell Language Server repo? Likely the HLS people can do more to fix the issue.