Skip to content

Try some optimizations #4448

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

Closed
wants to merge 18 commits into from
Closed

Try some optimizations #4448

wants to merge 18 commits into from

Conversation

odersky
Copy link
Contributor

@odersky odersky commented May 3, 2018

This branch tries out some low-level optimizations. It also contains Fix: commits which are fixes of problems discovered.

@odersky
Copy link
Contributor Author

odersky commented May 3, 2018

test performance please

@dottybot
Copy link
Member

dottybot commented May 3, 2018

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

@dottybot
Copy link
Member

dottybot commented May 3, 2018

Performance test finished successfully:

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

Benchmarks is based on merging with master (d0f7846)

@odersky
Copy link
Contributor Author

odersky commented May 3, 2018

test performance please: a1ce848

@dottybot
Copy link
Member

dottybot commented May 3, 2018

performance test scheduled for a1ce848: 1 job(s) in queue, 0 running.

@liufengyun
Copy link
Contributor

@odersky it's possible to give multiple commits separated by space.

@dottybot
Copy link
Member

dottybot commented May 3, 2018

Performance test finished successfully:

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

Benchmarks is based on merging with master (48a2f4b)

def head: T = apply(0)
def last: T = apply(length - 1)

def headOr[U >: T](alt: => U): U = if (length == 0) alt else head
Copy link
Contributor

Choose a reason for hiding this comment

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

if (isEmpty) alt else head

@odersky
Copy link
Contributor Author

odersky commented May 3, 2018

test performance please

@dottybot
Copy link
Member

dottybot commented May 3, 2018

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

@dottybot
Copy link
Member

dottybot commented May 3, 2018

Performance test finished successfully:

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

Benchmarks is based on merging with master (48a2f4b)

odersky added 5 commits May 4, 2018 19:15
In readLater the context is not preserved, but reconstituted using the
owner of the context building the closure. We need to pass the mode as
well, or else ReadPositions might be reset. I noticed this when I saw
that positions were not read correctly when inlining.
…nitions

This was done by accident before, because we did not keep the mode bits
of the context calling a readLater.
When printing trees, modifiers were always taken from the tree. This is wrong
for typed trees, since their flags and annotations come from the symbol, the
tree modifiers are no longer relevant.
Was forgotten before, which meant that labels were forgotten in inlined
code. The code was still correct, but a method would be created for each label.
@odersky
Copy link
Contributor Author

odersky commented May 4, 2018

Rebased sur #4464.

odersky added 6 commits May 5, 2018 16:32
The idea is to have a compiler-specific list data type that
optimizes for small lists. Where the overhead of normal lists
is one Cons node per element, the overhead of `Lst` is
0 for lists of length <= 1, and 1 array node for longer lists.
Furthermore, we'll try to inline heavily, which is easier for
specialized data structures.

The main downsides are inefficient `tail` and `::`, in particular
for longer lists. Compiler code will need to be adapted to avoid these where
it is performance critical.

This also serves as test case for the inline related fixes in the
previous commits.
Direct encoding of lazy val

I also tried to mase typeParams tail recursive by addling a local `recur`
method. But it turns out the previous typeParams is already fully optimized, no need
to add a local function.
@odersky
Copy link
Contributor Author

odersky commented May 6, 2018

test performance please

@dottybot
Copy link
Member

dottybot commented May 6, 2018

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

@dottybot
Copy link
Member

dottybot commented May 6, 2018

Performance test finished successfully:

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

Benchmarks is based on merging with master (6f6816d)

@odersky
Copy link
Contributor Author

odersky commented May 7, 2018

test performance please

@dottybot
Copy link
Member

dottybot commented May 7, 2018

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

@dottybot
Copy link
Member

dottybot commented May 7, 2018

Performance test finished successfully:

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

Benchmarks is based on merging with master (ddf10a2)

Mostly in TypeErasure and MixinOps, plus derived code.
Also: remove stray println.
@odersky
Copy link
Contributor Author

odersky commented May 7, 2018

test performance please

@dottybot
Copy link
Member

dottybot commented May 7, 2018

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

@dottybot
Copy link
Member

dottybot commented May 8, 2018

Performance test finished successfully:

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

Benchmarks is based on merging with master (80764e0)

@odersky
Copy link
Contributor Author

odersky commented May 9, 2018

The fixes in this PR have been integrated in master. As far as optimizations go, the small ones did not help and for Lst we need a fresh start because it gets too messy to mix Lst and List. The idea is to globally replace List by Lst in all the compiler, including the backend, either by changing the implementation of List in the standard library or by installing Lst, Lst.Empty and Lst.:: as aliases for the List operations in a global package object.

The updated Lst is part of #4490

@odersky odersky closed this May 9, 2018
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