-
Notifications
You must be signed in to change notification settings - Fork 175
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
Reflection overhead #310
Comments
This is not much information to go about: is this on-going (overhead during operation), or just during initial warmup period? Are you properly reusing Startup overhead is to be expected as initial construction of (de)serializers requires Reflection access to find Bean/value class structure, as well as any annotations. But assuming mappers are not created on per-call basis (which is a really bad idea wrt performance), there should not be reflection access after initial use. So you would need to show actual code, or perhaps performance test reproduction. |
@cowtowncoder , I had faced the same issue and after some investigation I could conclude that the problem in that line : val isGenericTypeVar = paramDef.type.javaType is TypeVariable<*> Call to I would suggest to replace that part of code with something like below to prevent unneeded have calls: val isGenericTypeVar = { paramDef.type.javaType is TypeVariable<*> }
val isMissingAndRequired = paramVal == null && isMissing && jsonProp.isRequired
if (isMissingAndRequired ||
(paramVal == null && !paramDef.type.isMarkedNullable && !isGenericTypeVar())) { I can send a PR if it's ok with that approach. |
@Tapac I'll have to defer to @dinomite and @viartemev here wrt proposed change. But what is weird is that modules rarely should have to rely on Still.... what I do not understand is this: looking for |
What kind of a cache do you mean? |
@Tapac Ah! |
Hmm, it looks like that |
I don't think we can avoid calling The hard part in my mind is a test to verify that change is actually productive. Oh, and I had missed that @Tapac had suggested nearly this—would you create a PR with your implementation idea? |
@dinomite I think there should be a simpler way -- why aren't these aspect resolved right in constructor of Kotlin ValueInstantiator, instead of So, as much of introspection code as possible should be moved in constructor (or maybe better yet, factory method, which then just passes resulting configuration settings), and I wish I could suggest specific changes, but unfortunately I can't quite follow Kotlinisms. But I am pretty sure that all relevant information must be statically (as in, during construction of |
Good explanation, I'll see how I can do this from |
After migrating one of our rest clients to kotlin data classes (with jackson and KotlinModule), we observe large reflection overheads. This almost doubles our allocation rate compared to the previous implementation.
Reflection cache is on with with 500.000 limit.
Similar issue:
#136
The text was updated successfully, but these errors were encountered: