Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove connection mutex contention risk on autobind #5883

Closed
progier389 opened this issue Aug 3, 2023 · 2 comments
Closed

Remove connection mutex contention risk on autobind #5883

progier389 opened this issue Aug 3, 2023 · 2 comments
Assignees
Labels
bug Something isn't working In JIRA ticket is in JIRA Need BZ The ticket needs to be cloned to a BZ
Milestone

Comments

@progier389
Copy link
Contributor

progier389 commented Aug 3, 2023

Issue Description
Code review show that c_mutex is held for a quite long period (in bind.c) while performing autobind:
When doing anonymous bind on a connection using SASL/EXTERNAL mechanism
the mutex is held during the whole lookup that maps the SSL certificate to the bind dn
but the page search issue showed that holding that c_mutex has a terrible impact on overall performance

Package Version and Platform:

  • Platform: Fedora, RHEL
  • Package and version: main branch
  • Browser [e.g. chrome, safari]

Steps to Reproduce
The steps are quite similar to the paged search result performance issue.
The trick is to enable the internal operation flags in access log and disable the standard operation, it makes the fact that the lock is held during autobind internal search very visible.

  1. Setup an instance (named standalone1) and having suffix dc=example,dc=com with default tests entries generated by dscreate"
  2. Run: dsconf standalone1 config replace nsslapd-accesslog-level=4
  3. Run: ldclt -p 389 -e esearch -b "dc=example,dc=com" -f "cn=demo"
  4. In another windows run a loop on:
    ldapsearch -Q -LLL -Y EXTERNAL -H ldapi://%2fvar%2frun%2fslapd-standalone1.socket -b dc=example,dc=com cn=demo
  5. Then you should see the ldclt performance dropping significantly:
ldclt[416127]: Average rate: 14371.20/thr  (14371.20/sec), total: 143712
ldclt[416127]: Average rate: 14527.00/thr  (14527.00/sec), total: 145270
ldclt[416127]: Average rate: 8274.10/thr  (8274.10/sec), total:  82741
ldclt[416127]: Average rate: 4551.20/thr  (4551.20/sec), total:  45512
ldclt[416127]: Average rate: 4191.30/thr  (4191.30/sec), total:  41913

Should not have a significant performance drop.

Additional context
I thought about several solutions:

  • computing the mapping out of the lock and only lock to get/data into the connection (but it only solve the autobind code)
  • split the lock between the data needed for accept and listen threads (but it impacts lots of places and so there are risks ... )
  • using try lock to acquire the lock in the listening thread and just skip the connection if the lock is busy.
    That may leads to CPU load increase (because the listening thread loops until the mutex get released but
    at least events on other connections are handled).
@progier389 progier389 added bug Something isn't working Need BZ The ticket needs to be cloned to a BZ In JIRA ticket is in JIRA labels Aug 3, 2023
@progier389 progier389 added this to the 1.4.3 milestone Aug 3, 2023
@progier389 progier389 self-assigned this Aug 3, 2023
@progier389
Copy link
Contributor Author

Jira ticket: IDMDS-3501

@progier389
Copy link
Contributor Author

599db0a Issue 5883 - Remove connection mutex contention risk on autobind (#5886)
415c748..599db0a main -> main
f01a613..837fad7 389-ds-base-2.3 -> 389-ds-base-2.3
d2af71c..efe7385 389-ds-base-2.2 -> 389-ds-base-2.2
4ba6190..561d80e 389-ds-base-2.1 -> 389-ds-base-2.1
8ac0c5d..68b3c59 389-ds-base-2.0 -> 389-ds-base-2.0
66106c8..a76bb01 389-ds-base-1.4.4 -> 389-ds-base-1.4.4
438821a..ccff99d 389-ds-base-1.4.3 -> 389-ds-base-1.4.3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working In JIRA ticket is in JIRA Need BZ The ticket needs to be cloned to a BZ
Projects
None yet
Development

No branches or pull requests

1 participant