memberOf plugin :: mbof_add_operation() optimizations#8464
memberOf plugin :: mbof_add_operation() optimizations#8464alexey-tikhonov wants to merge 3 commits intoSSSD:masterfrom
Conversation
9b17f9b to
e35eab4
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces several optimizations to the mbof_add_operation() function in the memberof plugin. The changes include a more efficient way to remove duplicate entries from an array and the removal of a redundant check, both of which are good improvements. However, one of the optimizations replaces ldb_dn_compare() with strcmp() for checking DN equality. This is a critical issue as strcmp() performs a case-sensitive comparison, which is incorrect for DNs and can lead to failing to detect duplicates. This could cause data inconsistencies by allowing duplicate memberof values. I have added a review comment with a suggestion to fix this.
09e7d3d to
f363d76
Compare
91810e2 to
4036bfc
Compare
|
(rebased) |
4036bfc to
caa7cb4
Compare
|
Replaced If I read -- |
|
Hi, about and this is only true for the which is because of https://github.com/SSSD/sssd/blob/master/src/db/sysdb_private.h#L58. For Long story short, since the cache handles the HTH bye, |
'msg->dn' (== 'addop->entry_dn') is already filtered out from 'parents->dns[i]' at the beginning of `mbof_add_operation()`
when removing a duplicate. DNs order doesn't matter.
caa7cb4 to
63a748e
Compare
|
(rebased) |
`ldb_dn_compare()` here is heavy because when DNs are not equal (vast majority of cases), it performs `ldb_dn_casefold_internal()` to return -1 or 1, but it's not important in this context. Note that in general using `str*cmp()` instead of `ldb_dn_get_linearized()` might yield incorrect results due to different DN representations. But since all 'memberof' DNs originate from sysdb cache / memberof plugin itself, it should be safe replacement in this context.
63a748e to
0a11304
Compare
|
Thank you.
I have implemented this. |
Using the same test case as described in #8454 and testing on top of that PR:
tu1andtu2are members of the same 5k LDAP groups (RFC2307 case, no nested groups)time id [email protected] | tr ',' '\n' | wc -land thentime id [email protected] | tr ',' '\n' | wc -lare executedThis patch set reduces time spent by
id tu1from 27 to 8 seconds and by consequentid tu2from 23 to 5 seconds on my laptop.