directory-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Pierre-Arnaud Marcelot ...@marcelot.net>
Subject Re: Slight possible improvement in the search operation
Date Thu, 01 Aug 2013 12:02:53 GMT
+1 as well.

Regards,
Pierre-Arnaud

On 31 juil. 2013, at 22:29, Kiran Ayyagari <kayyagari@apache.org> wrote:

> without further ado, my +1
> 
> 
> On Thu, Aug 1, 2013 at 1:47 AM, Emmanuel L├ęcharny <elecharny@gmail.com> wrote:
> Hi guys,
> 
> I have done some profiling on the search operation, and I have found
> that for each processed search, we call the modifyFilter() operation,
> which tries to optimize the filter. In this method, we check if the
> search is done on the SubSchema Subentry. To do that, we get the rootDSE
> from the Nexus, and get the SubschemaSubentry Dn :
> 
>     private boolean isSubSchemaSubEntrySearch( LdapSession session,
> SearchRequest req ) throws Exception
>     {
>         Dn base = req.getBase();
>         String baseNormForm = ( base.isSchemaAware() ?
> base.getNormName() : base.getNormName() );
> 
>         // get the rootDSE from the nexus
>         DirectoryService ds =
> session.getCoreSession().getDirectoryService();
>         PartitionNexus nexus = ds.getPartitionNexus();
> 
>         Value<?> subschemaSubentry = nexus.getRootDse( null ).get(
> SchemaConstants.SUBSCHEMA_SUBENTRY_AT ).get();
> 
>         // Grab the SubschemaSubentry from the rootDSE, and transform it
> to a Dn
>         Dn subschemaSubentryDn = new Dn( ds.getSchemaManager(),
> subschemaSubentry.getString() );
> 
>         String subschemaSubentryDnNorm = subschemaSubentryDn.getNormName();
> 
>         return subschemaSubentryDnNorm.equals( baseNormForm );
>     }
> 
> The two commented operations are extremely costly :
> - we clone the root DSE just to get one single attrinbute from it
> - and we parse a DN which is not lakely to change, ever.
> 
> We could most certainly spare us the CPU to do those two operations. The
> RootDSE is initialized once when we start the server, and never updated
> later, so the getRootDSE() method could perfectly be returned as is (and
> duringthe initialization, we can encapsulate the rootDse in a
> ImmutableEntry to protect it against any modification.
> 
> The very same for the subschemaSubentry DN : we could store a pre-parsed
> version of it in the rootDSE, to avoid a parsing every time we do a search.
> 
> The gain would be around 8%, per the proviling session I have conducted.
> 
> --
> Regards,
> Cordialement,
> Emmanuel L├ęcharny
> www.iktek.com
> 
> 
> 
> 
> -- 
> Kiran Ayyagari
> http://keydap.com


Mime
View raw message