-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove document from state table when it is closed. #753
Conversation
We could use ocaml GC module to know the memory footprint and let the user declare a cap above which we purge closed tabs. |
@rtetley I did look at this PR implementing the memory reclaim when the memory footprint > 4G (should be configurable I guess). There are two problems:
|
Thanks Gaetan, that clearly helped! Indeed the stack is a root. Kudos. There is still something bad, I don't know if we should used some memory profiler.
(3.97G -> 2.68G)
(93.9M -> 124M) |
Closing the trivial buffer actually increses the memory, I don't know how Gc.compact can result in that. |
Since you measure |
update it is not reproducible, this time it went down to 500M, that is still huge, but 5 times smaller. So I guess the measure implemented in this PR is OKish. The other question for @rtetley is still valid: why is the code doing something on invisible tabs? Is it wanted? Should I systematically skip working on invisible tabs (even if their state is not purged)? |
What is the state of the installed summary (eg the parser state, Global.env, etc) when running the Gc.compact? |
Exactly, this is what could have changed, since this time I worked on the smaller tab before closing the huge one. It means that calling compact without installing a minimal state may not work well. Looking into it. |
Bingo! it now goes to 100M without fiddling with other tabs |
let path = DocumentUri.to_path textDocument.uri in | ||
begin match Hashtbl.find_opt states path with | ||
| None -> assert false | ||
| Some { st } -> replace_state path st false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the reason for doing replace
with visible = false
then filtering instead of doing Hashtbl.remove
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You don't necessarily want to remove the execution state of the document when you close it. For example you might close a document by mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The point is that, if memory allows for it, we want to keep the coq sessions alive.
It is not uncommon to close a tab and reopen it.
In VSCode you have the usual browser shortcut for it, ctrl-w to close and shift-ctrl-t to open the last closed tab.
In this scenario we want to be nice to the users and not lose their session.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does reopening the tab get the saved state with the current code?
Also I guess the consider_purge should be delayed a bit since big sessions are the ones that are the worst to lose by mistake.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good question. Probably not at the moment.
For the consider_purge a reasonable alternative would be to send a popup message to the user when memory runs out asking him if he wants to purge ?
a44edc6
to
eca732a
Compare
I think we are good to go. @gares ? |
Closes #751