Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

Improve implicit search drastically #424

Merged
merged 9 commits into from
Jun 1, 2016

Conversation

jvican
Copy link
Member

@jvican jvican commented May 13, 2016

Disable logging of pickler generation

  • Keep around the infrastructure used for debugging the implicit search
    because we'll come back to improve it further soon.

Add big improvement in the implicit search

  • Change all the implicit definitions to return
    AbstractPicklerUnpickler instead of Pickler[T] with Unpickler[T].
    The former one has more precedence than the latter one. This avoids to
    call the generator macro EVERY TIME we ask for an implicit
    pickler/unpickler.
  • Make sure that the LowPriorityImplicits are placed in the right
    location of the Defaults trait.
  • This addresses a big deal of Improve performance of implicit search #422 although more changes will come,
    especially affecting preferringAlternativeImplicits.
  • Do some minor cleanup and formatting changes (trying out scalafmt) in
    the project.
  • Remove explicit registerings of picklers that were not necessary
    because of AutoRegister.
  • Register myself to the TODOs that are concerned with the creation of
    runtime picklers/unpicklers. @jsuereth, I've stolen you some TODOs ;)

Add benchmark utility that helps address #422

  • Add just a memo that will tell us how many times we are looking for the
    pickler/unpickler of a type T.

Remove cumbersome PicklingMacros definition

  • We don't need PicklingMacros when we can use the more explicit
    Pickler.generate and family.
  • Rename Macros to PicklingMacros.

Move preferringAlternativeImplicits to Macros

  • Reuse AlgorithmLogger to report errors
  • Do some basic cleanup and lay the ground for future work on improving the
    preferringAlternativeImplicits.

First step towards better implicit search

  • Improve debugging of the algorithm and put some comments.
  • Gather GenPicklers and GenUnpicklers in the same file, remove
    unused trait. Update AllPicklerUnpicklers accordingly.

@jvican
Copy link
Member Author

jvican commented May 13, 2016

I'm still polishing a little bit this PR and make it pass!

@jsuereth
Copy link
Contributor

FYI you should merge with your test fixes. That was passing os I merged. Looks like I have a bunch of merge conflicts to resovle in my branch too :)

@jvican jvican force-pushed the improve-implicit-search branch 2 times, most recently from cb9480b to 804178e Compare May 23, 2016 17:04
* Improve debugging of the algorithm and put some comments.

* Gather `GenPicklers` and `GenUnpicklers` in the same file, remove
  unused trait. Update `AllPicklerUnpicklers` accordingly.
* Reuse `AlgorithmLogger` to report errors

* Do some basic cleanup and lay the ground for future work on improving
the `preferringAlternativeImplicits`.
* We don't need `PicklingMacros` when we can use the more explicit
`Pickler.generate` and family.

* Rename `Macros` to `PicklingMacros`.
* Add just a memo that will tell us how many times we are looking for
the pickler/unpickler of a type `T`.
* Change all the implicit definitions to return
  `AbstractPicklerUnpickler` instead of `Pickler[T] with Unpickler[T]`.
  The former one has more precedence than the latter one. This avoids to
  call the generator macro EVERY TIME we ask for an implicit
  pickler/unpickler.

* Make sure that the `LowPriorityImplicits` are placed in the right
  location of the `Defaults` trait.

* This addresses a big deal of scala#422 although more changes will come,
  especially affecting `preferringAlternativeImplicits`.

* Do some minor cleanup and formatting changes (trying out scalafmt) in
  the project.

* Remove explicit registerings of picklers that were not necessary
  because of `AutoRegister`.

* Register myself to the TODOs that are concerned with the creation of
  runtime picklers/unpicklers. @jsuereth, I've stolen you some TODOs ;)
* Keep around the infrastructure used for debugging the implicit search
  because we'll come back to improve it further soon.
* Import `HasCompat` to expose the 2.10 macros stub and move around the
  implicit class hack to make `pt` compile. This is quite flaky, we
  should use something like `macro-compat`.

* Change type signature of picklers/unpicklers in wikigraph to avoid
  clash.
@jvican
Copy link
Member Author

jvican commented May 24, 2016

This is ready for review 👍 I've fixed the compatibility issues with 2.10.

@jvican
Copy link
Member Author

jvican commented May 24, 2016

This is also ready for merge @jsuereth

@@ -353,45 +354,6 @@ abstract class Macro extends RichTypes { self =>
def syntheticPicklerUnpicklerQualifiedName(tpe: Type): TypeName = syntheticBaseQualifiedName(tpe) + syntheticPicklerUnpicklerSuffix()
def syntheticPicklerUnpicklerSuffix(): String = "PicklerUnpickler"

def preferringAlternativeImplicits(body: => Tree): Tree = {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice!

@jvican jvican closed this May 25, 2016
@jvican jvican reopened this May 25, 2016
@jvican
Copy link
Member Author

jvican commented May 25, 2016

Closed and reopened to force Travis to execute the tests.

@jvican jvican merged commit 4f5dd03 into scala:0.11.x Jun 1, 2016
@jvican jvican removed the in progress label Jun 1, 2016
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants