Open rymsha opened 3 years ago
The main issue lies in Thymeleaf (where imageUrl function gets called) and OGNL (where synchronization happens in order to cache methods)
One issue is on XP side though: in order to form image "hash" (or better call it fingerprint) elasticsearch "get" method gets invoked, ant that is naturally one of the slowest methods to call due to its realtime guarantees (by default)
at org.elasticsearch.client.support.AbstractClient.get(AbstractClient.java:188)
at com.enonic.xp.repo.impl.elasticsearch.storage.StorageDaoImpl.getById(StorageDaoImpl.java:176)
at com.enonic.xp.repo.impl.branch.storage.BranchServiceImpl.doGetById(BranchServiceImpl.java:172)
at com.enonic.xp.repo.impl.branch.storage.BranchServiceImpl.get(BranchServiceImpl.java:166)
at com.enonic.xp.repo.impl.storage.NodeStorageServiceImpl.get(NodeStorageServiceImpl.java:215)
at com.enonic.xp.repo.impl.node.GetNodeByIdCommand.execute(GetNodeByIdCommand.java:26)
at com.enonic.xp.repo.impl.node.AbstractNodeCommand.doGetById(AbstractNodeCommand.java:38)
at com.enonic.xp.repo.impl.node.GetBinaryKeyCommand.execute(GetBinaryKeyCommand.java:30)
at com.enonic.xp.repo.impl.node.NodeServiceImpl.getBinaryKey(NodeServiceImpl.java:779)
at com.enonic.xp.core.impl.content.GetBinaryKeyCommand.execute(GetBinaryKeyCommand.java:39)
at com.enonic.xp.core.impl.content.ContentServiceImpl.getBinaryKey(ContentServiceImpl.java:1070)
at com.enonic.xp.portal.impl.url.ImageUrlBuilder.resolveHash(ImageUrlBuilder.java:59)
at com.enonic.xp.portal.impl.url.ImageUrlBuilder.buildUrl(ImageUrlBuilder.java:30)
at com.enonic.xp.portal.impl.url.PortalUrlBuilder.doBuild(PortalUrlBuilder.java:146)
at com.enonic.xp.portal.impl.url.PortalUrlBuilder.build(PortalUrlBuilder.java:132)
at com.enonic.xp.portal.impl.url.PortalUrlServiceImpl.lambda$build$0(PortalUrlServiceImpl.java:106)
at com.enonic.xp.portal.impl.url.PortalUrlServiceImpl$$Lambda$237/71793612.call(Unknown Source)
at com.enonic.xp.context.ContextImpl.callWith(ContextImpl.java:101)
at com.enonic.xp.portal.impl.url.PortalUrlServiceImpl.runWithAdminRole(PortalUrlServiceImpl.java:137)
at com.enonic.xp.portal.impl.url.PortalUrlServiceImpl.build(PortalUrlServiceImpl.java:106)
at com.enonic.xp.portal.impl.url.PortalUrlServiceImpl.imageUrl(PortalUrlServiceImpl.java:65)
at com.enonic.xp.portal.impl.view.ImageUrlFunction.execute(ImageUrlFunction.java:27)
at com.enonic.xp.portal.impl.view.ViewFunctionServiceImpl.execute(ViewFunctionServiceImpl.java:41)
at com.enonic.xp.lib.thymeleaf.ThymeleafViewFunctions.execute(ThymeleafViewFunctions.java:63)
at com.enonic.xp.lib.thymeleaf.ThymeleafViewFunctions.imageUrl(ThymeleafViewFunctions.java:37)
at sun.reflect.GeneratedMethodAccessor20.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at ognl.OgnlRuntime.invokeMethod(OgnlRuntime.java:870)
- locked <0x00000005f51baf58> (a java.lang.reflect.Method)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1293)
at ognl.ObjectMethodAccessor.callMethod(ObjectMethodAccessor.java:68)
Rebranded it to an improvement. Real issue is in Thymeleaf (or better say, how it is used)
imageUrl are slow (they hit ES anyway)
Probably serialization only affects thymeleaf. But performance hit is severe: it multiplies elasticsearch response time by number of requests.