5 ms·
Is there a standard mechanism to measure power consumption for applications on processors?
by yalogin 5y ago
Is there a standard mechanism to measure power consumption for applications on processors?
- jeroenhd 5y agoNot really. Exact power consumption will vary wildly based on cache state, the instructions executed, the state of the branch predictor, state of the pipeline, and so forth. The best you could do is track power during the time an application is scheduled to run on the processor but even that is an approximation because the power consumption of a single core depends on the state of other cores as well. Then you get into arbitrary territory (do you count the CPU time spent inside the filesystem driver or network minifilter as application time? is all called kernel code, which may execute on another core, taken into account? what about data transfers between the CPU and GPU? what about the power spent on cooling the CPU while the code runs?) and you end up with a very arbitrary and difficult approximation. I think simpler approximations are more than enough, but it's near impossible to track power usage for a single application. Windows has such an approximation based on various factors, not just the CPU, and that's not much more than a "low-medium-high" scale.
- yalogin 5y agoThat makes sense but I see a lot of places where they estimate power consumption in W or mWs. How do they do it? Is there may be a window of estimation possible in a constrained environment? No network or file I/O I guess is all the restrictions we can put on a process without compromising functionality. Alternatively how do I measure power consumption of a random process? Assuming I only want to get a number and nothing else.
- jeroenhd 5y agoI honestly don't know how you'd get such a number. What I'd do is measure the total energy consumption for a while and divide that by the time the process had control over the CPU. Perhaps the CPU and GPU can be measured separately.
- wmf 5y agoThe processor measures it and you can use RAPL or powermetrics to read the measurement.
- yalogin 5y agoWow! Thanks. Reading through it and it makes a lot of sense. I had no idea such a thing existed till now.