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

Share MethodParameter cache between HandlerMethods [SPR-9748] #14382

Closed
spring-projects-issues opened this issue Sep 3, 2012 · 5 comments
Closed
Assignees
Labels
in: web type: enhancement
Milestone

Comments

@spring-projects-issues
Copy link
Collaborator

@spring-projects-issues spring-projects-issues commented Sep 3, 2012

Patrick Linskey opened SPR-9748 and commented

RequestMappingHandlerAdapter creates a new HandlerMethod for each request. HandlerMethods cache their MethodParameters to avoid costly reflection calls each time annotation stats are needed, but the per-request copy circumvents this cache. This patch explicitly copies the MethodParameter cache from a HandlerMethod and its request-scoped dependents.


Affects: 3.1.1, 3.1.2, 3.2 M2

Issue Links:

  • #13936 monitor contention at org.springframework.core.MethodParameter.getParameterAnnotations() ("is duplicated by")
  • #17058 NPE in org.springframework.core.MethodParameter.getParameterName (possible race condition)
  • #17429 Thread contention in HandlerMethod due to unnecessary BeanFactory.getType call

Referenced from: commits 2295372, 0a877af

1 votes, 3 watchers

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 3, 2012

Patrick Linskey commented

GitHub commit for 3.1.1: pcl@15a9eee
GitHub commit for master: pcl@4939518

Note that this and #14381 both contain edits to HandlerMethod. The GitHub commits above are applied on top of the #14381 patch; applying them out-of-order might take some manual tweaking.

'./gradlew build' succeeds with this patch on master. I'm still trying to figure out how to get 3.1.1 to build on my machine (http://forum.springsource.org/showthread.php?129846-Spring-3-1-1-compilation&p=423733#post423733)

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 3, 2012

Patrick Linskey commented

FYI, this eliminates 2.1% of the CPU burn in my Spring-MVC app.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 3, 2012

Patrick Linskey commented

On closer inspection, this eliminates 4.2% of the CPU burn.

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 10, 2012

Rossen Stoyanchev commented

This should now be resolved although using a slightly different approach. Here is the commit with the changes. It has also been applied to 3.1.x (and will be in 3.1.3) with a few other changes. Note however that currently there are (unrelated) build failures in both master and 3.1.x, so no snapshots are available yet.

Thanks for raising this issue!

@spring-projects-issues
Copy link
Collaborator Author

@spring-projects-issues spring-projects-issues commented Sep 10, 2012

Patrick Linskey commented

Looks good... and incidentally, this fix might resolve a follow-on optimization that we noticed around ServletInvocableHandlerMethod. I'll try these out once a snapshot for 3.1.3 is available and see what the impact is. Thanks!

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

No branches or pull requests

2 participants