Is it expected that the first deserialization from...
# serialization
m
Is it expected that the first deserialization from a
Json
instance will be slow? Parsing a small JSON text in some unit tests. The first test takes 167 ms (longer on build machine) just in the parsing. All the other tests take about one millisecond to parse the same amount of JSON. This is on the JVM with Kotlin 1.6.10 and Serialization 1.3.2.
b
This is JVM JIT in action. Any big operation is expected to be much slower the first time it's executed.
m
I would have expected JIT to take longer to improve, but that does make sense
e
also note that if you're using the reified helpers that don't require a serializer as input, then it (counterintuitively) performs reflection to find the serializer, which will also be slower the first time (and will always be slower than passing the serializer explicitly)
m
I was using the reified version. Changing didn't have much of an impact.
m
In addition to the above reasons, maybe Classloading plays a role there? You could try to warm the classes before deserializing to see if there's any difference