kotlinx.serialization
kotlinx.serialization copied to clipboard
[DRAFT] Serializers cache
Attempt to somehow address #2003
Preliminary data
Benchmark Mode Cnt Score Error Units
LookupOverheadBenchmark.dataPlain thrpt 14 9.831 ± 0.457 ops/us
LookupOverheadBenchmark.dataReified thrpt 14 3.326 ± 0.084 ops/us
LookupOverheadBenchmark.genericPlain thrpt 14 5.473 ± 0.565 ops/us
LookupOverheadBenchmark.genericReified thrpt 14 0.164 ± 0.008 ops/us
LookupOverheadBenchmark.objectPlain thrpt 14 27.828 ± 2.141 ops/us
LookupOverheadBenchmark.objectReified thrpt 14 5.221 ± 0.101 ops/us
The following best-case approximation of caching:
@Benchmark
fun objectApprox(): Object {
typeOf<Object>()
return Json.decodeFromString(Object.serializer(), "{}")
}
gives
LookupOverheadBenchmark.objectApprox thrpt 14 13.181 ± 0.821 ops/us
which is much better for the benchmark that stresses empty string
Continuing in https://github.com/Kotlin/kotlinx.serialization/issues/2003
Continuing a PR in an issue that predates it? Are you sure you referenced the right one?
Oh, right, I've meant https://github.com/Kotlin/kotlinx.serialization/pull/2015 :)