Skip to content

Commit

Permalink
Issue 6172 - RFE: improve the performance of evaluation of filter com…
Browse files Browse the repository at this point in the history
…ponent when tested against a large valueset (like group members)

Bug description:
	Before returning an entry (to a SRCH) the server checks that the entry matches the SRCH filter.
	If a filter component (equality) is testing the value (ava) against a
	large valueset (like uniquemember values), it takes a long time because
	of the large number of values and required normalization of the values.
	This can be improved taking benefit of sorted valueset. Those sorted
	valueset were created to improve updates of large valueset (groups) but
	at that time not implemented in SRCH path.

Fix description:
	In case of LDAP_FILTER_EQUALITY component, the server can get
	benefit of the sorted valuearray.
	To limit the risk of regression, we use the sorted valuearray
	only for the DN syntax attribute. Indeed the sorted valuearray was
	designed for those type of attribute.
	With those two limitations, there is no need of a toggle and
	the call to plugin_call_syntax_filter_ava can be replaced by
	a call to slapi_valueset_find.
	In both cases, sorted valueset and plugin_call_syntax_filter_ava, ava and
	values are normalized.
	In sorted valueset, the values have been normalized to insert the index
	in the sorted array and then comparison is done on normalized values.
	In plugin_call_syntax_filter_ava, all values in valuearray (of valueset) are normalized
	before comparison.

relates: 389ds#6172

Reviewed by: Pierre Rogier (Big Thanks !!!)
  • Loading branch information
tbordaz committed May 15, 2024
1 parent 884deb6 commit bf1c52d
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion ldap/servers/slapd/filterentry.c
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,29 @@ test_ava_filter(
rc = -1;
for (; a != NULL; a = a->a_next) {
if (slapi_attr_type_cmp(ava->ava_type, a->a_type, SLAPI_TYPE_CMP_SUBTYPE) == 0) {
rc = plugin_call_syntax_filter_ava(a, ftype, ava);
if ((ftype == LDAP_FILTER_EQUALITY) &&
(slapi_attr_is_dn_syntax_type(a->a_type))) {
/* This path is for a performance improvement */

/* In case of equality filter we can get benefit of the
* sorted valuearray (from valueset).
* This improvement is limited to DN syntax attributes for
* which the sorted valueset was designed.
*/
Slapi_Value *sval = NULL;
sval = slapi_value_new_berval(&ava->ava_value);
if (slapi_valueset_find((const Slapi_Attr *)a, &a->a_present_values, sval)) {
rc = 0;
}
slapi_value_free(&sval);
} else {
/* This is a fallback condition: the use of sorted valuearray
* is possibly not valid.
* It uses directly the valuearray and then have to go through
* all the values, normalize them until it matches the ava.
*/
rc = plugin_call_syntax_filter_ava(a, ftype, ava);
}
if (rc == 0) {
break;
}
Expand Down

0 comments on commit bf1c52d

Please sign in to comment.