haskell-language-server icon indicating copy to clipboard operation
haskell-language-server copied to clipboard

High memory usage even on simple completion

Open mattatticus opened this issue 2 years ago • 15 comments

Hello. I am using Arch Linux with Neovim and nvim-lspconfig. I came across some issues with the language server. When I edit a simple haskell file, the memory usage of the language server just went up to 1.3G. I mean, is this normal? Please look forward to fix this. I have just 3G of ram and sometimes the server just uses so much memory that it causes a OOM and the system just freezes. Sometimes I have to hard reboot my pc :(.

Steps to reproduce

-- I just typed this in a file

import Data.List

main :: IO()
main = undefined

When providing some basic completions the server used up 1.3G of memory

mattatticus avatar Apr 19 '22 14:04 mattatticus

https://user-images.githubusercontent.com/87596985/164033177-3f45c302-8b28-4a52-a834-cb79f42ce518.mp4

The progress bar at the top right of the screen shows my memory usage.

mattatticus avatar Apr 19 '22 14:04 mattatticus

What version are you using and can you look at the logs to see if there is any information there? (check the troubleshooting docs)

drsooch avatar Apr 19 '22 19:04 drsooch

haskell

mattatticus avatar Apr 20 '22 13:04 mattatticus

Can you upgrade and try version 1.6? (Although, 1.7 is about to be released) I think there was some completion work done in 1.4, so it possibly may help.

drsooch avatar Apr 20 '22 13:04 drsooch

I have upgraded to version 1.6 . But still the issue persists

mattatticus avatar Apr 21 '22 15:04 mattatticus

I followed the steps you showed in your gif, I sat around 200 MB of live bytes with 900 MB heap. You can try passing -j 1 to HLS at start up to force it to use one core, although I'm not sure if it would help or not.

Unfortunately compiling Haskell is a memory intensive operation, when working on a haskell project I routinely push near 5 GB of ram usage by HLS depending on what I'm doing.

Also if this is actually a bug please take a look at HLS logs to see if there is anything out of the ordinary. Starting in 1.6 the logs will display the memory usage by the server.

drsooch avatar Apr 22 '22 02:04 drsooch

You can try passing -j 1 to HLS at start up to force it to use one core, although I'm not sure if it would help or not.

Don't do that, HLS needs at least two capabilities otherwise it won't work.

michaelpj avatar Apr 26 '22 08:04 michaelpj

You can try passing -j 1 to HLS at start up to force it to use one core, although I'm not sure if it would help or not.

Don't do that, HLS needs at least two capabilities otherwise it won't work.

I believe this is no longer true, hls-graph removes this requirement.

pepeiborra avatar Apr 26 '22 14:04 pepeiborra

You can try passing -j 1 to HLS at start up to force it to use one core, although I'm not sure if it would help or not.

I tried passing -j 1 to HLS but it just stops working completely. Its memory usage dropped down but there was no completions , no redundency checks, nothing.

mattatticus avatar May 02 '22 13:05 mattatticus

You can try passing -j 1 to HLS at start up to force it to use one core, although I'm not sure if it would help or not.

I tried passing -j 1 to HLS but it just stops working completely. Its memory usage dropped down but there was no completions , no redundency checks, nothing.

I cannot reproduce this with HLS 1.7.0. How are you passing the parameter?

How many cores do you have anyway? -j1 will only help if you have more than 1.

pepeiborra avatar May 02 '22 16:05 pepeiborra

I just have 2 cores. I cannot upgrade to version 1.7.0 as I have to compile it myself and I am on Arch (it throws various errors when compiling). So I stopped trying to compile and stick to 1.6.0. In the meanwhile I was using ghcid for some of my work. It just provided error reports. It does not provide completion or any of that stuff (It was never made to that). But it works. And I am considering to use it until I can upgrade to version 1.7.0.

mattatticus avatar May 03 '22 06:05 mattatticus

How do I build the project statically. I just want to link all the haskell deps to the main executable. I have tried messing around with the stack yaml but no clue how to do it.

mattatticus avatar Jun 23 '22 12:06 mattatticus

I think I am in the same boat as @TonyTomCat01.

Run from VSCode as .ghcup/hls/1.7.0.0/lib/haskell-language-server-1.7.0.0/bin//haskell-language-server-9.0.2 --lsp I get between 1.2-3 GB of RAMs used. Does that look right for simply editing a 14-module stack project?

why-not-try-calmer avatar Jul 18 '22 08:07 why-not-try-calmer

I think I am in the same boat as @TonyTomCat01.

Run from VSCode as .ghcup/hls/1.7.0.0/lib/haskell-language-server-1.7.0.0/bin//haskell-language-server-9.0.2 --lsp I get between 1.2-3 GB of RAMs used. Does that look right for simply editing a 14-module stack project?

Depends on how many files you have open at one-time but yes that is not out of the ordinary.

drsooch avatar Jul 20 '22 16:07 drsooch

I think I am in the same boat as @TonyTomCat01. Run from VSCode as .ghcup/hls/1.7.0.0/lib/haskell-language-server-1.7.0.0/bin//haskell-language-server-9.0.2 --lsp I get between 1.2-3 GB of RAMs used. Does that look right for simply editing a 14-module stack project?

Depends on how many files you have open at one-time but yes that is not out of the ordinary.

I see. Is there any plan to improve the situation?

why-not-try-calmer avatar Jul 20 '22 16:07 why-not-try-calmer