Skip to content

Tweak performance of findRef #9870

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 2 commits into from
Sep 26, 2020
Merged

Conversation

liufengyun
Copy link
Contributor

Tweak performance of findRef

@liufengyun
Copy link
Contributor Author

test performance please

@dottybot
Copy link
Member

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

sym.is(ExtensionMethod) && (sym.extensionParam.span == xmethod.extensionParam.span)
if !xmethod.exists || result.tpe.isError || canAccessUnqualified(result.symbol) then
result
if xmethod.exists then
Copy link
Contributor

Choose a reason for hiding this comment

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

I would have thought that the code here would be executed only rarely.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For a simple program (see below), the speedup is about 24% (34ms/op VS 45ms/op):

class MyInt(val x: Int) {
  def eq(that: MyInt): Boolean = this.x == that.x
}

class Test {
  def foo(x: MyInt, y: MyInt): Boolean = x.eq(y)

  val a = MyInt(2)
  val b = MyInt(3)
  foo(a, b)
}

Copy link
Contributor

Choose a reason for hiding this comment

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

Interesting. I just found out why: The code in question (including the expensive tryEither) is executed twice, once for each MyInt(...). I had not thought of that. So, yes, because of constructor syntax, failures in findRef are now not that uncommon. So this is a definite improvement. Unfortunately, the benchmarks are too noisy to see this immediately.

@dottybot
Copy link
Member

Performance test finished successfully:

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

Benchmarks is based on merging with master (246fc89)

@liufengyun
Copy link
Contributor Author

retest performance please

@dottybot
Copy link
Member

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

@dottybot
Copy link
Member

Performance test finished successfully:

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

Benchmarks is based on merging with master (2ec7a6f)

@liufengyun
Copy link
Contributor Author

retest performance please

@liufengyun liufengyun marked this pull request as ready for review September 26, 2020 07:25
@dottybot
Copy link
Member

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

@dottybot
Copy link
Member

Performance test finished successfully:

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

Benchmarks is based on merging with master (f4528ce)

@odersky odersky merged commit d82b700 into scala:master Sep 26, 2020
@odersky odersky deleted the findref-tweak branch September 26, 2020 16:13
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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