10000 Short circuit type comparisons of type refs when eta-expansion is futile by retronym · Pull Request #5885 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

Short circuit type comparisons of type refs when eta-expansion is futile #5885

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

Merged
merged 1 commit into from
May 4, 2017

Conversation

retronym
Copy link
Member
@retronym retronym commented May 4, 2017

If the initial comparison of a pair of higher kinded type refs yield false,
there is no point eta expanding them both to poly types to repeat the
comparison (in an more expensive fashion!)

If the initial comparison of a pair of higher kinded type refs yield false,
there is no point eta expanding them both to poly types to repeat the
comparison (in an more expensive fashion!)
@retronym
Copy link
Member Author
retronym commented May 4, 2017

Previous discussion in the context of #5823, from which I've split this PR:

#5823 (comment)

@retronym
Copy link
Member Author
retronym commented May 4, 2017

Before:

% for sha in 2.12.3-bin-70fbf98-SNAPSHOT 2.12.3-bin-989b22c-SNAPSHOT;  do sbt "set scalaVersion in compilation := \"$sha\"" "hot -psource= -f3 -wi 10 -jvmArgs -Xmx1G"; sleep 10; done

[info] Benchmark                                   (extraArgs)  (source)    Mode  Cnt     Score   Error  Units
[info] HotScalacBenchmark.compile                                         sample  248  1259.374 ± 8.655  ms/op
[info] HotScalacBenchmark.compile:compile·p0.00                           sample       1226.834          ms/op
[info] HotScalacBenchmark.compile:compile·p0.50                           sample       1247.805          ms/op
[info] HotScalacBenchmark.compile:compile·p0.90                           sample       1286.393          ms/op
[info] HotScalacBenchmark.compile:compile·p0.95                           sample       1371.537          ms/op
[info] HotScalacBenchmark.compile:compile·p0.99                           sample       1425.287          ms/op
[info] HotScalacBenchmark.compile:compile·p0.999                          sample       1438.646          ms/op
[info] HotScalacBenchmark.compile:compile·p0.9999                         sample       1438.646          ms/op
[info] HotScalacBenchmark.compile:compile·p1.00                           sample       1438.646          ms/op

After:

[info] # Run complete. Total time: 00:10:50
[info]
[info] Benchmark                                   (extraArgs)  (source)    Mode  Cnt     Score   Error  Units
[info] HotScalacBenchmark.compile                                         sample  265  1235.682 ± 6.967  ms/op
[info] HotScalacBenchmark.compile:compile·p0.00                           sample       1203.765          ms/op
[info] HotScalacBenchmark.compile:compile·p0.50                           sample       1226.834          ms/op
[info] HotScalacBenchmark.compile:compile·p0.90                           sample       1265.422          ms/op
[info] HotScalacBenchmark.compile:compile·p0.95                           sample       1323.932          ms/op
[info] HotScalacBenchmark.compile:compile·p0.99                           sample       1366.672          ms/op
[info] HotScalacBenchmark.compile:compile·p0.999                          sample       1405.092          ms/op
[info] HotScalacBenchmark.compile:compile·p0.9999                         sample       1405.092          ms/op
[info] HotScalacBenchmark.compile:compile·p1.00                           sample       1405.092          ms/op

Copy link
Contributor
@adriaanm adriaanm left a comment

Choose a reason for hiding this comment

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

Nice! I like that the optimization is shared between sameType & subType.

@retronym retronym merged commit ce0e5b2 into scala:2.12.x May 4, 2017
@adriaanm adriaanm added the performance the need for speed. usually compiler performance, sometimes runtime performance. label May 25, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance the need for speed. usually compiler performance, sometimes runtime performance.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0