Page 1 of 1

[Solved] Dynamically throttling CPU usage via command line in Linux?

Posted: Wed Nov 08, 2023 7:07 pm
by darkextratoasty
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.

Re: Dynamically throttling CPU usage via command line in Linux?

Posted: Wed Nov 08, 2023 8:55 pm
by bikeaddict
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:

Code: Select all

cpulimit -l 1600 -p $(pgrep FahCore_a)

Re: Dynamically throttling CPU usage via command line in Linux?

Posted: Wed Nov 08, 2023 9:20 pm
by darkextratoasty
Perfect, thank you for the help!

Re: [Solved] Dynamically throttling CPU usage via command line in Linux?

Posted: Sat Nov 11, 2023 8:15 pm
by toTOW
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 ... :(

Re: [Solved] Dynamically throttling CPU usage via command line in Linux?

Posted: Sat Nov 11, 2023 9:42 pm
by darkextratoasty
toTOW wrote: Sat Nov 11, 2023 8:15 pm Usually, the FAH compute core doesn't like when the number of threads is adjusted too often ... it increases the risk of loosing WUs.
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.
toTOW wrote: Sat Nov 11, 2023 8:15 pm It is also highly inefficient to run more working thread than available CPU threads ... :(
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.

Re: [Solved] Dynamically throttling CPU usage via command line in Linux?

Posted: Sat Nov 11, 2023 9:49 pm
by bikeaddict
The github project's documentation describes how cpulimit works:

https://github.com/opsengine/cpulimit
The control of the used CPU amount is done sending SIGSTOP and SIGCONT POSIX signals to processes.
It seems to pause and resume the process for short intervals.

Re: [Solved] Dynamically throttling CPU usage via command line in Linux?

Posted: Sat Nov 11, 2023 9:58 pm
by darkextratoasty
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.

Re: [Solved] Dynamically throttling CPU usage via command line in Linux?

Posted: Sat Nov 11, 2023 11:16 pm
by bikeaddict
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. :wink:

Re: [Solved] Dynamically throttling CPU usage via command line in Linux?

Posted: Wed Jan 03, 2024 6:34 am
by miczac
On a side note you also could renice the FahCore_a process.
Something like

Code: Select all

renice 19 -p $(pgrep FahCore_a)
would give it lowest priority.
HTH, Michael.