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

Almost empty and not loaded ns-slapd high cpu load #5551

Closed
jpVm5jYYRE1VIKL opened this issue Nov 30, 2022 · 9 comments
Closed

Almost empty and not loaded ns-slapd high cpu load #5551

jpVm5jYYRE1VIKL opened this issue Nov 30, 2022 · 9 comments

Comments

@jpVm5jYYRE1VIKL
Copy link

jpVm5jYYRE1VIKL commented Nov 30, 2022

Issue Description
Almost empty and not loaded 389ds high cpu load.
Restart of container does not solve issue.
Logs does not contain any errors.

strace attached to ns-slapd show following :

clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0
clock_nanosleep(CLOCK_REALTIME, 0, {tv_sec=0, tv_nsec=1000000}, NULL) = 0

DB Monitor Report: 2022-11-30 14:33:26
--------------------------------------------------------
Database Cache:
 - Cache Hit Ratio:     86%
 - Free Space:          497.21 MB
 - Free Percentage:     100.0%
 - RO Page Drops:       0
 - Pages In:            14
 - Pages Out:           0

Normalized DN Cache:
 - Cache Hit Ratio:     86%
 - Free Space:          19.98 MB
 - Free Percentage:     99.9%
 - DN Count:            127
 - Evictions:           0

Backends:
  - dc=new,dc=com (userRoot):
    - Entry Cache Hit Ratio:        67%
    - Entry Cache Count:            10
    - Entry Cache Free Space:       1.31 GB
    - Entry Cache Free Percentage:  100.0%
    - Entry Cache Average Size:     4.39 KB
    - DN Cache Hit Ratio:           0%
    - DN Cache Count:               10
    - DN Cache Free Space:          192.0 MB
    - DN Cache Free Percentage:     100.0%
    - DN Cache Average Size:        78.0 B

Package Version and Platform:
Docker

Steps to Reproduce
Not clear.

@jpVm5jYYRE1VIKL jpVm5jYYRE1VIKL added the needs triage The issue will be triaged during scrum label Nov 30, 2022
@tbordaz tbordaz added Container upstream and removed needs triage The issue will be triaged during scrum labels Dec 7, 2022
@tbordaz tbordaz added this to the FUTURE milestone Dec 7, 2022
@jpVm5jYYRE1VIKL
Copy link
Author

I think that core of issue is : 1000000 is 0.001 of seconds . Due to it nanosleep call executes 1000 times per second and eat host cpu power. In case if nanosleep used to wait for event better to implement it using poll instead or if nanosleep critically needed then to exit from nanosleep early than timer expired need to implement signal handler. Or may be it will be good to have also a crutch solution - adjustable nanosleep delay config setting.

@Firstyear
Copy link
Contributor

@jpVm5jYYRE1VIKL Can you pinpoint which call to clock_nanosleep is causing this? A stack trace or similar? That would really help.

@obaterspok
Copy link
Contributor

It's fixed by this: #5813
That will lower the cpu usage but there are still places where I assume we could sleep more

obaterspok added a commit to obaterspok/389-ds-base that referenced this issue Jun 28, 2023
Description: This lowers the cpu usage on the ns-slapd process on a idle system from ~ 7% to 5%

relates: 389ds#5551
@mreynolds389
Copy link
Contributor

@obaterspok - you didn't have to close the PR :-) We just wanted you to update the commit. Could file it again? Or are you still working on it?

@obaterspok
Copy link
Contributor

@mreynolds389 - I'm sorry, I took a shortcut with the PR as I just edited the code directly on github and I just couldn't figure out how I would squash it. Therefor I have cloned it now and will resend it shortly

btw, do you want it as usleep(500 * 1000); or as DS_Sleep(PR_MillisecondsToInterval(500));?

@mreynolds389
Copy link
Contributor

@mreynolds389 - I'm sorry, I took a shortcut with the PR as I just edited the code directly on github and I just couldn't figure out how I would squash it. Therefor I have cloned it now and will resend it shortly

btw, do you want it as usleep(500 * 1000); or as DS_Sleep(PR_MillisecondsToInterval(500));?

Hmm, it doesn't really matter. Well we don't use usleep anywhere else in the code, but for consistency I guess use the DS_Sleep() function.

obaterspok added a commit to obaterspok/389-ds-base that referenced this issue Jun 29, 2023
Bug Description: stracing the ns-slapd process one can see nanosleep gets called a lot as we only sleep for 1ms

Fix Description: Increasing the sleep time from 1ms to 500ms and the cpu usage will drop drop a few percent and strace will be more usable

relates: 389ds#5551

Reviewd by: @mreynolds389
@obaterspok
Copy link
Contributor

obaterspok commented Jun 29, 2023

I kept usleep as it was quite convenient due to nanosleep output in the strace instead of pselect. Hope it was okay

mreynolds389 pushed a commit that referenced this issue Jun 29, 2023
Bug Description: stracing the ns-slapd process one can see nanosleep gets called a lot as we only sleep for 1ms

Fix Description: Increasing the sleep time from 1ms to 500ms and the cpu usage will drop drop a few percent and strace will be more usable

relates: #5551

Reviewd by: @mreynolds389
mreynolds389 pushed a commit that referenced this issue Jun 29, 2023
Bug Description: stracing the ns-slapd process one can see nanosleep gets called a lot as we only sleep for 1ms

Fix Description: Increasing the sleep time from 1ms to 500ms and the cpu usage will drop drop a few percent and strace will be more usable

relates: #5551

Reviewd by: @mreynolds389
mreynolds389 pushed a commit that referenced this issue Jun 29, 2023
Bug Description: stracing the ns-slapd process one can see nanosleep gets called a lot as we only sleep for 1ms

Fix Description: Increasing the sleep time from 1ms to 500ms and the cpu usage will drop drop a few percent and strace will be more usable

relates: #5551

Reviewd by: @mreynolds389
@mreynolds389
Copy link
Contributor

642760b..a9f687e 389-ds-base-2.3 -> 389-ds-base-2.3
e8114bc..fdce42d 389-ds-base-2.2 -> 389-ds-base-2.2

Thanks for the contribution @obaterspok !

@mreynolds389
Copy link
Contributor

I kept usleep as it was quite convenient due to nanosleep output in the strace instead of pselect. Hope it was okay

Sounds like a perfect reason to keep it, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants