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 and late resolve annotations on bean properties to improve performance [SPR-9166] #13804
Comments
Taylor S. Wicksell commented https://github.com/Gradinko/spring-framework/commit/d8f3b0c3e307f5b6d70a8da3fe8bef9c3db4acd4 Made an attempt at delaying the parsing of annotations as a proof of concept. Broke no unit tests, greatly mitigated blocking issue in web application, showed good improvement in unit test referenced in description;
Change could definitely be made cleaner, but hopefully this can help guide towards a solution. |
Daniel Mikusa commented Taylor, You had previously asked why TypeDescriptor is comparing annotations in its equals method. I have an answer to your question. This is important for situations where type conversion may be influenced by an annotation. For example, if one class field is annotated with In other words, you fix here should work as long as you don't try to use Annotation driven formatting. Dan |
Chris Beams commented Taylor originally submitted a proposed fix for this issue at #18. I've asked him to follow the contributor guidelines and create a new pull request. |
Taylor S. Wicksell commented Phil, I don't think my original commit was really pull-worthy, but just a demonstration of the problem and my own fix which worked for my use case. Here is that commit for reference if it helps at all in your investigation of this issue > twicksell@d8f3b0c |
Phil Webb commented Hi Taylor, Both your commit and especially the test case that you provided have been very useful. I am investigating to see if we can use your approach in combination with some caching to speed things up. Cheers, |
Phil Webb commented A fix for this is now committed. Running the test case provided by Taylor S. Wicksell my timing reduced from 42.93s to 1.93s. |
Taylor S. Wicksell opened SPR-9166 and commented
The same type of deadlock seen in #13722 can actually be triggered from numerous locations in the framework beyond just converter cache lookup. After the release of 3.1.1 we noticed the same issue being triggered from multiple calls from the Spring Form tag.
The root issue seems to be the reading of annotations using reflection in the constructor of org.springframework.core.convert.Property. This condition can be recreated fairly easily by calling this constructor from a unit test using multiple threads, as shown here: https://gist.github.com/1894670
It would seem like deferring the parsing of annotations until they are actually requested could help to mitigate this issue greatly.
Affects: 3.0.6, 3.1.1
Issue Links:
Referenced from: commits 02ce826
2 votes, 6 watchers
The text was updated successfully, but these errors were encountered: