measuring CPU utilization objectively under load

30 Views Asked by At

So I have a thread which does some work. Some of this work is optional and I would like to dynamically adjust how much work is being attempted based on CPU allocation. In other words I would want to set a configuration knob to "50% of a core" and then my thread would do enough work to keep a core busy half of the time, no more. My initial idea was to measure the cpu utilization using getrusage and increase or decrease amount of work thread is trying to do based on that. But then i realized that this is not a reliable measure because if machine gets overloaded my thread running time will drop, but increasing work in this case would not be the right thing at all. So I need a way to figure out whether the thread is trying to do too much which would not be impacted by how loaded the system as a whole is.

0

There are 0 best solutions below