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

Cache BridgeMethodResolver results #22579

Closed
Tracked by #22560
philwebb opened this issue Mar 13, 2019 · 0 comments
Closed
Tracked by #22560

Cache BridgeMethodResolver results #22579

philwebb opened this issue Mar 13, 2019 · 0 comments
Assignees
Labels
in: core Issues in core modules (aop, beans, core, context, expression) type: enhancement A general enhancement
Milestone

Comments

@philwebb
Copy link
Member

Some analysis shows that it's quite common for the BridgeMethodResolver to be asked about the same method multiple times. Although not massively expensive (since we already lean on existing method and resolvable type caches), there is still some overhead with these calls. Given the relatively small number of bridge methods, it might be worth adding a cache for the results.

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged or decided on label Mar 13, 2019
@philwebb philwebb self-assigned this Mar 13, 2019
@sbrannen sbrannen added the in: core Issues in core modules (aop, beans, core, context, expression) label Mar 13, 2019
snicoll pushed a commit to snicoll/spring-framework that referenced this issue Mar 13, 2019
Add a cache to `BridgeMethodResolver` to help with repeated calls to
resolve the same methods. Since bridge method resolution can be somewhat
expensive (especially when resolving generics), and the number of bridge
methods is quite small, a cache generally helps.

This commit also simplifies the code a little by calling `doWithMethods`
directly rather than relying on `ReflectionUtils.getAllDeclaredMethods`
to do so. The methods list is now always created, but we save the list
creation that `getAllDeclaredMethods` used to do.

Closes spring-projectsgh-22579
philwebb added a commit to philwebb/spring-framework that referenced this issue Mar 14, 2019
Add a cache to `BridgeMethodResolver` to help with repeated calls to
resolve the same methods. Since bridge method resolution can be somewhat
expensive (especially when resolving generics), and the number of bridge
methods is quite small, a cache generally helps.

This commit also simplifies the code a little by calling `doWithMethods`
directly rather than relying on `ReflectionUtils.getAllDeclaredMethods`
to do so. The methods list is now always created, but we save the list
creation that `getAllDeclaredMethods` used to do.

Closes spring-projectsgh-22579
@jhoeller jhoeller added type: enhancement A general enhancement and removed status: waiting-for-triage An issue we've not yet triaged or decided on labels Mar 23, 2019
@jhoeller jhoeller added this to the 5.2 M1 milestone Mar 23, 2019
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) type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants