-
Notifications
You must be signed in to change notification settings - Fork 38.5k
Improve performance for conversions using a method parameter based type descriptor with annotations [SPR-14926] #19493
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
Comments
Oliver Drotbohm commented I've attached a screenshot showing the culprit in a test case provided for the original ticket in Spring HATEOAS. Under |
Juergen Hoeller commented This turns out as a different variant of #19496: It's not the annotation comparisons being so expensive per se, it's rather just the merged annotation comparisons that we unnecessarily triggered from As of 4.3.5, we're comparing the raw declared annotations which seems efficient enough. Being able to isolate the descriptor to type plus annotations seems beneficial still, since for conversion purposes, it doesn't matter which signature the type and the annotations actually came from. |
Oliver Drotbohm commented I didn't dive in deeper as I was sort of assuming the "new way" of looking up annotations would always include the synthesization of annotations. Anyway, thanks for the quick turnaround! |
Oliver Drotbohm commented I don't see any significant changes in the numbers after the recent fixes . However, it looks like the hotspot has changed to be Also, the ticket was marked as fixed in 4.3.5 but I couldn't find a related commit in the 4.3.x branch. |
Oliver Drotbohm commented It looks like that |
Oliver Drotbohm commented I created a local "fix" using the annotation type and the target type descriptor in the cache key instead of the annotation instance (not sure that creates really valid equals comparisons, I just wanted to see where I get if that hotspot is removed. The next thing I run into is the actual conversion. That seems to work well for simple conversions. However, playing around with it, I discovered something quite obscure again: ResponseEntity<Object> someMethod(@RequestParam("foo") @DateTimeFormat(iso = ISO.DATE) Date date) {…} Letting the |
Oliver Drotbohm commented Looks like the usage of |
Oliver Drotbohm opened SPR-14926 and commented
When a conversion is invoked using a
TypeDescriptor
instance that was created for aMethodParameter
containing annotations, the lookup of theConverter
is significantly slowed down as theTypeDescriptor
instances undergo an….equals(…)
check that's quite expensive due to the synthesized annotations.I wonder whether
TypeDescriptor
really needs to compare the annotations if the method and the parameter index are well defined as they by definition uniquely identify the parameter.Here's a sample test case showing the issue:
Affects: 4.3.4
Reference URL: spring-projects/spring-hateoas#511
Attachments:
Issue Links:
@AliasFor
@DateTimeFormat
(iso = ISO.DATE_TIME) should use optimized formatter for LocalDateTimeThe text was updated successfully, but these errors were encountered: