How To Limiting CPU Usage of a High-Priority Process
On a multi-core CPU machine, I have a process A that is loaded with root privileges through `sudo launchctl load /Library/LaunchDaemons/com.xxx.A.plist`. This process forks another process B, which has one thread performing file traversal and four threads performing checks. When the CPU usage exceeds a certain value, the checking threads sleep for a few seconds. However, during execution, the CPU usage of process B is very high, ranging from 100% to 200%. Reducing the number of checking threads from four to one improves the CPU usage somewhat, but it still remains high, exceeding 100%.
I have tried using `renice 20`, `APPPolicy`, and `CPULimit`, but none of these measures can limit the CPU usage to a lower value, such as 50% or 30%. Is this because process B has high privileges and is protected by the system, making CPU usage limiting measures ineffective? How can I restrict the CPU usage of process B to 30% or 50%?
MacBook Air 13″, macOS 14.0