[ 
https://issues.apache.org/jira/browse/SLING-3332?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13879866#comment-13879866
 ] 

Antonio Sanso commented on SLING-3332:
--------------------------------------

the startup/update slowness for the sling:alias comes from the optimization 
introduced in SLING-2521.

Now this is a good optimization indeed but IMHO it is really specific for 
repositories that have that "many-children-problem". 

The new code in the ResourceResolverImpl  looks like

{code}
final Map<String, String> aliases = 
factory.getMapEntries().getAliasMap(parent.getPath());
        if (aliases != null) {
            final String aliasName = aliases.get(childName);
            if (aliasName != null ) {
                final String aliasPath;
                if ( aliasName.startsWith("/") ) {
                    aliasPath = aliasName;
                } else {
                    aliasPath = parent.getPath() + '/' + aliasName;
                }
                final Resource aliasedChild = getResourceInternal( 
ResourceUtil.normalize(aliasPath) );
                logger.debug("getChildInternal: Found Resource {} with alias {} 
to use", aliasedChild, childName);
                return aliasedChild;
            }
        }
{code}

rather than

{code}
final Iterator<Resource> children = listChildren(parent);
        while (children.hasNext()) {
            child = children.next();
            if (!child.getPath().endsWith(JCR_CONTENT_LEAF)) {
                final String[] aliases = getProperty(child, PROP_ALIAS, 
String[].class);
                if (aliases != null) {
                    for (final String alias : aliases) {
                        if (childName.equals(alias)) {
                            logger.debug("getChildInternal: Found Resource {} 
with alias {} to use", child, childName);
                            return child;
                        }
                    }
                }
            }
        }
{code}

>From the other hand this optimization (given the fact an in-memory-map needs 
>to be built and updated ) will introduce the slow startup/update problem.

Should a repository not have the "many-children-problem" it would actually 
beneficial  to have the old (pre SLING-2521) behavior (only in case of many 
sling:alias).

>From this reason I would suggest to have a switch in the Felix Console where 
>the user can choose between have the optimization (in SLING-2521 ) or not.  

> Long startup time with many sling:alias
> ---------------------------------------
>
>                 Key: SLING-3332
>                 URL: https://issues.apache.org/jira/browse/SLING-3332
>             Project: Sling
>          Issue Type: Improvement
>          Components: ResourceResolver
>            Reporter: Antonio Sanso
>            Priority: Minor
>
> Similarly to SLING-3290 (Long startup time with many vanityPath) .
> When many  sling:alias are present the system take long time to startup , 
> Same when alias is removed or updated (and many sling:alias are present) .
> The reason behind is the usage of a query that updates the aliasMap used as 
> cache for sling:alias.
> Performance test report to follow



--
This message was sent by Atlassian JIRA
(v6.1.5#6160)

Reply via email to