Open
Description
Compiler version
I've compared a simple peace of code performance running with Scala 2 and Scala 3 and faced with performance regression. In this case Scala 2 generated program is more than 7 times faster on my computer.
The code is just calculate sum of big Array[Long] several times.
Minimized code
(0 until M).foreach { _ =>
var i = 0
while (i < N) {
sum += arr(i)
i += 1
}
}
The whole project code is available here: https://github.com/limansky/perf-issue
Output
sbt:perf> +run
[info] Setting Scala version to 2.13.12 on 1 projects.
[info] Reapplying settings...
[info] set current project to perf (in build file:/home/limansky/projects/langperf/scala/)
[info] running Main
time 4268 ms
10000000000
[success] Total time: 5 s, completed Feb 22, 2024, 3:10:32 PM
[info] Setting Scala version to 3.3.1 on 1 projects.
[info] Reapplying settings...
[info] set current project to perf (in build file:/home/limansky/projects/langperf/scala/)
[info] running Main
time 31699 ms
10000000000
Expectation
I suppose Scala 3 should be at least as fast as Scala 2.