Skip to content

Commit 131b8e9

Browse files
Remove local optimizations 🔥
Here are the results, each experiment consists of 40 forks of 10 warmups and 20 measurements each (that's what it takes to get ~30ms precision!): ConstantFold 12672.914 ± 29.044 ms/op InlineLocalObjects 12742.463 ± 29.693 ms/op DropNoEffects 12717.516 ± 28.266 ms/op DropGoodCasts 12753.709 ± 31.020 ms/op Jumpjump 12758.874 ± 28.979 ms/op Devalify 12820.393 ± 29.601 ms/op Valify 12732.851 ± 29.466 ms/op InlineOptions 12705.638 ± 29.186 ms/op RemoveUnnecessaryNullChecks 12740.366 ± 29.604 ms/op InlineCaseIntrinsics 12675.068 ± 29.075 ms/op Not Optimized 12731.068 ± 28.731 ms/op All Optimizations 12762.053 ± 28.751 ms/op Also here a count of how many time each optimization modifies a tree when bootstrapping (running all of them together): 20688 Devalify 7165 DropNoEffects 2787 InlineCaseIntrinsics 1340 ConstantFold 728 DropGoodCasts 76 InlineOptions 49 InlineLocalObjects 16 RemoveUnnecessaryNullChecks 3 Jumpjump Here are some additional numbers obtained using the Scala Native benchmarks: https://plot.ly/~olivierblanvillain/1/#plot
1 parent 37a5443 commit 131b8e9

29 files changed

+6
-2091
lines changed

.drone.yml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,6 @@ pipeline:
3636
- cp -R . /tmp/2/ && cd /tmp/2/
3737
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test"
3838

39-
test_optimised:
40-
group: test
41-
image: lampepfl/dotty:2018-06-29
42-
commands:
43-
- cp -R . /tmp/3/ && cd /tmp/3/
44-
- ./project/scripts/sbt dotty-optimised/test
45-
4639
test_sbt:
4740
group: test
4841
image: lampepfl/dotty:2018-06-29

build.sbt

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
val dotty = Build.dotty
22
val `dotty-bootstrapped` = Build.`dotty-bootstrapped`
3-
val `dotty-optimised` = Build.`dotty-optimised`
43
val `dotty-interfaces` = Build.`dotty-interfaces`
54
val `dotty-doc` = Build.`dotty-doc`
65
val `dotty-doc-bootstrapped` = Build.`dotty-doc-bootstrapped`
7-
val `dotty-doc-optimised` = Build.`dotty-doc-optimised`
86
val `dotty-compiler` = Build.`dotty-compiler`
97
val `dotty-compiler-bootstrapped` = Build.`dotty-compiler-bootstrapped`
10-
val `dotty-compiler-optimised` = Build.`dotty-compiler-optimised`
118
val `dotty-library` = Build.`dotty-library`
129
val `dotty-library-bootstrapped` = Build.`dotty-library-bootstrapped`
13-
val `dotty-library-optimised` = Build.`dotty-library-optimised`
1410
val `dotty-sbt-bridge` = Build.`dotty-sbt-bridge`
1511
val `dotty-sbt-bridge-bootstrapped` = Build.`dotty-sbt-bridge-bootstrapped`
1612
val `dotty-language-server` = Build.`dotty-language-server`
1713
val `dotty-bench` = Build.`dotty-bench`
1814
val `dotty-bench-bootstrapped` = Build.`dotty-bench-bootstrapped`
19-
val `dotty-bench-optimised` = Build.`dotty-bench-optimised`
2015
val `scala-library` = Build.`scala-library`
2116
val `scala-compiler` = Build.`scala-compiler`
2217
val `scala-reflect` = Build.`scala-reflect`
2318
val scalap = Build.scalap
2419
val dist = Build.dist
2520
val `dist-bootstrapped` = Build.`dist-bootstrapped`
26-
val `dist-optimised` = Build.`dist-optimised`
2721

2822
val `sbt-dotty` = Build.`sbt-dotty`
2923
val `vscode-dotty` = Build.`vscode-dotty`

compiler/src/dotty/tools/dotc/Compiler.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import util.FreshNameCreator
1515
import core.DenotTransformers.DenotTransformer
1616
import core.Denotations.SingleDenotation
1717
import dotty.tools.backend.jvm.{CollectSuperCalls, GenBCode, LabelDefs}
18-
import dotty.tools.dotc.transform.localopt.{Simplify, StringInterpolatorOpt}
18+
import dotty.tools.dotc.transform.localopt.StringInterpolatorOpt
1919

2020
/** The central class of the dotc compiler. The job of a compiler is to create
2121
* runs, which process given `phases` in a given `rootContext`.
@@ -92,7 +92,6 @@ class Compiler {
9292
new ElimOuterSelect, // Expand outer selections
9393
new AugmentScala2Traits, // Expand traits defined in Scala 2.x to simulate old-style rewritings
9494
new ResolveSuper, // Implement super accessors and add forwarders to trait methods
95-
new Simplify, // Perform local optimizations, simplified versions of what linker does.
9695
new PrimitiveForwarders, // Add forwarders to trait methods that have a mismatch between generic and primitives
9796
new FunctionXXLForwarders, // Add forwarders for FunctionXXL apply method
9897
new ArrayConstructors) :: // Intercept creation of (non-generic) arrays and intrinsify.
@@ -107,8 +106,7 @@ class Compiler {
107106
List(new Constructors, // Collect initialization code in primary constructors
108107
// Note: constructors changes decls in transformTemplate, no InfoTransformers should be added after it
109108
new FunctionalInterfaces, // Rewrites closures to implement @specialized types of Functions.
110-
new GetClass, // Rewrites getClass calls on primitive types.
111-
new Simplify) :: // Perform local optimizations, simplified versions of what linker does.
109+
new GetClass) :: // Rewrites getClass calls on primitive types.
112110
List(new LinkScala2Impls, // Redirect calls to trait methods defined by Scala 2.x, so that they now go to their implementations
113111
new LambdaLift, // Lifts out nested functions to class scope, storing free variables in environments
114112
// Note: in this mini-phase block scopes are incorrect. No phases that rely on scopes should be here

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,10 +143,7 @@ class ScalaSettings extends Settings.SettingGroup {
143143
val YshowNoInline = BooleanSetting("-Yshow-no-inline", "Show inlined code without the 'inlined from' info")
144144

145145
/** Linker specific flags */
146-
val optimise = BooleanSetting("-optimise", "Generates faster bytecode by applying local optimisations to the .program") withAbbreviation "-optimize"
147146
val Xlink = BooleanSetting("-Xlink", "Recompile library code with the application.")
148-
val YoptPhases = PhasesSetting("-Yopt-phases", "Restrict the optimisation phases to execute under -optimise.")
149-
val YoptFuel = IntSetting("-Yopt-fuel", "Maximum number of optimisations performed under -optimise.", -1)
150147
val YnoDecodeStacktraces = BooleanSetting("-Yno-decode-stacktraces", "Show raw StackOverflow stacktraces, instead of decoding them into triggering operations.")
151148

152149
/** Dottydoc specific settings */

compiler/src/dotty/tools/dotc/quoted/ToolboxSettings.scala

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,22 +7,16 @@ object ToolboxSettings {
77
implicit def default: ToolboxSettings = make()
88

99
/** Make toolbox settings
10-
* @param optimise Enable optimisation when compiling the quoted code
1110
* @param outDir Output directory for the compiled quote. If set to None the output will be in memory
1211
* @param color Print output with colors
1312
* @param rawTree Do not remove quote tree artifacts
1413
* @param compilerArgs Compiler arguments. Use only if you know what you are doing.
1514
*/
1615
def make(
17-
optimise: Boolean = false,
1816
color: Boolean = false,
1917
rawTree: Boolean = false,
2018
outDir: Option[String] = None,
2119
compilerArgs: List[String] = Nil
22-
): ToolboxSettings = {
23-
var compilerArgs1 = compilerArgs
24-
if (optimise) compilerArgs1 = "-optimise" :: compilerArgs1
25-
new ToolboxSettings(outDir, rawTree, compilerArgs1)
26-
}
27-
20+
): ToolboxSettings =
21+
new ToolboxSettings(outDir, rawTree, compilerArgs)
2822
}

compiler/src/dotty/tools/dotc/transform/localopt/BubbleUpNothing.scala

Lines changed: 0 additions & 67 deletions
This file was deleted.

compiler/src/dotty/tools/dotc/transform/localopt/ConstantFold.scala

Lines changed: 0 additions & 198 deletions
This file was deleted.

0 commit comments

Comments
 (0)