-
Notifications
You must be signed in to change notification settings - Fork 38.4k
Inefficient reflection operations for destroy method determination #26498
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
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Milestone
Comments
This was referenced Mar 7, 2021
Merged
This was referenced Mar 15, 2021
Open
lxbzmy
pushed a commit
to lxbzmy/spring-framework
that referenced
this issue
Mar 26, 2022
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
in: core
Issues in core modules (aop, beans, core, context, expression)
status: backported
An issue that has been backported to maintenance branches
type: enhancement
A general enhancement
Affects: Spring 4.x, 5.x
Problem:
Each call to DisposableBeanAdapter.hasDestroyMethod() for a given bean class will return the same boolean value, however in many cases those invocations issue one or two reflection operations to determine whether those methods exist. In the case of high-volume web applications, request-scoped beans are frequently initialized, resulting in many repetitve reflection operations.
Impact:
In two large, publicly-facing web applications, this problem uses between 1% and 3% cpu, and adds several milliseconds of latency to the server response.
Suggested solution:
We solved this internally by caching the result in a WeakHashMap<String, Boolean> keyed off of the classname. There was some discussion of using the Class rather than the name but we saw slightly better performance with this configuration.
The text was updated successfully, but these errors were encountered: