[Solved] Dynamically throttling CPU usage via command line in Linux?
Moderators: Site Moderators, FAHC Science Team
-
- Posts: 4
- Joined: Wed Nov 08, 2023 6:53 pm
[Solved] Dynamically throttling CPU usage via command line in Linux?
Is there a scriptable command that can be used to adjust the total CPU usage that fah consumes? Either by adjusting the number of CPU cores that fah utilizes, or by adjusting a CPU usage cap? I'm looking to automate the total CPU usage of a system through scripting, and it would be very convenient if fah has some built in way of adjusting its usage.
Last edited by darkextratoasty on Wed Nov 08, 2023 9:20 pm, edited 1 time in total.
-
- Posts: 210
- Joined: Sun May 03, 2020 1:20 am
Re: Dynamically throttling CPU usage via command line in Linux?
The cpulimit command can restrict CPU use by percentage. It might also be possible using cgroups, but I haven't tested that.
Example to limit to 50% CPU on a 32-thread system:
Example to limit to 50% CPU on a 32-thread system:
Code: Select all
cpulimit -l 1600 -p $(pgrep FahCore_a)
-
- Posts: 4
- Joined: Wed Nov 08, 2023 6:53 pm
Re: Dynamically throttling CPU usage via command line in Linux?
Perfect, thank you for the help!
-
- Site Moderator
- Posts: 6359
- Joined: Sun Dec 02, 2007 10:38 am
- Location: Bordeaux, France
- Contact:
Re: [Solved] Dynamically throttling CPU usage via command line in Linux?
Usually, the FAH compute core doesn't like when the number of threads is adjusted too often ... it increases the risk of loosing WUs.
It is also highly inefficient to run more working thread than available CPU threads ...
It is also highly inefficient to run more working thread than available CPU threads ...
-
- Posts: 4
- Joined: Wed Nov 08, 2023 6:53 pm
Re: [Solved] Dynamically throttling CPU usage via command line in Linux?
What would be considered 'too often'? Every 15 minutes, every hour, every 8 hours? Being about to dynamically adjust the workload is a hard requirement for me, so if doing so with fah is going to ruin my ability to complete WUs, I might have to find a different program to run.
Can you elaborate on this a bit more in relation to the 'cpulimit' command? Does the cpulimit command work by starting an stopping work threads and using it poses a risk of starting more work threads than there are CPU threads? I'm a bit lost as to where your comment connects to the topic at hand.
-
- Posts: 210
- Joined: Sun May 03, 2020 1:20 am
Re: [Solved] Dynamically throttling CPU usage via command line in Linux?
The github project's documentation describes how cpulimit works:
https://github.com/opsengine/cpulimit
https://github.com/opsengine/cpulimit
It seems to pause and resume the process for short intervals.The control of the used CPU amount is done sending SIGSTOP and SIGCONT POSIX signals to processes.
-
- Posts: 4
- Joined: Wed Nov 08, 2023 6:53 pm
Re: [Solved] Dynamically throttling CPU usage via command line in Linux?
So what exactly does that mean for my application? Does using the cpulimit command break fah or is it perfectly fine to use or...? Sorry I'm very new to all this and I don't really understand how any of this, aside from the first comment, is relevant.
-
- Posts: 210
- Joined: Sun May 03, 2020 1:20 am
Re: [Solved] Dynamically throttling CPU usage via command line in Linux?
I haven't used cpulimit on the folding app other than testing it briefly to see that is appeared to work as expected. So I don't know if it causes any problems with long term use. I think you should test it and report back.
Re: [Solved] Dynamically throttling CPU usage via command line in Linux?
On a side note you also could renice the FahCore_a process.
Something like would give it lowest priority.
HTH, Michael.
Something like
Code: Select all
renice 19 -p $(pgrep FahCore_a)
HTH, Michael.