-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Make lazy vals thread-safe by default #6579
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
Conversation
9f11894
to
54ea912
Compare
test performance please |
performance test scheduled: 2 job(s) in queue, 1 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/6579/ to see the changes. Benchmarks is based on merging with master (6ede814) |
54ea912
to
de46982
Compare
de46982
to
0b46b97
Compare
test performance please |
performance test scheduled: 3 job(s) in queue, 1 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/6579/ to see the changes. Benchmarks is based on merging with master (2984e57) |
0b46b97
to
322487b
Compare
I am still concerned that the compile time trend here is upwards. If lazy vals in Definitions are not the problem, where else would they be one? |
My first suspect would be
in Types.scala. Then the lazy vals in Applications.scala and Implicits.scala, as well as the lazy vals defined in the Backend. Maybe make all of these @ThreadUnsafe as well? |
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 changes look good to me, but let's try to tweak performance a bit more before merging.
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/6579/ to see the changes. Benchmarks is based on merging with master (c165638) |
It seems unfortunate to allocate a general-sounding name like |
Nothing prevents us from reusing it to work on other things than lazy vals. It's documented as only working on lazy vals since it's the only place where it does something currently. |
Interesting -- do you have any examples in mind?
…On Sun, Jun 2, 2019, 5:24 PM Guillaume Martres ***@***.***> wrote:
Nothing prevents us from reusing it to work on other things than lazy
vals. It's documented as only working on lazy vals since it's the only
place where it does something currently.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#6579>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAAYAUHB6IQESMWFGKPGBHTPYQ27ZANCNFSM4HQE5LHA>
.
|
Nope |
@odersky OK to merge ? |
@smarter It's OK to merge. I still would have liked to go to the bottom of the performance regressions. E.g. Re2 is clearly worse. I wonder where that could come from. But it's not urgent, we can do it later |
Otherwise we might end up trying to initialize UnitType recursively, which happens to work with the current implementation of non-volatile lazy vals, but won't work after the next commit.
Previously this required using `@volatile` but that would not be consistent with Scala 2. The old behavior of non-volatile lazy vals can be recovered by using the newly-introduced `@threadUnsafe`.
There does not seem to be a noticeable performance difference compared to thread-safe lazy vals but there is a noticeable impact on bytecode size (Definitions.class goes from 210 to 168K).
989c95d
to
a73b830
Compare
Previously this required using
@volatile
but that would not beconsistent with Scala 2. The old behavior of non-volatile lazy vals can
be recovered by using the newly-introduced
@threadUnsafe
.