v0.14.2 introduced significant performance degradation
See original GitHub issueWe use Circe in several Scala cron jobs. Last week or so, we upgraded Circe from v0.14.1
to v0.14.2
, and some cron jobs took several times longer to complete.
We ran some profiling and found that https://github.com/circe/circe/pull/1617/ caused this performance reduction by introducing a new cursorToDecodingFailure
function in modules/core/shared/src/main/scala/io/circe/Decoder.scala
that takes linear time to run.
Example
Demo.sc
import io.circe.Codec
import io.circe.generic.extras.Configuration
import io.circe.generic.extras.semiauto.deriveConfiguredCodec
import io.circe.parser.decode
import java.util.UUID
import scala.io.Source
case class Cat(
id: UUID,
friends: Seq[Cat] = Seq.empty
)
object Cat {
implicit final val configuration: Configuration = Configuration.default.withDefaults
implicit val personDecoder: Codec[Cat] = deriveConfiguredCodec
}
case class Dog(
id: UUID,
friends: Option[Seq[Dog]] = None
)
object Dog {
implicit final val configuration: Configuration = Configuration.default.withDefaults
implicit val personDecoder: Codec[Dog] = deriveConfiguredCodec
}
val fileSource = Source.fromFile("uuid-10k.json")
val fileContent = fileSource.getLines.mkString
fileSource.close()
val catStartTime = java.lang.System.currentTimeMillis()
decode[Seq[Cat]](fileContent)
println(s"Time taken for cats: ${java.lang.System.currentTimeMillis() - catStartTime} ms")
val dogStartTime = java.lang.System.currentTimeMillis()
decode[Seq[Dog]](fileContent)
println(s"Time taken for dogs: ${java.lang.System.currentTimeMillis() - dogStartTime} ms")
uuid-10k.json
[{"id":"19b10dec-91fe-42ee-8da7-2cafe9529dad"},{"id":"2da8de7d-02fe-479c-8293-4bebbd24c4ef"}, ... ]
Result
Time taken for cats: 3758 ms
Time taken for dogs: 154 ms
Cat
s and Dog
s are pretty similar. Surprisingly, one is significantly slower than the other. I believe many people use the style in the case class Cat
to represent potentially empty list fields. This will cause problems in some production environments once they switch to v0.14.2
.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (4 by maintainers)
Top Results From Across the Web
Releases — Panel v0.14.2
The 0.9.6 release unfortunately caused a major regression in layout performance due to the way optimizations in Bokeh and Panel interacted. This release...
Read more >Bitcoin Core version 0.14.2 released
This is a new minor version release, including various bugfixes and performance improvements, as well as updated translations.
Read more >Premiere Pro 14.2 H.264 and H.265 Hardware Encoding ...
Premiere Pro has supported H.264/H.265 hardware encoding for a long time, but it was limited to Intel CPUs that supported Quicksync.
Read more >Server Deployment — Panel v0.14.2rc2
In that situation a reverse tunnel must be established from the server to the ... Go to mybinder.org, enter the URL of your...
Read more >Release Notes | Firebase - Google
Performance Monitoring replaced the Top Issues field with Recent alerts in the Performance card on Project home. This is a follow-up to our...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
yep, fixed my issue as well., thx.
👍 Thanks for re-running that. We have some PRs in progress to hopefully help with that. See https://github.com/circe/circe/pull/1974