Skip to content
This repository has been archived by the owner on Oct 7, 2020. It is now read-only.

Have a watchdog restarting hie on high memory usage #806

Open
lorenzo opened this issue Sep 6, 2018 · 6 comments
Open

Have a watchdog restarting hie on high memory usage #806

lorenzo opened this issue Sep 6, 2018 · 6 comments

Comments

@lorenzo
Copy link
Collaborator

lorenzo commented Sep 6, 2018

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.

@alanz
Copy link
Collaborator

alanz commented Sep 6, 2018

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

@lorenzo
Copy link
Collaborator Author

lorenzo commented Sep 8, 2018

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.

@kfigiela
Copy link

kfigiela commented Sep 10, 2018

@lorenzo, the workaround I posted some time ago in the other issue does partially what you want:
#412 (comment) 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).

@lorenzo
Copy link
Collaborator Author

lorenzo commented Sep 10, 2018

@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.

@unode
Copy link

unode commented Nov 4, 2018

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.

@yousefvand
Copy link

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants