-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Init check: Early Promotion of fields #11533
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
case Warm(cls, outer) => | ||
canDirectlyPromote(outer) | ||
case _ => | ||
val summary = expand(pot) |
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.
This will lead to infinite loops. The following might be a test case:
class A {
val a = f
def f: A = f
class B(x: Int)
println(new a.B(5))
val n = 10
}
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.
Mitigating this with a visited
set. I think it's easier to just set a maximum recursion depth though, because this is only a speed-up measure most of the time...
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 can play with it and see which works better for the tests we have.
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.
Thanks for the good work.
We still need to
- figure out the failures in CI
- avoid expensive analysis of early promotion so that community build can finish fast
BTW: it's better to rebase against master than merging master to this PR.
case Warm(cls, outer) => | ||
canDirectlyPromote(outer) | ||
case _ => | ||
val summary = expand(pot) |
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 can play with it and see which works better for the tests we have.
if errs.isEmpty then | ||
Errors.empty | ||
else | ||
UnsafePromotion(warm, eff.source, state.path, errs.toList).toErrors |
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 community build does not finish within 3 hours. We need to find a way to avoid "expensive" analysis. A budget for early promotion?
1055156
to
5a4a0d0
Compare
be1606b
to
dc2b873
Compare
The following program will take some time to type-check: class A {
def v: A = new A {
def get_b: A =
v1
v2
// v3
v
}
def v1 = v
def v2 = v
// def v3 = v
print(v)
} The time taken to type-check seems to grow exponentially compared to the number of methods (if I uncommented The above problem is super-evident in the |
Nice minimization @natsukagami 👍 The program does not seem to be complex, there might be a big optimization opportunity hidden there. |
16b1318
to
e70cba0
Compare
e70cba0
to
c6cf0de
Compare
@liufengyun Turns out the long running time was caused by the cache bug fixed in |
Thanks @natsukagami, great to know. I did expect #12055 to improve performance but didn't know it causes exponential behavior. |
c6cf0de
to
259a2ab
Compare
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.
LGTM, thanks @natsukagami 🎉
Promote(pot, outer)
effect.Promote(pot, outer) <= Promote(outer)
) is now used as a quick check (canDirectlyPromote
), before the newer, more costly check is run.This change is