CPU Energy Meter: A tool for measuring energy consumption of Intel CPUs
github.com
github.com
# in milli-watt (1000 = 1W) because shell arithmetic doesn't do floating point
while true; do
LAST_MJ=$MJ
MJ=$(cat /sys/devices/virtual/powercap/intel-rapl/intel-rapl:0/energy_uj)
echo $(((MJ - LAST_MJ) / 1000))
sleep 1
done
Despite the powercap name being intel-rapl, the powercap interface is also available on AMD machines.For a more detailed reading on several more metrics about the CPU, I think pcm[1] may be a better tool (it's a successor to the Intel Power Gadget the project was forked from). Though, it only works on Intel CPU.
perf stat -e 'power/energy-pkg/' -I 1000 --interval-count 3
# time counts unit events
1.001064377 11.00 Joules power/energy-pkg/
2.002605466 10.98 Joules power/energy-pkg/
3.003726824 11.01 Joules power/energy-pkg/Power profiling is listed as supported on all CPUs though a bunch of features (including memory bandwidth, one that I had wanted) are limited to EPYC CPUs and don't exist in Ryzen or Threadripper.
https://www.kernel.org/doc/html/v5.8/hwmon/amd_energy.html
https://www.kernel.org/doc/html/v5.12/hwmon/amd_energy.html
https://www.kernel.org/doc/html/v5.13/hwmon/amd_energy.html (404)
>Long story short, since last year the AMD Energy sensor information has been limited to root due to the PLATYPUS security vulnerability. HWMON maintainer Guenter Roeck proposed slightly limiting and randomizing the sensor data so it couldn't be used for nefarious purposes but still accurate enough for genuine use-cases and no longer needing to be root-only access. However, AMD engineers didn't like that approach.
>With the hardware monitoring subsystem maintainer not wanting the information to be restricted to root-only and AMD not wanting the limiting/randomization approach, Guenter went ahead and removed the driver.
So... we're better off without having this system at all than we would be if it were limited to root OR if it were randomized? Sounds like silly kernel politicking to me. "You don't like my plan? Oh well, I guess I'll take the ball and go home, have fun losers!"
"Identifying Compiler Options to Minimise Energy Consumption for Embedded platforms"
There is also a paper about PMT: https://arxiv.org/pdf/2210.03724
For whole-node power on typical racked systems, I'd expect to interrogate the power strips or similar supplies with SNMP or otherwise.
If you are into overspending on PSUs you can get similar features in consumer PSUs, for example [1]. But at that point we have completely left the realm of "simple interface".
If you want to get a whole-system overview the PSU values are obviously better. But one of the biggest power consumer in many servers are the fans, and because they react to temperature sensors they always lag behind what's actually happening. That makes attributing a rise or fall in power tricky at sub-minute timescales. That's where CPU energy use is much more useful, even if it's a less complete picture.
1: https://www.thermaltake.com/toughpower-irgb-plus-850w-gold-t...
Why don't systems drive the fans based on the VR state instead of lagging temperature readings?
It can seem like it is a simpler method of control (why measure temperature if we don't have to?). But they were really very annoying to be around. It wasn't so bad with constant loads, but bursty dynamic loads created an audible cacophony that was very distracting.
Such a system also doesn't necessarily take into consideration other things that affect cooling performance, like ambient temperature and dust.
At least one of the problems (the annoying sounds) can theoretically be worked around by slowing down the rate at which a fan ramps up and down. But by the time that is done, fan speed is back to lagging again -- we're heading back to where we were before.
And then we still have variables like ambient temperature, dust, degraded thermal interfaces, and others to contend with.
So, the simpler method seems to be what we broadly already do today: We change fan speeds based on the temperature of the thing being cooled.
This temperature already has everything we need integrated to begin with: It includes thermal output, ambient temp, dust, old thermal goop, and everything else.
If thing is cool (for whatever reasons it is cool -- maybe it's idling in a shed in January in Minnesota), then: Fan can go slow or even turn off.
If thing is hot (for whatever reasons it is hot -- maybe it's doing real work in a shed in August in Minnesota and full of cat hair), then: Fan can go faster.
https://www.corsair.com/us/en/explorer/diy-builder/power-sup...
This was yesterday. Wild.