helix icon indicating copy to clipboard operation
helix copied to clipboard

Very poor performance with Haskell files

Open dariooddenino opened this issue 2 years ago • 7 comments

Summary

Hi! I can't use helix with my haskell project anymore.

There are a couple of issues that I'm experiencing:

  1. When I make a change the diagnostics are updated after several seconds. From the logs you can see that 26 seconds pass between the code change and the error diagnostics showing up.

  2. When this happens, saving the file is delayed by several seconds if it even happens. Often I just have to wait for the LSP to be done and then save it again. Sometimes I get a red "Async operation failed" message or something similar flashing briefly in the status bar.

This wasn't happening before. The problem is that the issue persists even if I go back to older commits (when I know it was working fine). Removing my config.toml and languages.toml files doesn't change anything.

I'm pretty sure it's not a language server issue, as I can open the same file in emacs or vscode, make the same exact changes to the file and have near instant feedback.

I think this happens with haskell only, and only with projects that are over a certain size.

Anything I can try to figure this out or to give you more info?

Thank you!

Reproduction Steps

No response

Helix log

~/.cache/helix/helix.log
2023-01-09T14:33:51.643 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":24,"line":70},"start":{"character":24,"line":70}},"text":" "}],"textDocument":{"uri":"file:///...","version":15}}}
2023-01-09T14:33:54.412 helix_lsp::transport [ERROR] err <- "2023-01-09T13:33:54.412792Z | Info | Live bytes: 858.06MB Heap size: 3023.04MB\n"
2023-01-09T14:33:54.413 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"window/logMessage","params":{"message":"Live bytes: 858.06MB Heap size: 3023.04MB","type":3}}
2023-01-09T14:33:54.413 helix_term::application [INFO] window/logMessage: LogMessageParams { typ: Info, message: "Live bytes: 858.06MB Heap size: 3023.04MB" }
2023-01-09T14:33:55.628 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"610","value":{"kind":"report","message":"342/668"}}}
2023-01-09T14:33:55.729 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"610","value":{"kind":"report","message":"338/668"}}}
2023-01-09T14:33:56.030 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"610","value":{"kind":"report","message":"343/668"}}}
2023-01-09T14:33:56.733 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"610","value":{"kind":"report","message":"348/668"}}}
2023-01-09T14:34:00.807 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"610","value":{"kind":"end"}}}
2023-01-09T14:34:00.908 helix_lsp::transport [INFO] <- {"id":74,"jsonrpc":"2.0","method":"window/workDoneProgress/create","params":{"token":"613"}}
2023-01-09T14:34:00.908 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":null,"id":74}
2023-01-09T14:34:00.911 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"begin","title":"Processing"}}}
2023-01-09T14:34:00.912 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///...","version":15}}
2023-01-09T14:34:01.011 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"658/668"}}}
2023-01-09T14:34:01.111 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"282/668"}}}
2023-01-09T14:34:01.312 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"290/668"}}}
2023-01-09T14:34:01.430 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"refact:Avoid lambda","message":"...","range":{"end":{"character":59,"line":161},"start":{"character":16,"line":161}},"severity":3,"source":"hlint"},{"code":"refact:Avoid lambda","message":"...","range":{"end":{"character":62,"line":162},"start":{"character":19,"line":162}},"severity":3,"source":"hlint"}],"uri":"...","version":15}}
2023-01-09T14:34:01.613 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"296/668"}}}
2023-01-09T14:34:04.019 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"301/668"}}}
2023-01-09T14:34:04.119 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"300/668"}}}
2023-01-09T14:34:04.319 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"301/668"}}}
2023-01-09T14:34:04.419 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"300/668"}}}
2023-01-09T14:34:04.620 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"301/668"}}}
2023-01-09T14:34:10.339 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"309/668"}}}
2023-01-09T14:34:11.041 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"314/668"}}}
2023-01-09T14:34:11.141 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"313/668"}}}
2023-01-09T14:34:11.242 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"314/668"}}}
2023-01-09T14:34:15.858 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"321/668"}}}
2023-01-09T14:34:17.664 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"347/668"}}}
2023-01-09T14:34:17.765 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"336/668"}}}
2023-01-09T14:34:17.867 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"519/668"}}}
2023-01-09T14:34:17.930 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"refact:Avoid lambda","message":"...","range":{"end":{"character":59,"line":161},"start":{"character":16,"line":161}},"severity":3,"source":"hlint"},{"code":"refact:Avoid lambda","message":"...","range":{"end":{"character":62,"line":162},"start":{"character":19,"line":162}},"severity":3,"source":"hlint"},{"code":"-Wdeferred-type-errors","message":"...","range":{"end":{"character":68,"line":79},"start":{"character":0,"line":70}},"severity":1,"source":"typecheck"},{"code":"-Wunused-matches","message":"...’","range":{"end":{"character":24,"line":70},"start":{"character":23,"line":70}},"severity":2,"source":"typecheck","tags":[1]}],"uri":"...","version":15}}
2023-01-09T14:34:17.970 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"report","message":"667/668"}}}
2023-01-09T14:34:18.008 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"613","value":{"kind":"end"}}}

Platform

Linux

Terminal Emulator

kitty 0.26.5

Helix Version

22.12-108-g77860bdb

dariooddenino avatar Jan 09 '23 14:01 dariooddenino

It looks like the server hasn't finished initializing.

kirawi avatar Jan 09 '23 15:01 kirawi

@kirawi Yes, but the same happens even if I wait for it to end initializing.

dariooddenino avatar Jan 09 '23 15:01 dariooddenino

@kirawi Yes, but the same happens even if I wait for it to end initializing.

The whole point of providing logs is to help us debug your issue by looking at what's happening during your problem. If you're not taking the logs while the problem is happening, you're just giving us a random text file.

dead10ck avatar Jan 10 '23 03:01 dead10ck

Are you building helix from source? Make sure you're building in release mode. Is there a previous commit version where it works fine? Or maybe a previous haskell lsp version?

archseer avatar Jan 10 '23 05:01 archseer

@dead10ck Sorry, I didn't mean to provide a misleading log file. It's just that the same thing happens even if I wait. Here's a log taken well after the inizialization ended, same edit on the same file: 14 seconds from the change to the error diagnostics.

2023-01-10T09:03:28.258 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":23,"line":70},"start":{"character":23,"line":70}},"text":"f"}],"textDocument":{"uri":"file:///...","version":1}}}
2023-01-10T09:03:28.376 helix_lsp::transport [INFO] <- {"id":5,"jsonrpc":"2.0","method":"window/workDoneProgress/create","params":{"token":"344"}}
2023-01-10T09:03:28.376 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":null,"id":5}
2023-01-10T09:03:28.379 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[],"uri":"file:///...","version":1}}
2023-01-10T09:03:28.379 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"344","value":{"kind":"begin","title":"Processing"}}}
2023-01-10T09:03:28.393 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","method":"textDocument/didChange","params":{"contentChanges":[{"range":{"end":{"character":24,"line":70},"start":{"character":24,"line":70}},"text":" "}],"textDocument":{"uri":"file:///...","version":2}}}
2023-01-10T09:03:28.479 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"344","value":{"kind":"report","message":"662/667"}}}
2023-01-10T09:03:28.503 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"344","value":{"kind":"end"}}}
2023-01-10T09:03:28.609 helix_lsp::transport [INFO] <- {"id":6,"jsonrpc":"2.0","method":"window/workDoneProgress/create","params":{"token":"346"}}
2023-01-10T09:03:28.609 helix_lsp::transport [INFO] -> {"jsonrpc":"2.0","result":null,"id":6}
2023-01-10T09:03:28.610 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"begin","title":"Processing"}}}
2023-01-10T09:03:28.711 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"623/667"}}}
2023-01-10T09:03:28.811 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"298/667"}}}
2023-01-10T09:03:29.028 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"301/667"}}}
2023-01-10T09:03:29.195 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"refact:Avoid lambda","message":"...","range":{"end":{"character":59,"line":161},"start":{"character":16,"line":161}},"severity":3,"source":"hlint"},{"code":"refact:Avoid lambda","message":"...","range":{"end":{"character":62,"line":162},"start":{"character":19,"line":162}},"severity":3,"source":"hlint"}],"uri":"file:///...","version":2}}
2023-01-10T09:03:31.034 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"307/667"}}}
2023-01-10T09:03:31.136 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"306/667"}}}
2023-01-10T09:03:31.236 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"308/667"}}}
2023-01-10T09:03:32.941 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"315/667"}}}
2023-01-10T09:03:33.444 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"321/667"}}}
2023-01-10T09:03:33.544 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"320/667"}}}
2023-01-10T09:03:33.845 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"321/667"}}}
2023-01-10T09:03:33.946 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"320/667"}}}
2023-01-10T09:03:34.147 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"321/667"}}}
2023-01-10T09:03:36.654 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"328/667"}}}
2023-01-10T09:03:39.967 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"335/667"}}}
2023-01-10T09:03:41.872 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"331/667"}}}
2023-01-10T09:03:41.972 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"$/progress","params":{"token":"346","value":{"kind":"report","message":"444/667"}}}
2023-01-10T09:03:42.063 helix_lsp::transport [INFO] <- {"jsonrpc":"2.0","method":"textDocument/publishDiagnostics","params":{"diagnostics":[{"code":"refact:Avoid lambda","message":"...","range":{"end":{"character":59,"line":161},"start":{"character":16,"line":161}},"severity":3,"source":"hlint"},{"code":"refact:Avoid lambda","message":"...","range":{"end":{"character":62,"line":162},"start":{"character":19,"line":162}},"severity":3,"source":"hlint"},{"code":"-Wdeferred-type-errors","message":"...","range":{"end":{"character":68,"line":79},"start":{"character":0,"line":70}},"severity":1,"source":"typecheck"},{"code":"-Wunused-matches","message":"Defined but not used: ‘f’","range":{"end":{"character":24,"line":70},"start":{"character":23,"line":70}},"severity":2,"source":"typecheck","tags":[1]}],"uri":"...","version":2}}

@archseer I'm building from source with cargo install --locked --path helix-term.

A thing I failed to notice yesterday is that the old version of the language server fails to start completely, and that's because I also updated the project's GHC version. I tried the release binary and I get the same issue, so at this point I think it has to be some communication problem between hls-1.9.0.0 and helix since it works perfectly both with emacs and vscode. Sadly I can't double check by reverting to the old langauge server version, but it's the only thing left, more or less.

I'm going to try some more tests to see if I can isolate the issue and maybe create a reproducible case.

Thanks!

dariooddenino avatar Jan 10 '23 08:01 dariooddenino

It's a little hard to tell for sure, but I'm seeing change notices being sent before more progress messages. Are you sure it was done initializing? Or does it send those progress notices every time you write a change?

dead10ck avatar Jan 10 '23 11:01 dead10ck

@dead10ck Yeah, I'm sure it was done. I had a feeling it was somehow incorrectly reinitializing at every change, but I wasn't sure. I think this might be the issue

dariooddenino avatar Jan 10 '23 12:01 dariooddenino

Related issue from haskell-language-server repo:

https://github.com/haskell/haskell-language-server/issues/3458

dariooddenino avatar Jan 25 '23 09:01 dariooddenino

An important note from https://github.com/haskell/haskell-language-server/issues/3458 is that apparently HLS has changed behavior for editors that don't support changed file notifications. Does Helix support that? For more info, see https://github.com/haskell/haskell-language-server/issues/3458#issuecomment-1400600495

ocharles avatar Jan 25 '23 12:01 ocharles

We don't support that yet: https://github.com/helix-editor/helix/pull/2653

Seems like https://github.com/haskell/haskell-language-server/pull/3452 should help though and there was a regression in GHC 9.4?

archseer avatar Jan 25 '23 14:01 archseer

Yea, the comment above links to that PR and I'm using that locally for now. Things do seem much better!

ocharles avatar Jan 25 '23 14:01 ocharles

I have been using #2653 all day long and it seems to be working perfectly so far.

dariooddenino avatar Jan 26 '23 15:01 dariooddenino