-
Notifications
You must be signed in to change notification settings - Fork 624
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
Implemented serializers caching for lookup #2015
Conversation
Results (NB: it's noisy, but shows general idea):
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approach in general looks okay, but parameterized serializer also should be cached
benchmark/src/jmh/kotlin/kotlinx/benchmarks/json/LookupOverheadBenchmark.kt
Show resolved
Hide resolved
Results with latest changes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm completely okay with ClassValue/caching part.
I would like @sandwwraith to check general code correctness, code style and consistency with his changes prior to merge, I haven't dived deep into the semantics of builtinSerializer
changes
|
||
companion object { | ||
fun from(serializer: KSerializer<out Any>?): SerializerPair? { | ||
return serializer?.let { SerializerPair(it, it.nullable) } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure creating a pair of serializers right away is a great idea. Since this is a cache only for top-level serializers, I strongly feel that many nullable serializers will never be used, since the non-nullable case is much, much more often. In the end, they'll be just hard-referenced garbage in memory
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I second that, that's a good observation.
A separate cache for nullable serializer might be good
Relates #2003