Skip to content

memberOf plugin: mbof_append_muop() optimization#8551

Merged
alexey-tikhonov merged 3 commits into
SSSD:masterfrom
alexey-tikhonov:mbof_append_muop
Mar 30, 2026
Merged

memberOf plugin: mbof_append_muop() optimization#8551
alexey-tikhonov merged 3 commits into
SSSD:masterfrom
alexey-tikhonov:mbof_append_muop

Conversation

@alexey-tikhonov

@alexey-tikhonov alexey-tikhonov commented Mar 25, 2026

Copy link
Copy Markdown
Member

Testing with a following setup: 300 subgroups that all share the same 3000 users, plus one top-level
group containing all subgroups. ignore_group_members = false

time id user with a cold cache:

(to be rebased on top of #8546)

@alexey-tikhonov alexey-tikhonov added backport-to-sssd-2-9 Performance Performance related patches labels Mar 25, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces a new inline helper function, sss_linearized_dn_match, to optimize the comparison of linearized distinguished names (DNs) within mbof_append_muop and mbof_append_addop. The new function aims to handle specific case-sensitivity rules for DNs, particularly for the 'name' attribute. However, a critical review comment points out that the current implementation's use of strcasecmp for DN comparison is incorrect and unsafe, as it fails to properly account for the complex case-insensitivity rules of DN components, potentially leading to false negatives for equivalent DNs. The reviewer suggests either reverting to ldb_dn_compare or implementing a more robust comparison logic.

Comment thread src/ldb_modules/memberof.c
@alexey-tikhonov alexey-tikhonov changed the title memberOf plugin: mbof_append_muop() optimizataion memberOf plugin: mbof_append_muop() optimization Mar 25, 2026
@alexey-tikhonov

Copy link
Copy Markdown
Member Author

/gemini review b0a82c0

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request introduces optimizations to the memberof LDB module by adding a hash table for efficient duplicate value checking and a new sss_linearized_dn_match function for improved DN comparisons. A critical issue was identified where the val_table pointer in mbof_memberuid_op might be uninitialized, potentially leading to a crash when hash_has_key() is called.

Comment thread src/ldb_modules/memberof.c
/* we already have this value, get out*/
return LDB_SUCCESS;
if (!op->val_table) {
hret = hash_create_ex(1024, &op->val_table, 0, 0, 0, 0,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SSSD code base in general inits hash table with '0', but 'memberof' plugin:

ldb_modules/memberof.c:3111:    ret = hash_create_ex(1024, &mod_ctx->igh->inherited_gh, 0, 0, 0, 0,
ldb_modules/memberof.c:4023:    ret = hash_create_ex(1024, &ctx->user_table, 0, 0, 0, 0,
ldb_modules/memberof.c:4122:    ret = hash_create_ex(1024, &ctx->group_table, 0, 0, 0, 0,

so kept 1024 for the sake of consistency.

@alexey-tikhonov
alexey-tikhonov marked this pull request as ready for review March 26, 2026 11:17
@alexey-tikhonov alexey-tikhonov added the coverity Trigger a coverity scan label Mar 26, 2026
@alexey-tikhonov
alexey-tikhonov requested a review from aplopez March 26, 2026 13:40
@alexey-tikhonov alexey-tikhonov removed the coverity Trigger a coverity scan label Mar 30, 2026

@aplopez aplopez left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Justification is the same as in 704c31d
In certain scenarios this function is a hot path and using heavy
`ldb_dn_compare()` adds unnecessary overhead.

Reviewed-by: Alejandro López <[email protected]>
Reviewed-by: Justin Stephenson <[email protected]>
Justification is the same as in 704c31d
In certain scenarios this function is a hot path and using heavy
`ldb_dn_compare()` adds unnecessary overhead.

Reviewed-by: Alejandro López <[email protected]>
Reviewed-by: Justin Stephenson <[email protected]>
Replace O(N) linear `strcmp` scan over `op->el->values[]` with O(1)
hash table lookup for duplicate name detection.

Implementation assisted-by: Claude Code (Opus 4.6)

Reviewed-by: Alejandro López <[email protected]>
Reviewed-by: Justin Stephenson <[email protected]>
@sssd-bot

Copy link
Copy Markdown
Contributor

The pull request was accepted by @aplopez with the following PR CI status:


🟢 CodeQL (success)
🟢 osh-diff-scan:fedora-rawhide-x86_64:upstream (success)
🟢 rpm-build:centos-stream-10-x86_64:upstream (success)
🟢 rpm-build:fedora-42-x86_64:upstream (success)
🟢 rpm-build:fedora-43-x86_64:upstream (success)
🟢 rpm-build:fedora-44-x86_64:upstream (success)
🟢 rpm-build:fedora-rawhide-x86_64:upstream (success)
🟢 Analyze (target) / cppcheck (success)
🟢 Build / freebsd (success)
🟢 Build / make-distcheck (success)
🟢 ci / intgcheck (centos-10) (success)
🟢 ci / intgcheck (fedora-42) (success)
🟢 ci / intgcheck (fedora-43) (success)
🟢 ci / intgcheck (fedora-44) (success)
🟢 ci / intgcheck (fedora-45) (success)
🟢 ci / prepare (success)
🟢 ci / system (centos-10) (success)
🟢 ci / system (fedora-42) (success)
🟢 ci / system (fedora-43) (success)
🟢 ci / system (fedora-44) (success)
🟢 ci / system (fedora-45) (success)
➖ Coverity scan / coverity (skipped)
🟢 Static code analysis / codeql (success)
🟢 Static code analysis / pre-commit (success)
🟢 Static code analysis / python-system-tests (success)


There are unsuccessful or unfinished checks. Make sure that the failures are not related to this pull request before merging.

@alexey-tikhonov
alexey-tikhonov merged commit 06692d5 into SSSD:master Mar 30, 2026
10 of 15 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants