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

Performance Issue with @ModelAttribute [SPR-15198] #19762

Closed
spring-issuemaster opened this issue Jan 27, 2017 · 3 comments
Closed

Performance Issue with @ModelAttribute [SPR-15198] #19762

spring-issuemaster opened this issue Jan 27, 2017 · 3 comments

Comments

@spring-issuemaster
Copy link
Collaborator

@spring-issuemaster spring-issuemaster commented Jan 27, 2017

Jochen Pier opened SPR-15198 and commented

There is a possible performance problem:

If you use:

@ModelAttribute
public void before(@ModelAttribute(name="test") TestClass test) {
	test.setPayload("myPayload");
}

it is MUCH (10x) slower than the same

@ModelAttribute
public void before(Model model) {
	TestClass t = new TestClass();
	t.setPayload("myPayload");
	model.addAttribute("test", t);
}

This is true especially in high traffic situations and is constantly getting worse (slower) over the time.

I think, maybe a hint in the documentation will be a good idea. (Or maybe you can find the problem)

Do you need a test-project?


Affects: 4.3.5

Issue Links:

  • #19626 Annotated method argument matching performance issue ("duplicates")
@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 27, 2017

Rossen Stoyanchev commented

ModelAttribute performs data binding so yes the details of the Object (how many fields, how many nested Objects, etc) could make a difference. In the very lease providing a TestClass object that approximates the real one would help. Or test project even better.

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Jan 29, 2017

Jochen Pier commented

I just added a test-project to the repo.
Please note: The problem seems to exists only in spring boot 1.4.3 - and NOT any more in spring boot 1.4.4!!
(I just discovered this while testing) But perhaps it's worth checking anyway.

Thank you!!

@spring-issuemaster
Copy link
Collaborator Author

@spring-issuemaster spring-issuemaster commented Feb 9, 2017

Rossen Stoyanchev commented

After taking a closer look, thanks for the sample, it appears the issue is a duplicate of #19626. The hotspot (~65% of time) is exactly in the same place as the first screenshot attached to #19626 but invoked from the ModelAttributeMethodProcessor. There is also a comment at the bottom about a similar report with an @ModelAttribute method. The versions also match (fixed in 4.3.6 which is what Spring Boot 1.4.4 is based on).

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

Successfully merging a pull request may close this issue.

None yet
2 participants
You can’t perform that action at this time.