Skip to content
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

Extremely long compilation time for Circe module #47

Closed
chuwy opened this issue Feb 6, 2016 · 6 comments
Closed

Extremely long compilation time for Circe module #47

chuwy opened this issue Feb 6, 2016 · 6 comments

Comments

@chuwy
Copy link
Contributor

chuwy commented Feb 6, 2016

Does any one else experiences an issue with extremely long compilation time?
I created small project with akka-http-json (particularly Circe) to show up a problem: https://github.com/chuwy/compile-problem/blob/master/src/main/scala/me.chuwy/example/Routes.scala#L10

If I remove CirceSupport from code, it compiles in a few seconds, but with import CirceSupport._ or extends CirceSupport it takes ~100s on this simple code chunk and >5min on more complicated. And all this even without actual decoding/encoding.

@hseeberger
Copy link
Owner

I noticed long compilation, too. Probably fue to format derivation. Maybe @travisbrown has some insights.

@chuwy
Copy link
Contributor Author

chuwy commented Feb 6, 2016

Yes, I can confirm it happens only for circe. I tried json4s and there's no this problem. I also tried it with circe 0.3.0-SNAPSHOT and problem seems still there.

@chuwy chuwy changed the title Extremely long compilation time Extremely long compilation time for Circe module Feb 6, 2016
@travisbrown
Copy link

The Shapeless-powered fully-automatic generic derivation in circe can be very slow in some situations (see the last two items in this list for some discussion).

There's work happening in Shapeless 2.3.0 that aims to improve this, and some changes I'm working on independently in circe also seem to make the situation incrementally better.

For now unfortunately the best solution is to fall back to semi-automatically derived instances, which means two lines of boilerplate for every type you need to serialized / deserialize:

import io.circe.{ Decoder, Encoder }, io.circe.generic.semiauto.deriveFor

implicit val myTypeEncoder: Encoder[MyType] = deriveFor[MyType].encoder
implicit val myTypeDecoder: Decoder[MyType] = deriveFor[MyType].decoder

Note that the runtime performance of derived instances (using both auto and semiauto) should be practically indistinguishable from manually-defined instances (there are benchmarks in circe to track this).

@nettok
Copy link

nettok commented Apr 3, 2016

When I upgraded to circe 0.4.0-RC1 the compilation time (for a very simple thing) went down from 1 minute 25 seconds to just 3 seconds. 👍

@hseeberger
Copy link
Owner

Nice. Hoping for a Circe 0.4 release anytime soon.

@hseeberger
Copy link
Owner

I think this can be closed, because compilation time with Circe 0.4 is much better than before.

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

No branches or pull requests

4 participants