You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by "Thomas Mueller (JIRA)" <ji...@apache.org> on 2012/07/23 12:31:34 UTC

[jira] [Created] (OAK-201) NamespaceRegistry is very slow

Thomas Mueller created OAK-201:
----------------------------------

             Summary: NamespaceRegistry is very slow
                 Key: OAK-201
                 URL: https://issues.apache.org/jira/browse/OAK-201
             Project: Jackrabbit Oak
          Issue Type: Bug
            Reporter: Thomas Mueller


The NamespaceRegistryImpl.getURI and getPrefix are called a lot, for example by NamePathMapperImpl.getOakName. 

The method doesn't do any caching, which is a problem because it has to read it each time from the repository. Even if it would do caching, it wouldn't help because it the method WorkspaceImpl.getNamespaceRegistry creates a new NamespaceRegistryImpl each time it is called. To allow caching of known mappings, the instance needs to be cached as well.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (OAK-201) NamespaceRegistry is very slow

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420546#comment-13420546 ] 

Jukka Zitting commented on OAK-201:
-----------------------------------

Before trying to optimize the NamespaceRegistryImpl, I'd prefer to get rid of the {{getURI}} and {{getPrefix}} calls in the first place. The name mapper could avoid all namespace lookups as long as no session-local namespace remappings are in effect.
                
> NamespaceRegistry is very slow
> ------------------------------
>
>                 Key: OAK-201
>                 URL: https://issues.apache.org/jira/browse/OAK-201
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>            Reporter: Thomas Mueller
>
> The NamespaceRegistryImpl.getURI and getPrefix are called a lot, for example by NamePathMapperImpl.getOakName. 
> The method doesn't do any caching, which is a problem because it has to read it each time from the repository. Even if it would do caching, it wouldn't help because it the method WorkspaceImpl.getNamespaceRegistry creates a new NamespaceRegistryImpl each time it is called. To allow caching of known mappings, the instance needs to be cached as well.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (OAK-201) NamespaceRegistry is very slow

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420583#comment-13420583 ] 

Julian Reschke commented on OAK-201:
------------------------------------

That would work; but wouldn't it be simpler if we just used constants for the node type names using the known OAK prefixes? (and not use expanded names at all here)
                
> NamespaceRegistry is very slow
> ------------------------------
>
>                 Key: OAK-201
>                 URL: https://issues.apache.org/jira/browse/OAK-201
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>            Reporter: Thomas Mueller
>
> The NamespaceRegistryImpl.getURI and getPrefix are called a lot, for example by NamePathMapperImpl.getOakName. 
> The method doesn't do any caching, which is a problem because it has to read it each time from the repository. Even if it would do caching, it wouldn't help because it the method WorkspaceImpl.getNamespaceRegistry creates a new NamespaceRegistryImpl each time it is called. To allow caching of known mappings, the instance needs to be cached as well.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (OAK-201) NamespaceRegistry is very slow

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420579#comment-13420579 ] 

Jukka Zitting commented on OAK-201:
-----------------------------------

Here's a quick draft of what I think the name mapper for the "no session-local namespace remappings" case should look like:

{code}
private static final Map<String, String> STANDARD_NAMES =
        ImmutableMap.<String, String>builder()
        .put(NodeType.NT_BASE, "nt:base")
        .put(Property.JCR_PRIMARY_TYPE, "jcr:primaryType")
        ...
        .build();

public String getOakName(String jcrName) {
    if (jcrName.charAt(0) != '{') {
        return jcrName;
    }

    String oakName = STANDARD_NAMES.get(jcrName);
    if (oakName != null) {
        return oakName;
    }
     // Fall back to normal parsing and mapping of the name
}
{code}
                
> NamespaceRegistry is very slow
> ------------------------------
>
>                 Key: OAK-201
>                 URL: https://issues.apache.org/jira/browse/OAK-201
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>            Reporter: Thomas Mueller
>
> The NamespaceRegistryImpl.getURI and getPrefix are called a lot, for example by NamePathMapperImpl.getOakName. 
> The method doesn't do any caching, which is a problem because it has to read it each time from the repository. Even if it would do caching, it wouldn't help because it the method WorkspaceImpl.getNamespaceRegistry creates a new NamespaceRegistryImpl each time it is called. To allow caching of known mappings, the instance needs to be cached as well.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (OAK-201) NamespaceRegistry is very slow

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420601#comment-13420601 ] 

Julian Reschke commented on OAK-201:
------------------------------------

OK, that's a case where we get the node type name from the caller, and where we need to support both remapped prefixes and expanded names.

I'll get to the missing optimization in the name mapper for this case this afternoon.
                
> NamespaceRegistry is very slow
> ------------------------------
>
>                 Key: OAK-201
>                 URL: https://issues.apache.org/jira/browse/OAK-201
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>            Reporter: Thomas Mueller
>
> The NamespaceRegistryImpl.getURI and getPrefix are called a lot, for example by NamePathMapperImpl.getOakName. 
> The method doesn't do any caching, which is a problem because it has to read it each time from the repository. Even if it would do caching, it wouldn't help because it the method WorkspaceImpl.getNamespaceRegistry creates a new NamespaceRegistryImpl each time it is called. To allow caching of known mappings, the instance needs to be cached as well.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (OAK-201) NamespaceRegistry is very slow

Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420578#comment-13420578 ] 

Thomas Mueller commented on OAK-201:
------------------------------------

Yes, that makes sense. 

It seems sometimes a one-way conversion is needed currently, for example in NodeImpl.setPrimaryType:

    String jcrPrimaryType = sessionDelegate.getOakPathOrThrow(Property.JCR_PRIMARY_TYPE);

Property.JCR_PRIMARY_TYPE is the expanded form ("{http://...}primaryType").

I guess we could create constants with the short form ("nt:primaryType"), and then check if there are remappings. Or use a hardcoded list for known remappings (either just the prefixes or the complete names).

                
> NamespaceRegistry is very slow
> ------------------------------
>
>                 Key: OAK-201
>                 URL: https://issues.apache.org/jira/browse/OAK-201
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>            Reporter: Thomas Mueller
>
> The NamespaceRegistryImpl.getURI and getPrefix are called a lot, for example by NamePathMapperImpl.getOakName. 
> The method doesn't do any caching, which is a problem because it has to read it each time from the repository. Even if it would do caching, it wouldn't help because it the method WorkspaceImpl.getNamespaceRegistry creates a new NamespaceRegistryImpl each time it is called. To allow caching of known mappings, the instance needs to be cached as well.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (OAK-201) NamespaceRegistry is very slow

Posted by "Jukka Zitting (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420585#comment-13420585 ] 

Jukka Zitting commented on OAK-201:
-----------------------------------

bq. and not use expanded names at all here

The name mapper needs to work also with external clients that are using expanded names.

But yes, in {{oak-jcr}} we could well use the prefixed forms of the standard names to avoid even the hash table lookup.
                
> NamespaceRegistry is very slow
> ------------------------------
>
>                 Key: OAK-201
>                 URL: https://issues.apache.org/jira/browse/OAK-201
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>            Reporter: Thomas Mueller
>
> The NamespaceRegistryImpl.getURI and getPrefix are called a lot, for example by NamePathMapperImpl.getOakName. 
> The method doesn't do any caching, which is a problem because it has to read it each time from the repository. Even if it would do caching, it wouldn't help because it the method WorkspaceImpl.getNamespaceRegistry creates a new NamespaceRegistryImpl each time it is called. To allow caching of known mappings, the instance needs to be cached as well.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (OAK-201) NamespaceRegistry is very slow

Posted by "Julian Reschke (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420553#comment-13420553 ] 

Julian Reschke commented on OAK-201:
------------------------------------

bq.  The name mapper could avoid all namespace lookups as long as no session-local namespace remappings are in effect.

I can look at that optimization, but the calls might also be caused by JCR-level calls that use expanded names.

Thomas, do you have a few call stacks?
                
> NamespaceRegistry is very slow
> ------------------------------
>
>                 Key: OAK-201
>                 URL: https://issues.apache.org/jira/browse/OAK-201
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>            Reporter: Thomas Mueller
>
> The NamespaceRegistryImpl.getURI and getPrefix are called a lot, for example by NamePathMapperImpl.getOakName. 
> The method doesn't do any caching, which is a problem because it has to read it each time from the repository. Even if it would do caching, it wouldn't help because it the method WorkspaceImpl.getNamespaceRegistry creates a new NamespaceRegistryImpl each time it is called. To allow caching of known mappings, the instance needs to be cached as well.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

[jira] [Commented] (OAK-201) NamespaceRegistry is very slow

Posted by "Thomas Mueller (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/OAK-201?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13420597#comment-13420597 ] 

Thomas Mueller commented on OAK-201:
------------------------------------

A stack trace:

SessionImpl.refresh(boolean) line: 156	
WorkspaceImpl$1.refresh() line: 153	
WorkspaceImpl$1(NamespaceRegistryImpl).getURI(String) line: 162	
SessionImpl(AbstractSession).getNamespaceURI(String) line: 132	
SessionDelegate$SessionNameMapper.getOakPrefix(String) line: 453	
SessionDelegate$SessionNameMapper(AbstractNameMapper).getOakName(String) line: 61	
NamePathMapperImpl.getOakName(String) line: 46	
NodeTypeManagerImpl.getNodeType(String) line: 83	
NodeImpl.addNode(String, String) line: 217	

So for each addNode(String, String), currently there is a Session.refresh(true).
                
> NamespaceRegistry is very slow
> ------------------------------
>
>                 Key: OAK-201
>                 URL: https://issues.apache.org/jira/browse/OAK-201
>             Project: Jackrabbit Oak
>          Issue Type: Bug
>            Reporter: Thomas Mueller
>
> The NamespaceRegistryImpl.getURI and getPrefix are called a lot, for example by NamePathMapperImpl.getOakName. 
> The method doesn't do any caching, which is a problem because it has to read it each time from the repository. Even if it would do caching, it wouldn't help because it the method WorkspaceImpl.getNamespaceRegistry creates a new NamespaceRegistryImpl each time it is called. To allow caching of known mappings, the instance needs to be cached as well.

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira