-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Performance regression in 16463.scala #16463
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
OK, I found the infinite recursion: BubbleSort[DropLargest[T]] This recurses forever because
so I guess it's more of a reporting issue than correctness. |
With the latest Scala version, a recursion limit error is displayed for your test case:
Is this what you expected @kubukoz? |
@mbovel yeah, that's a bit better 😅 wondering how much stack I'd need to give it to actually see a result though. Can you set JVM flags for the compiler with scala-cli? (presumably it'd only work with |
Please dismiss my previous comments, I actually was able to reproduce on |
Strange, I am again not able to reproduce the >200 s compilation time today. That is surprising, given that I was able to get this slow compilation time on Friday on the same setup. Not sure what could have changed in-between. What I am able to observe today though is an apparent performance degradation between f2829c3 and ab48a55, for the snippet from this issue:
|
By the way, here is the correct version ( import scala.compiletime.ops.int.*
object TupleOps:
import Tuple.*
type Reduce[T <: NonEmptyTuple, F[_, _]] =
Fold[Tuple.Tail[T], Tuple.Head[T], F]
infix type Maximum[T <: NonEmptyTuple] = Reduce[
T,
[A, B] =>> (A, B) match
case (Int, Int) => Max[A, B]
]
type IndexOfRec[T <: Tuple, Elem, I <: Int] = Tuple.Elem[T, I] match
case Elem => I
case _ => IndexOfRec[T, Elem, I + 1]
infix type IndexOf[T <: Tuple, Elem] = IndexOfRec[T, Elem, 0]
type DropLargest[T <: NonEmptyTuple] =
T IndexOf Maximum[T] match
case Int =>
Concat[Take[T, (T IndexOf Maximum[T])], Drop[T, (T IndexOf Maximum[T]) + 1]]
type BubbleSort[T <: Tuple] = T match
case EmptyTuple => EmptyTuple
case NonEmptyTuple =>
Concat[BubbleSort[DropLargest[T]], (Maximum[T] *: EmptyTuple)]
@main def main =
println(compiletime.constValueTuple[(TupleOps.BubbleSort[(2, 3, 5, 4, 1)])])
// (1,2,3,4,5) I will add it as a benchmark. |
It seems I only get the > 200 s compilation time when compiling the incorrect version via Bloop.
|
Ah, might be related to #21521 |
TODO (by me):
|
Related to #21521, which also had some issues which only appeared with bloop. |
I think the issue with Bloop is that it runs the compilation in the Bloop process so setting a lower -Xss doesn't change anything. Looks like a limitation of how Bloop works, we would need to restart Bloop every time otherwise. |
Compiler version
3.2.1
Minimized code
Output
Compiles forever. I'm able to get it to terminate with a recursion overflow if I specify really low stack, e.g.
-Xss256K
:Expectation
Successfully compiles or fails compilation in a couple seconds at most
The text was updated successfully, but these errors were encountered: