[ https://issues.apache.org/jira/browse/SLING-3848?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14101298#comment-14101298 ]
Rob Ryan commented on SLING-3848: --------------------------------- [~cziegeler] Thanks for the quick action. WRT your comment about 99 % of cases resourceType always being needed was contradicted by my experience. Consider Resolver.map() where each path up to the root would be resolvedwhen all it needed from each level was the sling:alias. In that case resourceType was irrelevant and in our use case Resolver,map() was consuming significant CPU due to that loop. There is a separate fix for that leveraging [~asanso]'s work on vanity paths and aliases, but his work has to be disabled if there any many aliases or vanity paths... That wasn't the only place experiencing the cost of instantiating resources, but it is suggestive that there may be other places where resources are created when only limited data is needed. Bear in mind that our use case is *not* primarily sling render driven. it take me awhile to get to it, but I'll re-verify. I expect to find that the initialization of resourceType in the constructor will show to have a noticeable impact. I'll check also whether delayed initialization is significantly different than Felix's optimization. > JcrNodeResource takes too long and initializes too much too soon > ---------------------------------------------------------------- > > Key: SLING-3848 > URL: https://issues.apache.org/jira/browse/SLING-3848 > Project: Sling > Issue Type: Improvement > Components: JCR > Reporter: Rob Ryan > Assignee: Carsten Ziegeler > Fix For: JCR Resource 2.3.8, API 2.7.2 > > Attachments: sling.api.diff, sling.jcr.resource.diff > > > In a performance test expected to reflect reasonably real-world conditions > (50 concurrent users of a mixed load 'forum' type application) I found > org.apache.sling.jcr.resource.internal.helper.jcr.JcrNodeResource.JcrNodeResource(ResourceResolver, > Node, ClassLoader) taking more than 20% of time used. The majority of this > time was spent in setting the resource metadata and to a lesser extent the > resource type. > Because the metadata especially is not often accessed and even the resource > type is not always accessed, delaying these initializations led to a > noticeable performance improvement. > The attached patch delays resourcetype lookup and metadata lookups until > needed. -- This message was sent by Atlassian JIRA (v6.2#6252)