scala / pickling

Fast, customizable, boilerplate-free pickling support for Scala
lampwww.epfl.ch/~hmiller/pickling
BSD 3-Clause "New" or "Revised" License
831 stars 79 forks source link

Improve performance of implicit search #422

Open jvican opened 8 years ago

jvican commented 8 years ago

These are the times we are looking for an implicit of type T in the implicit search for our test suite (which, btw, is huge):

Type Times
Any 1420
String 1456
Int 1677
Ref 2338

These stats lay the ground for the upcoming improvement in the implicit search that hopefully will address the performance issues that we face right now, especially large compilation times. I think that there's room for improvement and I'm working tirelessly on it.

jvican commented 8 years ago

Current:

Type Times
Any 168
String 0
Int 0
Ref 0

I still have to figure out why Any is still being invoked through the macro generation. This hints that the compiler cannot find it in scope. This is probably caused by some test cases not importing AnyPicklerUnpickler from the whole Defaults (we have some tests that cherry-pick the imports) and therefore pickling has to create it from scratch.

My last changes (in my private repo) decrease the compilation time by a half (in my computer the speedup is ~3x). There are still some more improvements coming that will improve preferringAlternativeImplicits.

jvican commented 8 years ago

It also improves https://github.com/scala/pickling/issues/342. I don't own a MBP, but in my Thinkpad x201 which is about 5 years old, the example in the issue consumes ~2s to compile. I think I could cut it even more with the upcoming changes.

jvican commented 8 years ago

I'm going to put off the next improvements in the implicit search for the next PR, since it's not high priority.