[
https://issues.apache.org/jira/browse/SLING-3844?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14167069#comment-14167069
]
Antonio Sanso commented on SLING-3844:
--------------------------------------
hi [[email protected]] Thanks a lot for your patch.
I wounder though if something a bit more simple (maybe a bit slower though)
would also do the trick. E.g. something like
{code}
### Eclipse Workspace Patch 1.0
#P org.apache.sling.resourceresolver
Index:
src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
===================================================================
---
src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
(revision 1630918)
+++
src/main/java/org/apache/sling/resourceresolver/impl/ResourceResolverImpl.java
(working copy)
@@ -437,7 +437,22 @@
while (path != null) {
String alias = null;
if (current != null && !path.endsWith(JCR_CONTENT_LEAF)) {
- alias = ResourceResolverContext.getProperty(current,
PROP_ALIAS);
+ if
(factory.getMapEntries().isOptimizeAliasResolutionEnabled()){
+ logger.debug("map: Optimize Alias Resolution is
Enabled");
+ //TODO handle /
+
+ final Map<String, String> aliases =
factory.getMapEntries().getAliasMap(current.getParent().getPath());
+ if (aliases!= null &&
aliases.containsValue(current.getName())) {
+ for (String key:aliases.keySet()) {
+ if
(current.getName().equals(aliases.get(key))) {
+ alias = key;
+ }
+ }
+ }
+ } else {
+ logger.debug("map: Optimize Alias Resolution is
Disabled");
+ alias = ResourceResolverContext.getProperty(current,
PROP_ALIAS);
+ }
}
if (alias == null || alias.length() == 0) {
alias = ResourceUtil.getName(path);
{code}
WDYT?
> Resolver.map() spends too much time looking up sling:alias
> ----------------------------------------------------------
>
> Key: SLING-3844
> URL: https://issues.apache.org/jira/browse/SLING-3844
> Project: Sling
> Issue Type: Improvement
> Components: ResourceResolver
> Affects Versions: Resource Resolver 1.1.0
> Reporter: Rob Ryan
> Assignee: Antonio Sanso
> Labels: Performance
> Attachments: sling.resourceresolver.diff
>
>
> In a performance test expected to reflect reasonably real-world conditions
> (50 concurrent users of a mixed load 'forum' type application) I found
> Resolver.map taking more that 30% of the time used. This was tracked
> primarily to checking each path element of the mapped path for sling:alias
> properties to substitute into the result.
> In consultation with [~cziegeler] and [~asanso] I proceeded to implement the
> inverse of Antonio's work on sling:alias for Resolver.resolve. The resulting
> patch is attached. In our case the Resolver.map cost fell from 30% of time
> used to 5%.
> If the resource.resolver.optimize.alias.resolution setting of the Apache
> Sling Resource Resolver Factory is set to false then the patch fallback to
> the original method of finding aliases. When the optimization is enabled the
> aliases are looked up in hash maps maintained by observation and queries for
> sling:alias along the same lines as Antonio's work.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)