-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Restart presentation compilers if memory is low #3967
Conversation
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.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Commit Messages
We want to keep history, but for that to actually be useful we have
some rules on how to format our commit messages (relevant xkcd).
Please stick to these guidelines for commit messages:
- Separate subject from body with a blank line
- When fixing an issue, start your commit message with
Fix #<ISSUE-NBR>:
- Limit the subject line to 72 characters
- Capitalize the subject line
- Do not end the subject line with a period
- Use the imperative mood in the subject line ("Added" instead of "Add")
- Wrap the body at 80 characters
- Use the body to explain what and why vs. how
adapted from https://chris.beams.io/posts/git-commit
Have an awesome day! ☀️
// ... 11 more | ||
// | ||
// This looks like a problem with Dottys code generation for void-returning closures passed | ||
// to Java methods. (or SAM functions in general?) |
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.
Hmm we should be returning a BoxedUnit here, could you open an issue so we can keep track of this?
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.
See #3984
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.
I guess this should be changed now that #3984 has been fixed?
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.
Yes, you are right.
Rebased. |
rebased |
// ... 11 more | ||
// | ||
// This looks like a problem with Dottys code generation for void-returning closures passed | ||
// to Java methods. (or SAM functions in general?) |
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.
I guess this should be changed now that #3984 has been fixed?
@@ -173,6 +204,7 @@ class DottyLanguageServer extends LanguageServer | |||
} | |||
|
|||
override def didChange(params: DidChangeTextDocumentParams): Unit = thisServer.synchronized { | |||
checkMemory() |
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.
Shouldn't checkMemory()
be called also when doing the other operations? I imagine that completion
and references
in particular can require quite some memory.
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.
Since they do not involve new runs, I don't think it's a problem. The leak comes from the memory of previous runs not being completely reclaimed.
I have noted during long editing sessions (lasting several days, typically) that memory can get full because the Dotty compiler has some space leaks. The leaks looks really hard to fix, and we don't know yet whether it's at all possible. To mitigate the leaks, this commit makes the language server watch available memory, and, if it is low (i.e. free memory after a GC < 10% of maximal available) restart all interactive drivers. This will free all memory of the compiler(s) except the shared nametable. There's a stressTest option in `Memory.scala`, which, when turned on, causes a restart every 10 editing actions. I verified that the compiler stays functional and reasonably responsive in that mode.
I observed a NoType when editing some code which caused ThisType#underlying to crash.
Merging this now since I am losing too much productivity running into the problem this solves. |
I have noted during long editing sessions (lasting several days,
typically) that memory can get full because the Dotty compiler has some
space leaks. The leaks look really hard to fix, and we don't know
yet whether it's at all possible. To mitigate the leaks, this commit
makes the language server watch available memory, and, if it
is low (i.e. free memory after a GC < 10% of maximal available)
restart all interactive drivers. This will free all memory of
the compiler(s) except the shared nametable.
There's a stressTest option in
Memory.scala
, which, when turned on,causes a restart every 10 editing actions. I verified that the compiler
stays functional and reasonably responsive in that mode.
Based on #3960