Skip to content
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

Optimize KotlinAnnotationIntrospector#AnnotatedMethod.hasRequiredMarker method. #449

Merged
merged 10 commits into from Oct 18, 2021

Conversation

k163377
Copy link
Contributor

@k163377 k163377 commented May 23, 2021

Purpose of the PR

The main purpose of this PR is to speed up the AnnotatedMethod.hasRequiredMarker method.

On getting a RequiredMarker from a KProperty

The process of getting RequiredMarker from KProperty has been modified to be done in a single loop.

In the current implementation, the process of getting the RequiredMarker from KProperty is performed separately by AnnotatedMethod.getCorrespondingGetter and AnnotatedMethod.getCorrespondingSetter.
member.declaringClass.kotlin.declaredMemberProperties, which is called in each of these two methods, is considered to be expensive to execute (I didn't run a benchmark to confirm this, but it seems so from the implementation).
Therefore, reducing the number of calls to it will speed up the process.

Regarding KFunction<*>.isSetterLike()

Since the result of Unit::class.createType() executed by KFunction<*>.isSetterLike() is immutable, it has been modified to be used as a constant.
This process also seems to have been expensive to execute.

Others

I also did some refactoring at the same time.

Questions

Should declaringClass.kotlin.declaredMemberProperties also be cached as Class -> List<KProperty1>?
When serializing/deserializing a class with a large number of fields, it seems to be more efficient to cache this process as well.

@dinomite dinomite self-assigned this Aug 13, 2021
@k163377
Copy link
Contributor Author

k163377 commented Oct 16, 2021

@dinomite It would be great if you could review this PR as well.

@dinomite
Copy link
Member

@k163377 👍 Will do, thanks for the reminder.

@dinomite dinomite merged commit cf5a405 into FasterXML:2.13 Oct 18, 2021
@k163377 k163377 deleted the optimize_instrospector branch October 18, 2021 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants