Skip to content

Optimizations: Make code inlining friendlier #3265

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 4 commits into from
Oct 11, 2017

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Oct 5, 2017

I noted that despite inlining and the printer scheme key operations had a lot of junk in them. This PR tries to address that, so that we remove unnecessary debug code from hot operations.

First, making completion printing a config option keeps the size of
key method SymDenotations#completeFrom small. (completeFrom showed up as taking alomst 1% in the no HT profile)

Second, we also make all tracing operations conditional on a Config option.

Third, we massage tracing operations themselves and tweak inlining so that no trace of the tracing operation remains in the generated code.

@odersky
Copy link
Contributor Author

odersky commented Oct 5, 2017

test performance please

@dottybot
Copy link
Member

dottybot commented Oct 5, 2017

performance test scheduled: 11 job(s) in queue, 1 running.

@odersky
Copy link
Contributor Author

odersky commented Oct 5, 2017

test performance please

@dottybot
Copy link
Member

dottybot commented Oct 5, 2017

performance test scheduled: 6 job(s) in queue, 1 running.

@dottybot
Copy link
Member

dottybot commented Oct 5, 2017

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/3265/ to see the changes.

Benchmarks is based on merging with master (af528a1)

@odersky odersky requested a review from smarter October 6, 2017 11:10
@odersky odersky changed the title Micro-optimization: Make completion printing a Config option Optimizations: Make code inlining friendlier Oct 6, 2017
@odersky
Copy link
Contributor Author

odersky commented Oct 6, 2017

test performance please

@dottybot
Copy link
Member

dottybot commented Oct 6, 2017

performance test scheduled: 21 job(s) in queue, 1 running.

@dottybot
Copy link
Member

dottybot commented Oct 6, 2017

Performance test finished successfully:

Visit http://dotty-bench.epfl.ch/3265/ to see the changes.

Benchmarks is based on merging with master (2ecd3d2)

odersky and others added 4 commits October 11, 2017 23:18
Making completion printing a config option keeps the size of
key method `SymDenotations#completeFrom` small.
This is useful for keeping code small.
 - Enable only if global config option is true (this avoids clutter in
   traced methods).
 - Move out of context into separate object `reporting.trace`.
 - Avoid default arguments, since these are loaded before inlining.

The net effect of these methods is no parts of tracing calls remain
in generated code if config.tracingEnabled is false.
In particular, this test the changes to constant folding done two
commits ago.
Copy link
Member

@smarter smarter left a comment

Choose a reason for hiding this comment

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

LGTM, I added some bytecode tests to check the constant folding actually works.

@smarter smarter merged commit f1940ee into scala:master Oct 11, 2017
case y :: Nil if y.tpe.widen.isRef(defn.BooleanClass) =>
op match {
case nme.ZAND => if (c) y else x
case nme.ZOR => if (c) x else y
Copy link
Member

Choose a reason for hiding this comment

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

Probably doesn't matter in this case, but I prefer to check the symbol's name (or identity), rather than the selected name, so as to avoid mis-classification in the presence of renaming imports.

@allanrenucci allanrenucci deleted the try-optimize-8 branch December 14, 2017 19:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants