Haskell-ide-engine: Have a watchdog restarting hie on high memory usage

Created on 6 Sep 2018  路  6Comments  路  Source: haskell/haskell-ide-engine

A common complaint about hie is its unbounded memory consumption. This can be due to many different factors, but probably mostly to the famously known memory leak in GHCi, which has mostly been solved in the upcoming GHC 8.6.

For many the road to using 8.6 is far away in the future, so we should mitigate the issue with some other measures. One strategy can be having a separate thread in hie checking on the memory usage and making the server restart when it exceed a certain threshold.

Before restart, hie can send a window/ShowMessage explaining what it is doing.

discussion performance

Most helpful comment

I experience high memory consumption (> 6GB) even with a hello world project for a few minutes which brings the system to its knees :cry:
hie

All 6 comments

This will need some kind of command line parameter, or config setting to decide on the criteria for restart,

I tried to implement this but found a couple roadblocks:

  • The vscode plugin does not seem to be handling restarts successfully. After a restart, opening new files will not get them type checked and will get no diagnostics at all.
  • The neovim client does not restart the server when it dies

Given those 2 issues, the experience of restarting the server will be significantly worse than consuming too much memory, so canning this for the time being.

@lorenzo, the workaround I posted some time ago in the other issue does partially what you want:
https://github.com/haskell/haskell-ide-engine/issues/412#issuecomment-385033847 OTOH, this does not solve the issues you mentioned.

Given those 2 issues, the experience of restarting the server will be significantly worse than consuming too much memory

I don't agree with that. Having OS unresponsive is very bad. I am working on not so small 35k LOC project and as soon as HIE uses more than ~4 GB memory my OS (macOS) starts to get sluggish and unresponsive. This is not out of memory condition, but HIE and kernel task are using all CPU (probably this is related to some memory allocation routines).

@kfigiela I'm not saying the issue should be ignored, only that after trying a restart in vscode and neovim, in both cases I had to restart the editor. That's no different to having the user just do that.

If using hie-wrapper through vscode I get reliable restarts of hie-x.y.
If hie-wrapper gets killed it's a different story.

Tools like earlyoom are a big cannon but may help alleviating the symptom.
You can customize it to prefer killing hie-x.y over something else.

I experience high memory consumption (> 6GB) even with a hello world project for a few minutes which brings the system to its knees :cry:
hie

Was this page helpful?
0 / 5 - 0 ratings