Skip to content

Fix performance degradation: make message fields lazy #8603

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

Merged
merged 13 commits into from
Mar 26, 2020

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Mar 24, 2020

Make fields msg and explanation in Message lazy and make
message containers strict.

That way, we can look inside a message container to find out what kind
of message we have without fear of forcing too much.

[EDIT]

This has turned into a large-scale refactoring of the error reporting chain. The aim was to make things more consistent, simpler, and more robust. We also fix some problems where tags would make it into the reported message, which was a classic case of people working on paralellel solutions that did not compose correctly with each other.

One reason for the drop in linecount is that I chucked ErrorMessagesTest out. I had little else but nuisance value.

@odersky
Copy link
Contributor Author

odersky commented Mar 24, 2020

We should also update the advice how to write an error message to include the laziness. And be vigilant for a while that nothing strict slips back in. The rules are:

  • Every message container should have msg and explanation (if defined) as lazy vals.
  • The kind field is a strict val.
  • There should be no other strict vals in a Message.

@nicolasstucki
Copy link
Contributor

test performance with #fast please

@dottybot
Copy link
Member

performance test scheduled: 1 job(s) in queue, 1 running.

@@ -12,7 +12,7 @@ object Message {
* not yet been ported to the new scheme. Comment out this `implicit def` to
* see where old errors still exist
*/
implicit def toNoExplanation(str: String): Message =
implicit def toNoExplanation(str: => String): Message =
Copy link
Member

@smarter smarter Mar 24, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's worth noting that we cannot have an implicit conversion from a by-name param when using Dotty's Conversion mechanism.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I noted that as well. That's a problem.

@dottybot
Copy link
Member

performance test failed:

Please check http://lamppc37.epfl.ch:8000/pull-8603-03-24-21.43.out for more information

@smarter
Copy link
Member

smarter commented Mar 24, 2020

Please check http://lamppc37.epfl.ch:8000/pull-8603-03-24-21.43.out for more information

I connected to EPFL vpn to check it out, but got back:

File not found. :(

/cc @liufengyun

@liufengyun
Copy link
Contributor

It's running now --- I accidentally remove the staging remote while fixing an issue.

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/8603/ to see the changes.

Benchmarks is based on merging with master (6cd3a9d)

@nicolasstucki
Copy link
Contributor

test performance please

@dottybot
Copy link
Member

performance test scheduled: 1 job(s) in queue, 0 running.

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/8603/ to see the changes.

Benchmarks is based on merging with master (6cd3a9d)

@allanrenucci
Copy link
Contributor

Why not make all the message fields (msg, kind, explanation) be defs? To the best of my knowledge, they are evaluated only once when they are reported.

@odersky
Copy link
Contributor Author

odersky commented Mar 25, 2020

@allanrenucci Good point. I don't know whether there are situations where we want to read these fields more than once.

@liufengyun
Copy link
Contributor

test performance please

@dottybot
Copy link
Member

performance test scheduled: 1 job(s) in queue, 0 running.

@dottybot
Copy link
Member

dottybot commented Mar 25, 2020

performance test failed:

Please check http://lamppc37.epfl.ch:8000/pull-8603-03-25-19.27.out for more information

Merge conflict, the PR needs rebase.

odersky added 10 commits March 25, 2020 21:39
Make field `msg` and `explanation` in Message lazy and make
message containers strict.

That way, we can look inside a message container to find out what kind
of message we are having without fear of forcing too much.
Also:

 - Turn some message classes into normal classes. More to follow.
   For error messages there's really no justification to
   spend all the extra code size on case class infrastructure.

 - Drop ErrorMessageTest. That's the only test that requires
   message classes to be case classes. Over the whole time of
   its existence, that test was nothing more than a pain in the ass.
   I do not think there was a single real fault that it reported
   but it caused lots of extra work everytime a message changes.
   Best not to waste more cycles composing and fixing these tests.
There's no need to have the additional code for the case class machinery in the compiler.
Fixes in files that were not saved before
It was not clear go me that `diagnostic` should be its own package.
The previous pipeline forgot to filter out <nonsensical> tags in most situations
@odersky
Copy link
Contributor Author

odersky commented Mar 25, 2020

test performance please

@dottybot
Copy link
Member

performance test scheduled: 1 job(s) in queue, 0 running.

@dottybot
Copy link
Member

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/8603/ to see the changes.

Benchmarks is based on merging with master (37eec14)

Caching is done at a central point in class `Message` where also
`<nonsensical>` tags are dropped.
@odersky
Copy link
Contributor Author

odersky commented Mar 26, 2020

@anatoliykmetyuk can you give it a quick review? Since it touches many things it would be good to get this in sooner rather than later. It might still have some weaknesses but I am sure it's better than what we had before.

@anatoliykmetyuk anatoliykmetyuk merged commit 82d76e8 into scala:master Mar 26, 2020
@anatoliykmetyuk anatoliykmetyuk deleted the fix-performance branch March 26, 2020 12:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants