-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Local optimisations round two #2647
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
|
||
/** Every pure statement preceding a ??? can be removed. | ||
* | ||
* This optimisation makes it rather tricky meaningful examples since the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sentence seems to be missing some words.
def visitor: Tree => Unit | ||
|
||
/** Does the actual Tree => Tree transformation, possibly using a different | ||
* context from the one using in Optimisation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you give more explanations on what contexts are used when? Also typo: using -> used.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got addressed in this PR, we always use the correct, most local context!
def localOptimizations(classNode: ClassNode): Unit = { | ||
// BackendStats.timed(BackendStats.methodOptTimer)(localOpt.methodOptimizations(classNode)) | ||
def localOptimisations(classNode: ClassNode): Unit = { | ||
// BackendStats.timed(BackendStats.methodOptTimer)(localOpt.methodOptimisations(classNode)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I propose not to rename the method here. This is how method is actually called in the backend.
@OlivierBlanvillain, If you don't mind, I propose to wait with getting this PR in. |
For curiosity I've just checked: Oxford English Dictionary, prefers the |
@DarkDimius How large is your diff? I would be surprise if git manages to rebase either diffs on top of the other, and if it doesn't, it's probably easier to hand apply your changes on top of this rather than the other way around... (Happy to help if you point me to a branch) I really don't have a preference between -ise and -ize, as long has it's not half/half 😄 |
6697282
to
9c152e8
Compare
@DarkDimius Found the issue with DropNoEffects, if you want to have a look a the last commits. It's currently not tested by the CI, but this is what I use locally: $ sbt ';project dotty-compiler-bootstrapped ;clean ;set scalacOptions ++= Seq("-optimise", "-Yopt-phases:DropNoEffects") ;test' |
@OlivierBlanvillain, nice find! Did tests pass on your machine after the change? |
The above, i.e. bootstrapped Dotty tests with |
@@ -447,6 +448,8 @@ class Definitions { | |||
def Long_* = Long_mulR.symbol | |||
lazy val Long_divR = LongClass.requiredMethodRef(nme.DIV, List(LongType)) | |||
def Long_/ = Long_divR.symbol | |||
val CommutativePrimitiveOperations = new PerRun[collection.Set[Symbol]](implicit ctx => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't put stuff inside Definitions, unless its frequently used by multiple phases.
Same applies for SeqFactoryType.
a.symbol.extendedOverriddenSymbols.isEmpty && | ||
(isPureExpr(a.fun) || a.fun.symbol.is(Synthetic)) => | ||
|
||
def reciever(t: Tree): Type = t match { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
typo: reciever -> receiver
Block(recv :: Nil, res) | ||
} | ||
|
||
// To run this optimisation after erasure one would need to specialize it |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this comment to the top of the class?
case Some(_) => | ||
a | ||
} | ||
case a: DefDef if (a.symbol.is(Label) && timesUsed.getOrElse(a.symbol, 0) == 1 && defined.contains(a.symbol)) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This same if expression is repeated below, factor it out in a def?
bb0f005
to
16671f2
Compare
16671f2
to
f6e4632
Compare
f6e4632
to
f8cf56f
Compare
@OlivierBlanvillain, i've pushed a merge of our changes. I've quite substantially changed the structure of the split, because the original split introduced 70% slowdown(even after removing fuel) |
What changes in the split cause a slowdown? |
50% that I've removed - substantially more allocations. More maps, sets & etc were allocated, unlike before. More lambdas were coined. More calls were non-local and cold. E.g. there were two contexts being used interchangeably. In general: abstractions in Scala are anything but free. What brings the remaining 20% slowdown - I haven't checked yet and I don't think I'll have opportunity to do it in coming months. |
@DarkDimius Interesting, what measure did you use? |
f8cf56f
to
195d5e6
Compare
@DarkDimius I just force pushed to restore history, I authored 4 commits under you name, you can check that nothing got lost using I isolated the CI failure, it looks like |
@DarkDimius I think you have mesured the wrong with this 20% slowdown. By not sharing instances Optimistion instead of allocating new ones you where also sharing the mutable.Hashmap instances. The failure on compileStdLib is actaully a proper timeout: keeping these Hashmaps around when compiling all of stdlib prevented GC from doing it job, and (I'm guessing) spent a lot of time reshufuling the Hashmap. I also removed your `private val useFuel = false` back to a simple runtime setting check. I moved the debuging code in a `printIfDifferent` which only adds 3 extra bytecode instructions to the body of the TreeMap.transform (going from 70 to 73).
Let's get this in. The followup discussions can be held separately, but this PR in any case is an improvement. |
LGTM. Glad to have it in. |
Follow up PR of #2513
Objective: bootstrap Dotty with
-optimise
!