joular / joularjx

JoularJX is a Java-based agent for software power monitoring at the source code level.
https://www.noureddine.org/research/joular/joularjx
GNU General Public License v3.0
71 stars 17 forks source link

What is the unit of the value returned by Cpu.getCurrentPower? #41

Closed metacosm closed 10 months ago

metacosm commented 10 months ago

Is it mW, W, J, something else?

adelnoureddine commented 10 months ago

Hi, the power value is in Watts in Windows and on Raspberry. On Linux with RAPL, it's the energy value in Joules from RAPL readings (which by itself is meaningless as that's energy since pc start, and we use to calculate energy difference every second e2 - e1, so we can get enegy/second, thus power).

metacosm commented 10 months ago

It doesn't appear to be the case, though, as both initial and current power are measured during the same loop iteration meaning that the measurements occur in quick succession. Also, this means that every other Cpu implementations must return 0 for getInitialPower, when the Linux RAPL implementation is actually the only one that's supposed to make use of this value.

metacosm commented 10 months ago

This also means that the logic / reporting is inconsistent because the agent reports total joules being consumed while in all instances apart from RAPL/Linux, the total is actually Watts, at least, if I understand correctly.

adelnoureddine commented 10 months ago

The logic algorithm is:

The before/after energy collection is done every second, while we collect methods statistics in a smaller sampling loop with the method sample() https://github.com/joular/joularjx/blob/63f12854f616d60bddd93b9997605e7e920b82b2/src/main/java/org/noureddine/joularjx/monitor/MonitoringHandler.java#L92 Which will loop for the entire second.

Hope this clarifies our approach.