Skip to content

Cache Interceptor signature result #3396

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

Puppy4C
Copy link

@Puppy4C Puppy4C commented Jan 18, 2025

The signature of Interceptor is static, and I think it should be cached, otherwise every time an operation is performed, a new one will be created, which is a time-consuming operation.

@@ -64,6 +67,10 @@ public Object invoke(Object proxy, Method method, Object[] args) throws Throwabl
}

private static Map<Class<?>, Set<Method>> getSignatureMap(Interceptor interceptor) {
return signatureMapCache.computeIfAbsent(interceptor.getClass(), (clazz) -> createSignatureMap(interceptor));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggest changing it to org.apache.ibatis.util.MapUtil#computeIfAbsent

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, it seemed that this method did not exist at the time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See #3372

@harawata
Copy link
Member

Thank you for the PR, @Puppy4C !

I did some tests and the effect of this PR was not significant (see the benchmark result).
Unless there is some issue with my benchmark code/config, I consider this to be a "premature optimization" and will close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants