<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=jsl1" rel="nofollow">jsl1</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9343?redirect=false" rel="nofollow">SPR-9343</a></strong> and commented</p>
<p dir="auto">org.springframework.core.convert.Property class performs expensive operations in its constructor such as resolveAnnotations() method.</p>
<p dir="auto">The annotations could be lazy loaded instead (when calling getAnnotations())<br>
I noticed that while profiling an application using BeanWrapperImpl to set java bean properties values (see screenshot attached).</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1.1</p>
<p dir="auto"><strong>Attachments:</strong></p>
<ul dir="auto">
<li><a href="https://jira.spring.io/secure/attachment/19614/spring_bug.png" rel="nofollow">spring_bug.png</a> (<em>26.25 kB</em>)</li>
</ul>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398152353" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/14304" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/14304/hovercard" href="https://github.com/spring-projects/spring-framework/issues/14304">#14304</a> Poor Performance with lots of Prototype Scoped Beans (<em><strong>"duplicates"</strong></em>)</li>
</ul>
<p dir="auto"><strong><a href="https://jira.spring.io/secure/ViewProfile.jspa?name=kmudrick" rel="nofollow">Kevin Mudrick</a></strong> opened <strong><a href="https://jira.spring.io/browse/SPR-9670?redirect=false" rel="nofollow">SPR-9670</a></strong> and commented</p>
<p dir="auto">We are seeing a pretty substantial performance hit with the creation of large quantities of prototype-scoped beans in the 3.1.x branch versus 3.0.x (and 2.5.6)</p>
<p dir="auto">In our example, we have call context.getBean() with a bean consisting of 2 levels of nested bean referenced, in a pretty large loop.</p>
<p dir="auto">3.0.7: 40604ms<br>
3.1.2: 685150ms</p>
<p dir="auto">The only difference between these runs is the version of the spring dependencies.</p>
<p dir="auto">After profiling using YourKit, I found the hotspots in 3.1.x to be in the following places:</p>
<p dir="auto">org.springframework.beans.TypeConverterDelegate: This seems to be the bigger problem.<br>
The changes introduced in 3.1 (specifically, in commit <a class="commit-link" data-hovercard-type="commit" data-hovercard-url="https://github.com/spring-projects/spring-framework/commit/6f146737f475828b6d765784017773378c2c4922/hovercard" href="https://github.com/spring-projects/spring-framework/commit/6f146737f475828b6d765784017773378c2c4922"><tt>6f14673</tt></a>) to findDefaultEditor() end up (expensively) initializing an editor registry every time this is called.  Since we get here each time we apply a property on every bean creation, this really adds up.  Previously, the commented-out code ended up shortcutting this.  I found that replacing the commented out code (the part that relied on the now-removed PropertyTypeDescriptor/PropertyDescriptor with static use of PropertyEditorManager.findEditor(), cuts down on the slowness considerably, at the expense of relying on java.beans - which a few commit comments seem to indicate is something to be avoided for better platform compatibility.</p>
<p dir="auto">org.springframework.core.convert.Property: This also seems to be a problem.<br>
The overhead of the annotation parsing via reflection is already noted in <a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398118763" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13981" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13981/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13981">#13981</a> - but that issue doesn't seem to mention this example.  My profiling is showing that this is being constructed for every property found on every bean being created.  With lots of prototype beans - this comes to light pretty quickly.  Perhaps if ReflectionUtils used a similar caching strategy to apache commons-beanutils PropertyUtilsBean for annotations, this performance hit could be mitigated.</p>
<hr>
<p dir="auto"><strong>Affects:</strong> 3.1.2</p>
<p dir="auto"><strong>Issue Links:</strong></p>
<ul dir="auto">
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398118763" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13981" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13981/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13981">#13981</a> org.springframework.core.convert.Property class performs expensive operations in its constructor (<em><strong>"is duplicated by"</strong></em>)</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398106550" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/12081" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/12081/hovercard" href="https://github.com/spring-projects/spring-framework/issues/12081">#12081</a> Concurrent prototype creation causes NullPointerException</li>
<li><a class="issue-link js-issue-link" data-error-text="Failed to load title" data-id="398113052" data-permission-text="Title is private" data-url="https://github.com/spring-projects/spring-framework/issues/13109" data-hovercard-type="issue" data-hovercard-url="/spring-projects/spring-framework/issues/13109/hovercard" href="https://github.com/spring-projects/spring-framework/issues/13109">#13109</a> TypeConverterDelegate contains commented out code</li>
</ul>
<p dir="auto">0 votes, 6 watchers</p>