Details
-
Task
-
Status: Open
-
Major
-
Resolution: Unresolved
-
Models Implementation 1.6.4
-
None
-
None
Description
While analyzing repository access, I found a pattern in the Scripting HTL implementation, which leads to multiple invocations of the same check on the same resources in the Sling Model ModelAdapterFactory.
Invocation at JavaUseProvider.loadObject():
- modelAdapterFactory.canCreateModelFromAdaptable()
- modelAdapterFactory.createModel
those methods directly or indirectly call org.apache.sling.models.impl.AdapterImplementations.lookup(), which calls getModelClassForResource; and there multiple resources are resolved, based on the provided resourceType.
I benchmarked this code using a simple AEM sample page (WKND) using HTL and Sling Models. I found this code is responsible to the creation of 712 JCR Node resource objects (the total page rendering triggered the creation of more than 10k, so these are around 7%). When deduplicating the requested paths, I found that only 36 distinct paths were resolved with these 712 JCR Node resources.
That means that with proper caching (probably using the ResourceResolver.getPropertyMap) around 6.5% of repository access could be avoided, leading to a page rendering improvement in about the same range.