Showing results for 
Show  only  | Search instead for 
Did you mean: 

Process CPU % is incorrect?


I'm using AppD and Oracle JDK 1.8.0_231.


I've seen some incorrect process CPU% reported by the java agent.  It appears that the number is being derived as follows:


Process CPU burnt (ms/min)/60000/Runtime.availableProcessors()


In other words, the number of milliseconds of CPU used in a minute, divided by the number of milliseconds in a minute, divided by the result of Runtime.availableProcessors().  So, if there are 4 CPUs and the "cpu burnt" number is 30000, then we'd have 30000/60000/4, which is 12.5%


However, the Runtime.availableProcessors() method doesn't always report the actual number of processors.  Instead, if -XX:ActiveProcessorCount=n is set, it uses that.  In my example, if there were actually 8 CPUs but -XX:ActiveProcessorCount=4 is set, then AppD will report 12.5% when the actual number should be 6.25% (divide by 8 instead of 4.)


The active processor count does not actually limit the number of CPUs the process can use so I think this method of calculating process CPU % fails when the active processor count is set to something other than the actual value.









You are correct that this is the method used to calculate this metric.


The net result is that it measures the CPU consumption as a percentage of the resources that the JVM user declared were allocated to the JVM, a measure that is useful to some customers, so just changing the way it is calculated is problematic.


It is possible to track the process CPU consumption vs the resources of the entire machine using the SIM agent


Does this latter method address your needs?


Warm regards,


Found something helpful? Click the Accept as Solution button to help others find answers faster.
Liked something? Click the Thumbs Up button.

The active processor count doesn't itself limit the number of CPUs the JVM can use in a general way.  Would you expect this option to only be used in combination with other features?


Here is an example of CPU usage during a load test.  Active processor count was 4 but there were 8 CPUs on the machine and you can clearly see all 8 CPUs being used equally.


8 CPUs used equally8 CPUs used equally


As it is, the calculated process CPU usage is incorrect for cases where the total CPU count is greater than the specified active processor count.