Skip to content

[autobackport: sssd-2-9] Bunch of assorted perf improvements of hot path functions#8458

Merged
justin-stephenson merged 3 commits intoSSSD:sssd-2-9from
sssd-bot:SSSD-sssd-backport-pr8447-to-sssd-2-9
Feb 17, 2026
Merged

[autobackport: sssd-2-9] Bunch of assorted perf improvements of hot path functions#8458
justin-stephenson merged 3 commits intoSSSD:sssd-2-9from
sssd-bot:SSSD-sssd-backport-pr8447-to-sssd-2-9

Conversation

@sssd-bot
Copy link
Contributor

This is an automatic backport of PR#8447 Bunch of assorted perf improvements of hot path functions to branch sssd-2-9, created by @alexey-tikhonov.

Please make sure this backport is correct.

Note

The commits were cherry-picked without conflicts.

You can push changes to this pull request

git remote add sssd-bot git@github.com:sssd-bot/sssd.git
git fetch sssd-bot refs/heads/SSSD-sssd-backport-pr8447-to-sssd-2-9
git checkout SSSD-sssd-backport-pr8447-to-sssd-2-9
git push sssd-bot SSSD-sssd-backport-pr8447-to-sssd-2-9 --force

Original commits
09e283e - SDAP: use DEBUG_CONDITIONAL in hot path
9a2cf21 - UTIL: sss_tc_utf8_str_tolower() optimization
a5b77e4 - UTIL: sss_create_internal_fqname() optimization (caching)

Backported commits

  • 11a61f5 - SDAP: use DEBUG_CONDITIONAL in hot path
  • e8b53e4 - UTIL: sss_tc_utf8_str_tolower() optimization
  • 7da25e4 - UTIL: sss_create_internal_fqname() optimization (caching)

Original Pull Request Body

Those patches are based on a profiling of a following test case:

  • users tu1 and tu2 are members of 5k LDAP groups (RFC2307 case, no nested groups)
  • SSSD stared with an empty cache
  • time id tu1@ldap.test | tr ',' '\n' | wc -l is executed

(Note you need to tweak both LDAP (limits) and SSSD (timeout, client_idle_timeout) settings to make this req complete successfully).

Combined, those patches reduce lookup time on my laptom from ~51+s to ~45-s (at least with debug_microseconds = true)

Note that much more fruitful optimizations are possible under sdap_initgr_common_store(), including getting rid of O(N^2) loop over sdap_get_group_primary_name() in sdap_add_incomplete_groups(), and some of those optimization will make patches in this PR kind of obsolete for this specific test case. But given that those helpers are heavily used across all code base, I think it's still worth consideration.

Copy link

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

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 several performance improvements to hot path functions. The changes in sdap.c and sss_tc_utf8.c are good optimizations. However, the caching mechanism introduced in usertools.c for sss_create_internal_fqname has a critical thread-safety issue. It uses static variables without any locking, which can lead to race conditions in a multi-threaded environment like the SSSD backend. I've added a comment with a suggested fix.

@alexey-tikhonov alexey-tikhonov added Performance Performance related patches no-backport This should go to target branch only. Waiting for review labels Feb 17, 2026
Copy link
Contributor

@sumit-bose sumit-bose left a comment

Choose a reason for hiding this comment

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

Hi,

backport matches the original version, ACK.

bye,
Sumit

@sssd-bot
Copy link
Contributor Author

The pull request was accepted by @justin-stephenson with the following PR CI status:


🟢 CodeQL (success)
🟢 rpm-build:centos-stream-9-x86_64:upstream (success)
🟢 Build / make-distcheck (success)
🟢 ci / prepare (success)
🟡 ci / system (centos-9) (in_progress)
🟢 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.

@sssd-bot sssd-bot force-pushed the SSSD-sssd-backport-pr8447-to-sssd-2-9 branch from 7da25e4 to 350d4c6 Compare February 17, 2026 18:09
Both `perf` and manual measurement confirms ~6..8% perf gain
in the test case:
 - INITGROUPS lookup for a user that is a member of 5k groups,
   no groups were cached;
 - debug_level = 3
 - debug_microseconds = true

Note `debug_microseconds = true` - without this setting impact isn't
that dramatic.

Reviewed-by: Justin Stephenson <jstephen@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit 09e283e)
In vast majority of cases strings are ascii and lowercase.
In other cases overhead added should be negligible.

Reviewed-by: Justin Stephenson <jstephen@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit 9a2cf21)
This helper is heavily used, including in hot paths.

Since number of domains used is very limited, hash table used for caching
should be very small and lookup much more efficient as compared with
`sss_tc_utf8_str_tolower()`

Assisted-by: Claude Code (Opus 4.6)
Reviewed-by: Justin Stephenson <jstephen@redhat.com>
Reviewed-by: Sumit Bose <sbose@redhat.com>
(cherry picked from commit a5b77e4)
@sssd-bot
Copy link
Contributor Author

The pull request was accepted by @justin-stephenson with the following PR CI status:


🟢 CodeQL (success)
🟢 rpm-build:centos-stream-9-x86_64:upstream (success)
➖ Build / make-distcheck (skipped)
➖ ci / prepare (skipped)
➖ ci / system (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.

@sssd-bot sssd-bot force-pushed the SSSD-sssd-backport-pr8447-to-sssd-2-9 branch from 350d4c6 to 3fe0ec8 Compare February 17, 2026 18:25
@justin-stephenson justin-stephenson merged commit 8679758 into SSSD:sssd-2-9 Feb 17, 2026
7 of 8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Accepted no-backport This should go to target branch only. Performance Performance related patches

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants