Skip to content

Commit

Permalink
Remove local optimizations 🔥
Browse files Browse the repository at this point in the history
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
  • Loading branch information
OlivierBlanvillain committed Jul 17, 2018
1 parent 37a5443 commit 22d9046
Show file tree
Hide file tree
Showing 27 changed files with 5 additions and 2,089 deletions.
7 changes: 0 additions & 7 deletions .drone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,6 @@ pipeline:
- cp -R . /tmp/2/ && cd /tmp/2/
- ./project/scripts/sbt ";dotty-bootstrapped/compile ;dotty-bootstrapped/test"

test_optimised:
group: test
image: lampepfl/dotty:2018-06-29
commands:
- cp -R . /tmp/3/ && cd /tmp/3/
- ./project/scripts/sbt dotty-optimised/test

test_sbt:
group: test
image: lampepfl/dotty:2018-06-29
Expand Down
6 changes: 0 additions & 6 deletions build.sbt
Original file line number Diff line number Diff line change
@@ -1,29 +1,23 @@
val dotty = Build.dotty
val `dotty-bootstrapped` = Build.`dotty-bootstrapped`
val `dotty-optimised` = Build.`dotty-optimised`
val `dotty-interfaces` = Build.`dotty-interfaces`
val `dotty-doc` = Build.`dotty-doc`
val `dotty-doc-bootstrapped` = Build.`dotty-doc-bootstrapped`
val `dotty-doc-optimised` = Build.`dotty-doc-optimised`
val `dotty-compiler` = Build.`dotty-compiler`
val `dotty-compiler-bootstrapped` = Build.`dotty-compiler-bootstrapped`
val `dotty-compiler-optimised` = Build.`dotty-compiler-optimised`
val `dotty-library` = Build.`dotty-library`
val `dotty-library-bootstrapped` = Build.`dotty-library-bootstrapped`
val `dotty-library-optimised` = Build.`dotty-library-optimised`
val `dotty-sbt-bridge` = Build.`dotty-sbt-bridge`
val `dotty-sbt-bridge-bootstrapped` = Build.`dotty-sbt-bridge-bootstrapped`
val `dotty-language-server` = Build.`dotty-language-server`
val `dotty-bench` = Build.`dotty-bench`
val `dotty-bench-bootstrapped` = Build.`dotty-bench-bootstrapped`
val `dotty-bench-optimised` = Build.`dotty-bench-optimised`
val `scala-library` = Build.`scala-library`
val `scala-compiler` = Build.`scala-compiler`
val `scala-reflect` = Build.`scala-reflect`
val scalap = Build.scalap
val dist = Build.dist
val `dist-bootstrapped` = Build.`dist-bootstrapped`
val `dist-optimised` = Build.`dist-optimised`

val `sbt-dotty` = Build.`sbt-dotty`
val `vscode-dotty` = Build.`vscode-dotty`
Expand Down
6 changes: 2 additions & 4 deletions compiler/src/dotty/tools/dotc/Compiler.scala
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import util.FreshNameCreator
import core.DenotTransformers.DenotTransformer
import core.Denotations.SingleDenotation
import dotty.tools.backend.jvm.{CollectSuperCalls, GenBCode, LabelDefs}
import dotty.tools.dotc.transform.localopt.{Simplify, StringInterpolatorOpt}
import dotty.tools.dotc.transform.localopt.StringInterpolatorOpt

/** The central class of the dotc compiler. The job of a compiler is to create
* runs, which process given `phases` in a given `rootContext`.
Expand Down Expand Up @@ -92,7 +92,6 @@ class Compiler {
new ElimOuterSelect, // Expand outer selections
new AugmentScala2Traits, // Expand traits defined in Scala 2.x to simulate old-style rewritings
new ResolveSuper, // Implement super accessors and add forwarders to trait methods
new Simplify, // Perform local optimizations, simplified versions of what linker does.
new PrimitiveForwarders, // Add forwarders to trait methods that have a mismatch between generic and primitives
new FunctionXXLForwarders, // Add forwarders for FunctionXXL apply method
new ArrayConstructors) :: // Intercept creation of (non-generic) arrays and intrinsify.
Expand All @@ -107,8 +106,7 @@ class Compiler {
List(new Constructors, // Collect initialization code in primary constructors
// Note: constructors changes decls in transformTemplate, no InfoTransformers should be added after it
new FunctionalInterfaces, // Rewrites closures to implement @specialized types of Functions.
new GetClass, // Rewrites getClass calls on primitive types.
new Simplify) :: // Perform local optimizations, simplified versions of what linker does.
new GetClass) :: // Rewrites getClass calls on primitive types.
List(new LinkScala2Impls, // Redirect calls to trait methods defined by Scala 2.x, so that they now go to their implementations
new LambdaLift, // Lifts out nested functions to class scope, storing free variables in environments
// Note: in this mini-phase block scopes are incorrect. No phases that rely on scopes should be here
Expand Down
3 changes: 0 additions & 3 deletions compiler/src/dotty/tools/dotc/config/ScalaSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -143,10 +143,7 @@ class ScalaSettings extends Settings.SettingGroup {
val YshowNoInline = BooleanSetting("-Yshow-no-inline", "Show inlined code without the 'inlined from' info")

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

/** Dottydoc specific settings */
Expand Down
10 changes: 2 additions & 8 deletions compiler/src/dotty/tools/dotc/quoted/ToolboxSettings.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,16 @@ object ToolboxSettings {
implicit def default: ToolboxSettings = make()

/** Make toolbox settings
* @param optimise Enable optimisation when compiling the quoted code
* @param outDir Output directory for the compiled quote. If set to None the output will be in memory
* @param color Print output with colors
* @param rawTree Do not remove quote tree artifacts
* @param compilerArgs Compiler arguments. Use only if you know what you are doing.
*/
def make(
optimise: Boolean = false,
color: Boolean = false,
rawTree: Boolean = false,
outDir: Option[String] = None,
compilerArgs: List[String] = Nil
): ToolboxSettings = {
var compilerArgs1 = compilerArgs
if (optimise) compilerArgs1 = "-optimise" :: compilerArgs1
new ToolboxSettings(outDir, rawTree, compilerArgs1)
}

): ToolboxSettings =
new ToolboxSettings(outDir, rawTree, compilerArgs)
}

This file was deleted.

198 changes: 0 additions & 198 deletions compiler/src/dotty/tools/dotc/transform/localopt/ConstantFold.scala

This file was deleted.

Loading

0 comments on commit 22d9046

Please sign in to comment.