-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Revive function specialization #9846
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
Conversation
9384cfb
to
b30b157
Compare
compiler/src/dotty/tools/dotc/transform/SpecializeFunctions.scala
Outdated
Show resolved
Hide resolved
a73d29a
to
674d375
Compare
Could we entirely disable the two phases when compiling for Scala.js? Like this: |
It's done in a943064 |
04cfd2c
to
30087ee
Compare
Regarding the performance regression in the scalap project: the project has ~2KLOC, it defines 118 classes/traits, of which 68 are case classes. To include the auto-generated companion objects, there will be All the 68 companion objects of the case classes extend |
I'm still surprised this makes such a significant difference, especially since specialization should only be applicable for some of these case classes, do you know which part of the code is responsible for the slow-down, or is it spread across everything? |
My conjecture is |
compiler/src/dotty/tools/dotc/transform/SpecializeFunctions.scala
Outdated
Show resolved
Hide resolved
compiler/src/dotty/tools/dotc/transform/SpecializeFunctions.scala
Outdated
Show resolved
Hide resolved
compiler/src/dotty/tools/dotc/transform/SpecializeFunctions.scala
Outdated
Show resolved
Hide resolved
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/9846-8/ to see the changes. Benchmarks is based on merging with master (819e0b1) |
f647585
to
6a48696
Compare
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/9846-8/ to see the changes. Benchmarks is based on merging with master (4c055c4) |
- Fix isPlainFunctionClass Previous implementation is incorrect, as scala.Function1$ would qualify. - Create the symbol at the next phase Create the symbol at the next phase, so that it is a valid member of the corresponding function for all valid periods of its SymDenotations. Otherwise, the valid period will offset by 1, which causes a stale symbol in compiling stdlib. - Handle abstract apply and multiple applys - Don't specialize abstract apply - Fast specialization We avoid going through InfoTransformer, which will cause all symbols to be checked. The reason why it works is that the specialized base classes, i.e. Function0-2 already have all the relevant definitions.
- Fix typo - Use StringBuilder instead of StringBuffer (thanks @smarter) StringBuffer is synchronized thus is slower.
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/9846-10/ to see the changes. Benchmarks is based on merging with master (c3ac180) |
From the latest benchmark result http://dotty-bench.epfl.ch/9846-10 , the regression in scalap is caused by the code in d3fc1d6 (which agrees with the local benchmarking result). After fixing one typo in a8127bb, which creates 54 fewer methods, the compiler becomes faster ( |
test performance please |
performance test scheduled: 1 job(s) in queue, 0 running. |
Performance test finished successfully: Visit http://dotty-bench.epfl.ch/9846-10/ to see the changes. Benchmarks is based on merging with master (462a72f) |
Superseded by #10452 |
Revive function specialization
Based on #3306