Skip to content

Reported serious regression with for-Range handling #4137

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

Closed
LeeTibbert opened this issue Jan 1, 2025 · 1 comment · Fixed by #4139
Closed

Reported serious regression with for-Range handling #4137

LeeTibbert opened this issue Jan 1, 2025 · 1 comment · Fixed by #4139
Labels

Comments

@LeeTibbert
Copy link
Contributor

As reported by lolgab in issue #4132

Scala Native 0.4.0-M2 on Scala 2.11 was able to optimize Range loops as while loops.
During the years something got lost.
If you try the example on that version it takes the same time as its equivalent while loop.

EDIT:
The example optimizes correctly on current Scala Native with Scala 2.12 and Scala 2.13.
So this issue happens only on Scala 3.

(lolgab, thanks for discovering this. I hope I do not offend you by making the issue more visible.)

Oops!

This is a pretty serious regression.

I know that I have written all sorts of code all over Scala Native
using for-range loops (not range.foreach) with the believe that this optimization was occurring.
Probably even in the PRs I submitted and/or prepared over the recent holidays.

Probably high double digits of instances or more.
javalib and posixlib are probably strongly affected by this regression.

@lolgab
Copy link
Contributor

lolgab commented Jan 2, 2025

The root cause is a bug in Scala 3 that doesn't use the specialized variant of foreach in Range: scala/scala3#19759
The optimization in #4139 does optimize it regardless of the missing specialization.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants