Skip to content
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

Scala 3.5.0 runner takes 4X longer to start than scala-cli runner on Windows #21551

Closed
soronpo opened this issue Sep 6, 2024 · 1 comment
Closed
Labels
area:runner Issues tied to the scala runner command. itype:performance

Comments

@soronpo
Copy link
Contributor

soronpo commented Sep 6, 2024

Compiler version

v3.5.0

Minimized code

hello.sc

println("hello")

timeit.bat

@echo off
@setlocal

set start=%time%

:: Runs your command
cmd /c %*

set end=%time%
set options="tokens=1-4 delims=:.,"
for /f %options% %%a in ("%start%") do set start_h=%%a&set /a start_m=100%%b %% 100&set /a start_s=100%%c %% 100&set /a start_ms=100%%d %% 100
for /f %options% %%a in ("%end%") do set end_h=%%a&set /a end_m=100%%b %% 100&set /a end_s=100%%c %% 100&set /a end_ms=100%%d %% 100

set /a hours=%end_h%-%start_h%
set /a mins=%end_m%-%start_m%
set /a secs=%end_s%-%start_s%
set /a ms=%end_ms%-%start_ms%
if %ms% lss 0 set /a secs = %secs% - 1 & set /a ms = 100%ms%
if %secs% lss 0 set /a mins = %mins% - 1 & set /a secs = 60%secs%
if %mins% lss 0 set /a hours = %hours% - 1 & set /a mins = 60%mins%
if %hours% lss 0 set /a hours = 24%hours%
if 1%ms% lss 100 set ms=0%ms%

:: Mission accomplished
set /a totalsecs = %hours%*3600 + %mins%*60 + %secs%
echo command took %hours%:%mins%:%secs%.%ms% (%totalsecs%.%ms%s total)

Output

> timeit scala-cli run hello.sc
hello
command took 0:0:0.64 (0.64s total)

> timeit scala-cli run hello.sc
hello
command took 0:0:0.63 (0.63s total)

> timeit scala-cli run hello.sc
hello
command took 0:0:0.68 (0.68s total)

> timeit scala run hello.sc
hello
command took 0:0:4.57 (4.57s total)

> timeit scala run hello.sc
hello
command took 0:0:4.57 (4.57s total)

> timeit scala run hello.sc
hello
command took 0:0:4.47 (4.47s total)

Expectation

The performance should be roughly the same

@soronpo soronpo added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 6, 2024
@Gedochao Gedochao added area:runner Issues tied to the scala runner command. and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Sep 6, 2024
@Gedochao
Copy link
Contributor

Gedochao commented Sep 6, 2024

Hey, so this is a known issue, and has already been fixed.
The fix will be included in 3.5.1 (and is already available in 3.5.1-RC2).

For 3.5.0, on Windows (and only on Windows) the scala script is passing the --cli-version param to work around some other problems, as a result of which we are delegating the runner to a JVM launcher (launched by the windows native launcher).
This is bound to be slow.

We have done that initially to work around some other limitations (namely, support for JVM <17 and the requirement for a Scala CLI launcher to be >=30 days old to be sure it has already been verified by Microsoft), but we have abandoned this solution since then.

This behaviour was removed in #21234 and then backported to 3.5.1-RC2.
You can test this via the coursier installation:

cs install scala:3.5.1-RC2

Closing this issue.

@Gedochao Gedochao closed this as not planned Won't fix, can't repro, duplicate, stale Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:runner Issues tied to the scala runner command. itype:performance
Projects
None yet
Development

No branches or pull requests

2 participants