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

client: improve implementation of CPU throttling #5233

Merged
merged 3 commits into from
May 12, 2023
Merged

Conversation

davidpanderson
Copy link
Contributor

Old: if target CPU usage is (say) 1%,
we'd unthrottle, sleep 1 sec, throttle, and sleep 99 sec. A change to the usage pref wouldn't be enforced during that sleep.

New: do something every second; changes are seen immediately.

This makes a difference only when setting is very close to 0 or 100

Fixes #5231

Old: if target CPU usage is (say) 1%,
we'd unthrottle, sleep 1 sec, throttle, and sleep 99 sec.
A change to the usage pref wouldn't be enforced during that sleep.

New: do something every second; changes are seen immediately
@AenBleidd
Copy link
Member

The code looks fine to me.
@RichardHaselgrove, any chance you can test this?

@RichardHaselgrove
Copy link
Contributor

I'd say 'inconclusive'. Testing on Windows 7, I couldn't reproduce the stated problem with client 7.22.1: there didn't seem to be a delay when switching back from 1% to 100% of time. Having said that, it isn't obvious when CPU usage is paused - the task status in the Manager display (Advanced - tasks) remains as 'Running' throughout, and the only event logged is the 'Resume' (twice per task) when cpu_sched logging is enabled. The only clue is that elapsed time stops incrementing.

11/05/2023 12:21:14 | NumberFields@home | [cpu_sched] Resuming wu_sf7_DS-16x11_Grp7856971of8000000_0
11/05/2023 12:21:14 | NumberFields@home | [cpu_sched] Resuming task wu_sf7_DS-16x11_Grp7856971of8000000_0 using GetDecics version 400 (default) in slot 3
11/05/2023 12:21:14 | NumberFields@home | [cpu_sched] Resuming wu_sf7_DS-16x11_Grp7859884of8000000_0
11/05/2023 12:21:14 | NumberFields@home | [cpu_sched] Resuming task wu_sf7_DS-16x11_Grp7859884of8000000_0 using GetDecics version 400 (default) in slot 1
11/05/2023 12:21:14 | NumberFields@home | [cpu_sched] Resuming wu_sf7_DS-16x11_Grp7283016of8000000_1
11/05/2023 12:21:14 | NumberFields@home | [cpu_sched] Resuming task wu_sf7_DS-16x11_Grp7283016of8000000_1 using GetDecics version 400 (default) in slot 2
11/05/2023 12:21:14 | NumberFields@home | [cpu_sched] Resuming wu_sf7_DS-16x11_Grp7868029of8000000_0
11/05/2023 12:21:14 | NumberFields@home | [cpu_sched] Resuming task wu_sf7_DS-16x11_Grp7868029of8000000_0 using GetDecics version 400 (default) in slot 0

I switched to the artifact for this PR, with some difficulty: Windows Security Essentials flagged the client archive as a virus (Manager and apps were clean). I had to download it on a Linux machine and email it to myself ... I couldn't detect any change in behaviour between old and new.

@AenBleidd
Copy link
Member

@RichardHaselgrove, thank you for testing this.

I couldn't detect any change in behaviour between old and new.

I have asked the reported of this issue to test this on their side.

Windows Security Essentials flagged the client archive as a virus

Definitely a false positive detection. If you have any doubts - you can use this service to check any file with several endpoint security software: https://www.virustotal.com/gui/home/upload

if (limit >= 100) {
if (gstate.tasks_throttled) {
gstate.active_tasks.unsuspend_all(SUSPEND_REASON_CPU_THROTTLE);
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this need the mutex locking?

}
x -= 100;
} else {
if (!gstate.tasks_throttled) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there still a problem that changing prefs triggers a reschedule, which will resume any suspended task without resetting tasks_throttled, so we don’t get back in here even if we should?

which can run jobs that are currently throttled.
Clear the tasks_throttled flag,
so that the throttling logic can throttle these again if needed.
@davidpanderson
Copy link
Contributor Author

I think I fixed the problem Brian pointed out, and one or two others. Please test again.

@AenBleidd AenBleidd merged commit 142b211 into master May 12, 2023
@AenBleidd AenBleidd deleted the dpa_throttle3 branch August 15, 2023 09:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting preference "Use at most N % CPU time" during operation does not work reliably
4 participants