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

Fix #20521: Optimise caching for computing atoms and widened in OrTypes #21223

Merged
merged 1 commit into from
Jul 19, 2024

Conversation

noti0na1
Copy link
Member

@noti0na1 noti0na1 commented Jul 18, 2024

Fix #20521

When using the atoms of a large provisional union type, significant time is wasted computing the widened type and lub is invoked repeatedly. This PR addresses this issue by splitting the caching mechanisms for computing atoms and computing the widened type in OrType.

As a result of this optimization, the compilation time for tests/pos/i20521.scala has been reduced from approximately 40 seconds to 6 seconds, making it comparable to Scala 2's performance.

@noti0na1
Copy link
Member Author

test performance please

@dottybot
Copy link
Member

performance test scheduled: 1 job(s) in queue, 1 running.

@dottybot
Copy link
Member

Performance test finished successfully:

Visit https://dotty-bench.epfl.ch/21223/ to see the changes.

Benchmarks is based on merging with main (a046b00)

@noti0na1 noti0na1 changed the title Optimise caching for computing atoms and widened in OrTypes Fix #20521: Optimise caching for computing atoms and widened in OrTypes Jul 18, 2024
@noti0na1 noti0na1 marked this pull request as ready for review July 18, 2024 15:54
@noti0na1 noti0na1 requested review from dwijnand and odersky July 18, 2024 16:06
Copy link
Member

@dwijnand dwijnand left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense and seems like a safe change. Nicely found.

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks reasonable, and great that it helped performance!

@odersky odersky removed their assignment Jul 19, 2024
@noti0na1 noti0na1 merged commit 46867c0 into scala:main Jul 19, 2024
28 checks passed
@noti0na1 noti0na1 deleted the fix-20521 branch July 19, 2024 10:54
WojciechMazur added a commit that referenced this pull request Aug 27, 2024
…d in OrTypes" to 3.5.2 (#21453)

Backports #21223 to the 3.5.2 branch.

PR submitted by the release tooling.
[skip ci]
@WojciechMazur WojciechMazur added this to the 3.5.2 milestone Oct 8, 2024
WojciechMazur added a commit that referenced this pull request Dec 3, 2024
…d in OrTypes" to LTS (#22073)

Backports #21223 to the 3.3.5.

PR submitted by the release tooling.
[skip ci]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Slow inference with large Maps of literals
5 participants