-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Performance regression with Error Message classes #1691
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
Comments
When redesigning the messages, we wanted to keep the laziness - but since we're no longer dealing with only strings, this becomes more complicated. Whether it is forced or not depends a bit on the behavior of the Reporting trait. As you can see, all messages are taken by value and perhaps it is the following line that actually does the forcing, it could perhaps be made to take |
@felixmulder There's more code forcing by-name So either To enforce Methods in |
On a related topic: what's the chance of memory leaks due to laziness? To make this question more interesting, assume Dotty is used in an IDE that tries to preserve Also remember that class Foo(byNameMsg: => String) {
lazy val byLazyValMsg = byNameMsg
} in particolar, the initializer for |
@Blaisorblade - it's way too late in the evening for me to start with this, hence my short response. I have an idea of how to deal with this, it is sort of along the lines of what you suggest but without asserts (hopefully). The closurizing is not really redundant as this is where the by-name breaks for new messages since the suggested placement is where We'll get there, don't worry 🌞 |
Of course — I didn't mean to criticize for the incompleteness.
FWIW |
That's interesting, I wasn't aware of that. Is this documented anywhere? Dotty does not seem to do that (ping @DarkDimius) which may lead to surprising new memory leaks when porting an existing codebase. |
@smarter Answered in a new issue (with some more info). |
PR for this in #1696. |
Can we close this issue? |
Yes, Felix fixed it :). |
I have noted that the introduction of error message classes introduces potentially serious performance regressions.
Essentially, the model is that errors can appear very frequently because they are part of retracted backtracking. So even if the program compiles OK it could have generated 10's of thousands of error messages. Previously, that was not a problem because everything in diagnostics was by-name and got forced only when the error got printed. But the new error messages do not behave this way.
E.g. MissingIdentifier takes a by-value string, which is passed a name.show.
show
is an expensive operation. This should not be called everytime we generate an error.I think as a first approximation every string in error messages should be by-name, and we should make sure the string is not forced in the initialization code of the message.
The text was updated successfully, but these errors were encountered: