You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Below is a heatmap of the duration (ms) for otel traces for the operation described above. Between 10:25AM and 11:15AM we were running kotlinx-serialization 1.5.0 and Kotlin 1.8.0. Prior to, and after that, we were running kotlinx-serialization 1.3.3 and Kotlin 1.8.0. The duration of each operation steadily increased when using kotlinx-serialization 1.5.0.
Example of a span during the timeframe that kotlinx-serialization 1.5.0 was being used:
Benchmarks
Simple benchmarks were written to compare versions of kotlinx-serialization and Kotlin, which can be found here.
The first benchmark was designed to reproduce the issue we were experiencing:
fun retrieveSerializerPerIteration() {
repeat(1000) {
val metadata: Map<String, String> = Json.decodeFromString(json)
}
}
To verify that the serializer lookup was the cause, a second benchmark was written which retrieved the serializer only once:
fun retrieveSerializerOnce() {
val serializer = serializer<Map<String, String>>()
repeat(1000) {
val metadata: Map<String, String> = Json.decodeFromString(serializer, json)
}
}
Results (Average time per operation):
kotlin-x serialization
kotlin
retrieve serializater per iteration
retrieve serializater once
1.5.0
1.8.0
1868.430 ms/op
1.440 ms/op
1.5.0
1.8.21
1909.756 ms/op
1.383 ms/op
1.3.3
1.8.0
2.513 ms/op
0.483 ms/op
1.3.3
1.8.21
2.594 ms/op
0.493 ms/op
The benchmarks were run again, but with the addition of the serialization compiler plugin:
kotlin-x serialization
kotlin
retrieve serializater per iteration
retrieve serializater once
1.5.0
1.8.0
0.334 ms/op
0.356 ms/op
1.5.0
1.8.21
0.337 ms/op
0.361 ms/op
1.3.3
1.8.0
2.501 ms/op
0.490 ms/op
1.3.3
1.8.21
2.481 ms/op
0.475 ms/op
Expected behavior
Time to retrieve serializers for built in classes should be the same when using kotlinx-serialization 1.5.0/1.3.3 without the compiler plugin.
Environment
Kotlin version: 1.8.0 & 1.8.21
Library version: 1.5.0
Kotlin platforms: JVM
Gradle version: 8.1
Postgresql driver version: 42.4.3
HikariCP version: 5.0.0
The text was updated successfully, but these errors were encountered:
Description
Retrieval of built-in serializers for inferred types is significantly slower when using Kotlinx-serialization 1.5.0 without the compiler plugin.
We have an operation which reads 1000 events from a database, iterates through the returned rows and deserializes with:
Below is a heatmap of the duration (ms) for otel traces for the operation described above. Between 10:25AM and 11:15AM we were running kotlinx-serialization 1.5.0 and Kotlin 1.8.0. Prior to, and after that, we were running kotlinx-serialization 1.3.3 and Kotlin 1.8.0. The duration of each operation steadily increased when using kotlinx-serialization 1.5.0.
Example of a span during the timeframe that kotlinx-serialization 1.5.0 was being used:
Benchmarks
Simple benchmarks were written to compare versions of kotlinx-serialization and Kotlin, which can be found here.
The first benchmark was designed to reproduce the issue we were experiencing:
To verify that the serializer lookup was the cause, a second benchmark was written which retrieved the serializer only once:
Results (Average time per operation):
The benchmarks were run again, but with the addition of the serialization compiler plugin:
Expected behavior
Time to retrieve serializers for built in classes should be the same when using kotlinx-serialization 1.5.0/1.3.3 without the compiler plugin.
Environment
The text was updated successfully, but these errors were encountered: