-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Compilation time regression when using subtyping of union type in enum type parameter #22675
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
The current nightly version (3.7.0-RC1-bin-20250226-399d008-NIGHTLY) does not have the performance issue. Happened between:
|
@dwijnand @kasiaMarek @rochala would you be able to take a look at the backport PR? It seems some modifications had to be made when porting the original PR, maybe we can pinpoint what is causing the performance regression in LTS. |
I don't have much of an insight here, I can't say I understood the changes that @dwijnand made in type inference to make the Metals feature work. But if he's too busy I can try to dig into this. |
It seems that using ![]() On |
Right... and the backport of #21583 to LTS was rejected. |
I think we should be able to backport if we remove the cc stuff from the PR? |
Thanks @kasiaMarek for finding this one, I will backport this as soon as the current batch is done. |
Will test it in scala#142 |
You can test it under |
Interestingly this is faster than 3.7.0-RC1, so there might be room for improvement in the Next too. |
Tested on both this minimized code sample, and the real-life scenario that was impacted by this issue. It works way much faster than |
Compiler version
3.3.5 | 3.3.6
Minimized code
Output
Expectation
After updating from
3.3.4
to3.3.5
we've noticed a huge increase in compilation times for one scenario similar to the one I'm showing above. Since it looks like it is also happening in3.3.6
, and the profile tracer is being ported back, I've used that version (3.3.6-RC1-bin-20250219-7fb2a9d-NIGHTLY
) to generate a trace file (pasted below as an image as well) for the minimized code.My guess is the
posttyper
phase of the compiler is taking way more time than it used to. I say guess because for3.3.4
I don't have any profile traces, but compilation time is under 1s for this exact same code.Also, after running a few experiments: the more cases we add to
EnumWithUnionSubtyping
, the longer it takes to compile, provided theCUnion
contains enough members (e.g. using 10 member types compilation time is more reasonable). If we swap theenum
for asealed trait
, the same happens.In our real-life scenario we have 30+ members, and four cases inside the
enum
, of course a bit more complex than the scenario above.It doesn't seem to be impacting
3.6.3
fwiw.tracefile.json
The text was updated successfully, but these errors were encountered: