memberOf plugin :: mbof_add_operation() optimizations#8464
memberOf plugin :: mbof_add_operation() optimizations#8464alexey-tikhonov merged 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, |
caa7cb4 to
63a748e
Compare
|
(rebased) |
63a748e to
0a11304
Compare
|
Thank you.
I have implemented this. |
0a11304 to
0d0b73b
Compare
ikerexxe
left a comment
There was a problem hiding this comment.
LGTM!
Codewise looks solid. I’ve focused on the implementation details and am relying on the test cases Alexey highlighted to confirm the improvement
sumit-bose
left a comment
There was a problem hiding this comment.
Hi,
thank you for the improvements, ACK.
bye,
Sumit
'msg->dn' (== 'addop->entry_dn') is already filtered out from 'parents->dns[i]' at the beginning of `mbof_add_operation()` Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com> Reviewed-by: Sumit Bose <sbose@redhat.com>
when removing a duplicate. DNs order doesn't matter. Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com> Reviewed-by: Sumit Bose <sbose@redhat.com>
`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. Reviewed-by: Iker Pedrosa <ipedrosa@redhat.com> Reviewed-by: Sumit Bose <sbose@redhat.com>
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 tu1@ldap.test | tr ',' '\n' | wc -land thentime id tu2@ldap.test | 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.