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 =
PartitionNexus nexus = ds.getPartitionNexus();
Value<?> subschemaSubentry = nexus.getRootDse( null ).get(
// Grab the SubschemaSubentry from the rootDSE, and transform it
to a Dn
Dn subschemaSubentryDn = new Dn( ds.getSchemaManager(),
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.