Java (Java Agent, Installation, JVM, and Controller Installation)

Showing results for 
Search instead for 
Did you mean: 

Process CPU % is incorrect?


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.





Tags (2)
Process CPU % is incorrect?