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

Slow codec automatic derivation #2051

Open
andreisilviudragnea opened this issue Nov 2, 2022 · 0 comments
Open

Slow codec automatic derivation #2051

andreisilviudragnea opened this issue Nov 2, 2022 · 0 comments

Comments

@andreisilviudragnea
Copy link

andreisilviudragnea commented Nov 2, 2022

When comparing codec automatic derivation with semi-automatic derivation (explicit or using JsonCodec), automatic derivation is very slow.

In each file which contains import io.circe.generic.auto._, if there is an expression like Decoder.apply[SomeType] (or any circe call which needs an implicit Decoder[T] instance), an automatically derived decoder will be generated for each implicit call site (DerivedDecoder.deriveDecoder gets called for each Decoder.apply[SomeType] call).

I have reproduced the bug here:

  • CirceGenericAutoSpec.scala typer phase takes 6.9 seconds
  • CirceGenericJsonCodecSpec.scala typer phase takes 114 ms
  • CirceGenericSemiAutoSpec.scala typer phase takes 102 ms

The number of class files generated by CirceGenericAutoSpec.scala is huge compared to the other two examples.

Given how inefficient automatic derivation can be in these cases, I think this behaviour should be documented here.

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

1 participant