{"id":3107,"date":"2015-08-26T10:30:12","date_gmt":"2015-08-25T23:30:12","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=3107"},"modified":"2015-08-27T12:02:22","modified_gmt":"2015-08-27T01:02:22","slug":"what-does-the-os-x-activity-monitors-energy-impact-actually-measure","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2015\/08\/26\/what-does-the-os-x-activity-monitors-energy-impact-actually-measure\/","title":{"rendered":"What does the OS X Activity Monitor&#8217;s &#8220;Energy Impact&#8221; actually measure?"},"content":{"rendered":"<p>[<strong>Update<\/strong>: this post has been updated with significant new information. Look to the end.]<\/p>\n<p><a href=\"https:\/\/support.apple.com\/en-au\/HT201464\">Activity Monitor<\/a> is a tool in Mac OS X that shows a variety of real-time process measurements. It is well-known and its &#8220;Energy Impact&#8221; measure (which was added in Mac OS X 10.9) is often consulted by users to compare the power consumption of different programs. <a class=\"external external-icon\" href=\"https:\/\/support.apple.com\/en-au\/HT202776\">Apple support documentation<\/a> specifically recommends it for troubleshooting battery life problems, as do countless articles on the web.<\/p>\n<p>However, despite its prominence, the exact meaning of the &#8220;Energy Impact&#8221; measure is unclear. In this blog post I use a combination of code inspection, measurements, and educated guesses to hypothesize how it is computed in Mac OS X 10.9 and 10.10.<\/p>\n<h3>What is known about &#8220;Energy Impact&#8221;?<\/h3>\n<p>The following screenshot shows the Activity Monitor&#8217;s &#8220;Energy&#8221; tab.<\/p>\n<p><img decoding=\"async\" src=\"https:\/\/mdn.mozillademos.org\/files\/11361\/ActMon-Energy.png\" alt=\"\" \/>There are no units given for &#8220;Energy Impact&#8221; or &#8220;Avg Energy Impact&#8221;.<\/p>\n<p>The <a href=\"https:\/\/support.apple.com\/en-au\/HT201464\">Activity Monitor documentation<\/a> says the following.<\/p>\n<blockquote><p>Energy Impact: A relative measure of the current energy consumption of the app. Lower numbers are better.<\/p><\/blockquote>\n<blockquote><p>Avg Energy Impact: The average energy impact for the past 8 hours or since the Mac started up, whichever is shorter.<\/p><\/blockquote>\n<p>That is vague. <a class=\"external external-icon\" href=\"https:\/\/support.apple.com\/en-au\/HT202776\">Other Apple documentation<\/a> says the following.<\/p>\n<blockquote><p>The Energy tab\u00a0of Activity Monitor displays the Energy Impact of each open app based on a number of factors including CPU usage, network traffic, disk activity and more. The higher the number, the more impact an app has on battery power.<\/p><\/blockquote>\n<p>More detail, but still vague. Enough so that <a href=\"http:\/\/apple.stackexchange.com\/questions\/107167\/what-do-the-energy-impact-numbers-displayed-in-the-new-osx-10-9-mean-and-how-a\">various<\/a> other\u00a0 <a href=\"http:\/\/apple.stackexchange.com\/questions\/96186\/how-does-apple-calculate-the-energy-consumption-of-a-process-in-os-x-mavericks\">people<\/a> have <a href=\"http:\/\/apple.stackexchange.com\/questions\/143733\/what-unit-does-the-activity-monitor-use-in-the-energy-tab\">wondered<\/a> what it <a href=\"http:\/\/www.quora.com\/What-is-the-Energy-Impact-in-OS-X-Mavericks-based-on\">means<\/a>. The <a href=\"http:\/\/forums.macrumors.com\/threads\/the-new-energy-tab-in-activity-monitor.1602748\/\">most precise description<\/a> I have found says the following.<\/p>\n<blockquote><p>If my recollection of the developer presentation slide on App Nap is correct, they are an abstract unit Apple created to represent several factors related to energy usage meant to compare programs relatively.<\/p>\n<p>I don&#8217;t believe you can directly relate them to one simple unit, because they are from an arbitrary formula of multiple factors.<\/p>\n<p>[&#8230;] To get the units they look at CPU usage, interrupts, and wakeups&#8230; track those using counters and apply that to the energy column as a relative measure of an app.<\/p><\/blockquote>\n<p>This sounds plausible, and we will soon see that it appears to be close to the truth.<\/p>\n<h3>A detour: <code>top<\/code><\/h3>\n<p>First, a necessary detour<code><\/code>. <code>top<\/code> is a program that is similar to Activity Monitor, but it runs from the command-line. Like Activity Monitor, <code>top<\/code> performs periodic measurements of many different things, including several that are relevant to power consumption: CPU usage, wakeups, and a &#8220;power&#8221; measure. To see all these together, invoke it as follows.<\/p>\n<pre class=\" language-html\" data-number=\"\"><code class=\" language-html\">top -stats pid,command,cpu,idlew,power -o power -d<\/code><\/pre>\n<p>(A non-default invocation is necessary because the wakeups and power columns aren&#8217;t shown by default unless you have an extremely wide screen.)<\/p>\n<p>It will show real-time data, updated once per second, like the following.<\/p>\n<pre class=\" language-html\" data-number=\"\"><code class=\" language-html\">PID            COMMAND                  %CPU         IDLEW        POWER\r\n50300          firefox                  12.9         278          26.6\r\n76256          plugin-container         3.4          159          11.3\r\n151            coreaudiod               0.9          68           4.3\r\n76505          top                      1.5          1            1.6 \r\n76354          Activity Monitor         1.0          0            1.0<\/code><\/pre>\n<p>The PID, COMMAND and %CPU columns are self-explanatory.<\/p>\n<p>The IDLEW column is the number of <em>package idle exit wakeups<\/em>. These occur when the processor package (containing the cores, GPU, caches, etc.) transitions from a low-power idle state to the active state. This happens when the OS schedules a process to run due to some kind of event. Common causes of wakeups include scheduled timers going off and blocked I\/O system calls receiving data.<\/p>\n<p>What about the POWER column? <code>top<\/code> is open source, so its meaning can be determined conclusively by reading the <code>powerscore_insert_cell<\/code> function in the <a class=\"external external-icon\" href=\"http:\/\/opensource.apple.com\/source\/top\/top-89.1.2\/power.c\">source code<\/a>. (The POWER measure was added to <code>top<\/code> in OS X 10.9.0 and the code has remain unchanged all the way through to OS X 10.10.2, which is the most recent version for which the code is available.)<\/p>\n<p>The following is a summary of what the code does, and it&#8217;s easier to understand if the %CPU and POWER computations are shown side-by-side.<\/p>\n<pre class=\" language-html\" data-number=\"\"><code class=\" language-html\">|elapsed_us| is the length of the sample period\r\n|used_us| is the time this process was running during the sample period\r\n\r\n  %CPU = (used_us * 100.0) \/ elapsed_us\r\n\r\n  POWER = if is_a_kernel_process()\r\n            0\r\n          else\r\n            ((used_us + IDLEW * 500) * 100.0) \/ elapsed_us\r\n          \r\n<\/code><\/pre>\n<p>The %CPU computation is as expected.<\/p>\n<p>The POWER computation is a function of CPU and IDLEW. It&#8217;s basically the same as %CPU but with a &#8220;tax&#8221; of 500 microseconds for each wakeup and an exception for kernel processes. The value of this function can easily exceed 100 &#8212; e.g. a program with zero CPU usage and 3,000 wakeups per second will have a POWER score of 150 &#8212; so it is not a percentage. In fact, POWER is a unitless measure because it is a semi-arbitrary combination of two measures with incompatible units.<\/p>\n<h3>Back to Activity Monitor and &#8220;Energy Impact&#8221;<\/h3>\n<h4>MacBook Pro running Mac OS X 10.9.5<\/h4>\n<p>First, I did some measurements with a MacBook Pro with an i7-4960HQ processor running Mac OS X 10.9.5.<\/p>\n<p>I did extensive testing with a range of programs: ones that trigger 100% CPU usage; ones that trigger controllable numbers of idle wakeups; ones that stress the memory system heavily; ones that perform frequent disk operations; and ones that perform frequent network operations.<\/p>\n<p><strong>In every case, Activity Monitor&#8217;s &#8220;Energy Impact&#8221; was the same as <code>top<\/code>&#8216;s POWER measure. Every indication is that the two are computed identically on this machine.<\/strong><code><\/code><\/p>\n<p>For example, consider the data in the following table,\u00a0 The data was gathered with a <a href=\"https:\/\/gist.github.com\/nnethercote\/11ab3290006c095159bc\">small test program<\/a> that fires a timer N times per second; other than extreme cases (see below) each timer firing causes an idle platform wakeup.<\/p>\n<pre class=\" language-html\" data-number=\"\">-----------------------------------------------------------------------------\r\nHz     CPU ms\/s   Intr        Pkg Idle   Pkg Power  Act.Mon. top\r\n-----------------------------------------------------------------------------\r\n     2     0.14        2.00       1.80     2.30W     0.1    0.1\r\n   100     4.52      100.13      95.14     3.29W       5      5\r\n   500     9.26      499.66     483.87     3.50W      25     25\r\n  1000    19.89     1000.15     978.77     5.23W      50     50\r\n  5000    17.87     4993.10    4907.54    14.50W     240    240\r\n 10000    32.63     9976.38    9194.70    17.61W     485    480\r\n 20000    66.66    19970.95   17849.55    21.81W     910    910\r\n 30000    99.62    28332.79   25899.13    23.89W    1300   1300\r\n 40000   132.08    37255.47   33070.19    24.43W    1610   1650\r\n 50000   160.79    46170.83   42665.61    27.31W    2100   2100\r\n 60000   281.19    58871.47   32062.39    29.92W    1600   1650\r\n 70000   276.43    67023.00   14782.03    31.86W     780    750\r\n 80000   304.16    81624.60     258.22    35.72W      43     45\r\n 90000   333.20    90100.26     153.13    37.93W      40     42\r\n100000   363.94    98789.49      44.18    39.31W      38     38\r\n<\/pre>\n<p>The table shows a variety of measurements for this program for different values of N. Columns 2&#8211;5 are from <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/Performance\/powermetrics\">powermetrics<\/a>, and show CPU usage, interrupt frequency, and package idle wakeup frequency, respectively. Column 6 is Activity Monitor&#8217;s &#8220;Energy Impact&#8221;, and column 7 is <code>top<\/code>&#8216;s POWER measurement. Column 6 and 7 (which are approximate measurements) are identical, modulo small variations due to the noisiness of these measurements.<\/p>\n<h4>MacBook Air running Mac OS X 10.10.4<\/h4>\n<p>I also tested a MacBook Air with an i5-4250U processor running Mac OS X 10.10.4. The results were substantially different.<\/p>\n<pre>-----------------------------------------------------------------------------\r\nHz\u00a0\u00a0\u00a0\u00a0 CPU ms\/s\u00a0\u00a0 Intr\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Pkg Idle\u00a0\u00a0 Pkg Power Act.Mon. top\r\n-----------------------------------------------------------------------------\r\n\u00a0\u00a0\u00a0\u00a0 2\u00a0\u00a0\u00a0\u00a0 0.21\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2.00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2.00\u00a0\u00a0\u00a0\u00a0 0.63W\u00a0\u00a0 0.0\u00a0\u00a0\u00a0  0.1\r\n\u00a0\u00a0 100\u00a0\u00a0\u00a0\u00a0 6.75\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 99.29\u00a0\u00a0\u00a0\u00a0\u00a0 96.69\u00a0\u00a0\u00a0\u00a0 0.81W\u00a0\u00a0 2.4\u00a0\u00a0\u00a0  5.2\r\n\u00a0\u00a0 500\u00a0\u00a0\u00a0 22.52\u00a0\u00a0\u00a0\u00a0\u00a0 499.40\u00a0\u00a0\u00a0\u00a0 475.04\u00a0\u00a0\u00a0\u00a0 1.15W\u00a0\u00a0 10\u00a0\u00a0\u00a0\u00a0   25\r\n\u00a0 1000\u00a0\u00a0\u00a0 44.07\u00a0\u00a0\u00a0\u00a0\u00a0 998.93\u00a0\u00a0\u00a0\u00a0 960.59\u00a0\u00a0\u00a0\u00a0 1.67W\u00a0\u00a0 21\u00a0\u00a0\u00a0\u00a0   48\r\n\u00a0 3000\u00a0\u00a0 109.71\u00a0\u00a0\u00a0\u00a0 3001.05\u00a0\u00a0\u00a0 2917.54\u00a0\u00a0\u00a0\u00a0 3.80W\u00a0\u00a0 60\u00a0\u00a0\u00a0   145\r\n\u00a0 5000\u00a0\u00a0\u00a0 65.02\u00a0\u00a0\u00a0\u00a0 4996.13\u00a0\u00a0\u00a0 4781.43\u00a0\u00a0\u00a0\u00a0 3.79W\u00a0\u00a0 90\u00a0\u00a0\u00a0   230\r\n\u00a0 7500\u00a0\u00a0 107.53\u00a0\u00a0\u00a0\u00a0 7483.57\u00a0\u00a0\u00a0 7083.90\u00a0\u00a0\u00a0\u00a0 4.31W\u00a0\u00a0 140\u00a0\u00a0\u00a0  350\r\n\u00a010000\u00a0\u00a0 144.00\u00a0\u00a0\u00a0\u00a0 9981.25\u00a0\u00a0\u00a0 9381.06\u00a0\u00a0\u00a0\u00a0 4.37W\u00a0\u00a0 190\u00a0\u00a0\u00a0  460<\/pre>\n<p>The results from <code>top<\/code> are very similar to those from the other machine. But Activity Monitor&#8217;s &#8220;Energy Impact&#8221; no longer matches <code>top<\/code>&#8216;s POWER measure. As a result it is much harder to say with confidence what &#8220;Energy Impact&#8221; represents on this machine. I tried tweaking the previous formula so that the idle wakeup &#8220;tax&#8221; drops from 500 microseconds to 180 or 200 microseconds and that gives results that appear to be in the ballpark but don&#8217;t match exactly. I&#8217;m a bit skeptical whether Activity Monitor is doing all its measurements at the same time or not. But it&#8217;s also quite possible that other inputs have been added to the function that computes &#8220;Energy Impact&#8221;.<\/p>\n<h3>What about &#8220;Avg Energy Impact&#8221;?<\/h3>\n<p>What about the &#8220;Avg Energy Impact&#8221;? It seems reasonable to assume it is computed in the same way as &#8220;Energy Impact&#8221;, but averaged over a longer period. In fact, we already know that period from the Apple documentation that says it is the &#8220;average energy impact for the past 8 hours or since the Mac started up, whichever is shorter.&#8221;<\/p>\n<p>Indeed, when the Energy tab of Activity Monitor is first opened, the &#8220;Avg Energy Impact&#8221; column is empty and the title bar says &#8220;Activity Monitor (Processing&#8230;)&#8221;. After a few seconds the &#8220;Avg Energy Impact&#8221; column is populated with values and the title bar changes to &#8220;Activity Monitor (Applications in last 8 hours)&#8221;. If you have <code>top<\/code> open during those 5&#8211;10 seconds can you see that <code>systemstats<\/code> is running and using a lot of CPU, and so presumably the measurements are obtained from it.<\/p>\n<p><code>systemstats<\/code> is a program that runs all the time and periodically measures, among other things, CPU usage and idle wakeups for each running process (visible in the &#8220;Processes&#8221; section of its output.) I&#8217;ve done further tests that indicate that the &#8220;Avg Energy Impact&#8221; is almost certainly computed using the same formula as &#8220;Energy Impact&#8221;. The difference is that the the measurements are from the past 8 hours of wake time &#8212; i.e. if a laptop is closed for several hours and then reopened, those hours are not included in the calculation &#8212; as opposed to the 1, 2 or 5 seconds of wake time used for &#8220;Energy Impact&#8221;.<\/p>\n<h3>battery status menu<\/h3>\n<p>Even more prominent than Activity Monitor is OS X&#8217;s battery status menu. When you click on the battery icon in the OS X menu bar you get a drop-down menu which includes a list of &#8220;Apps Using Significant Energy&#8221;.<\/p>\n<p><a href=\"https:\/\/blog.mozilla.org\/nnethercote\/files\/2015\/08\/battery-status-menu.png\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-3108 size-full\" src=\"https:\/\/blog.mozilla.org\/nnethercote\/files\/2015\/08\/battery-status-menu.png\" alt=\"Screenshot of the OS X battery status menu\" width=\"286\" height=\"186\" srcset=\"https:\/\/blog.mozilla.org\/nnethercote\/files\/2015\/08\/battery-status-menu.png 286w, https:\/\/blog.mozilla.org\/nnethercote\/files\/2015\/08\/battery-status-menu-252x164.png 252w\" sizes=\"(max-width: 286px) 100vw, 286px\" \/><\/a><\/p>\n<p>How is this determined? When you open this menu for the first time in a while it says &#8220;Collecting Power Usage Information&#8221; for a few seconds, and if you have <code>top<\/code> open during that time you see that, once again, <code>systemstats<\/code> is running and using a lot of CPU. Furthermore, if you click on an application name in the menu Activity Monitor will be opened and that application&#8217;s entry will be highlighted. Based on these facts it seems reasonable to assume that &#8220;Energy Impact&#8221; is again being used to determine which applications show up in the battery status menu.<\/p>\n<p>I did some more tests (on my MacBook Pro running 10.9.5) and it appears that once an energy-intensive application is started it takes about 20 or 30 seconds for it to show up in the battery status menu. And once the application stops using high amounts of energy I&#8217;ve seen it take between 4 and 10 minutes to disappear. The exception is if the application is closed, in which case it disappears immediately.<\/p>\n<p>Finally, I tried to determine the significance threshold. It appears that a program with an &#8220;Energy Impact&#8221; of roughly 20 or more will eventually show up as significant, and programs that have much higher &#8220;Energy Impact&#8221; values tend to show up more quickly.<\/p>\n<p>All of these battery status menu observations are difficult to make reliably and so should be treated with caution. They may also be different in OS X 10.10. It is clear, however, that the window used by the battery status menu is measured in seconds or minutes, which is much less than the 8 hour window used for &#8220;Avg Energy Impact&#8221;.<\/p>\n<p>An aside: <code>systemstats<\/code> is always running on OS X. The particular invocation used for the long-running instance &#8212; the one used by both Activity Monitor and the battery status menu &#8212; takes the undocumented <code>--xpc<\/code> flag. When I tried running it with that flag I got an error message saying &#8220;This mode should only be invoked by launchd&#8221;. So it&#8217;s hard to know how often it&#8217;s making measurements. The output from vanilla command-line invocations indicate it&#8217;s about every 10 minutes.<\/p>\n<p>But it&#8217;s worth noting that <code>systemstats<\/code> has a <code>-J<\/code> option which causes the CPU usage and wakeups for child processes to be attributed to their parents. It seems likely that the <code>--xpc<\/code> option triggers the same behaviour because the Activity Monitor does not show &#8220;Avg Energy Impact&#8221; for child processes (as can be seen in the screenshot above for the <code>login<\/code>, <code>bash<\/code> and <code>vim<\/code> processes that are children of the Terminal process). This hypothesis also matches up with the battery status menu, which never shows child processes. One consequence of this is that if you ssh into a Mac and run a power-intensive program from the command line it will not show up in Activity Monitor&#8217;s energy tab or the battery status menu, because it&#8217;s not attributable to a top-level process such as Terminal! Such processes will show up in <code>top<\/code> and in Activity Monitor&#8217;s CPU tab, however.<\/p>\n<h3>How good a measure is &#8220;Energy Impact&#8221;?<\/h3>\n<p>We&#8217;ve now seen that &#8220;Energy Impact&#8221; is used widely throughout OS X. How good a measure is it?<\/p>\n<p>The best way to measure power consumption is to actually measure power consumption. One way to do this is to use an ammeter, but this is difficult. Another way is to measure how long it takes for the battery to drain, which is easier but slow and requires steady workloads. Alternatively, recent Intel hardware provides <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Mozilla\/Performance\/Power_profiling_overview#Power_estimates\">high-quality estimates of processor and memory power consumption<\/a> that are relatively easy to obtain.<\/p>\n<p>These approaches all have the virtue of measuring or estimating actual power consumption (i.e. Watts). But the big problem is that they are machine-wide measures that cannot be used on a per-process basis. This is why Activity Monitor uses several <em>proxy<\/em> measures &#8212; ones that correlate with power consumption &#8212; which <em>can<\/em> be measured on a per-process basis. &#8220;Energy Impact&#8221; is a hybrid of at least two different proxy measures: CPU usage and wakeup frequency.<\/p>\n<p>The main problem with this is that &#8220;Energy Impact&#8221; is an exaggerated measure. Look at the first table above, with data from the 10.9.5 machine. The variation in the &#8220;Pkg Power&#8221; column &#8212; which shows the package power from the above-mentioned Intel hardware estimates &#8212; is vastly smaller than the variation in the &#8220;Energy Impact&#8221; measurements. For example, going from 1,000 to 10,000 wakeups per second increases the package power by 3.4x, but the &#8220;Energy Impact&#8221; increases by 9.7x, and the skew gets even worse at higher wakeup frequencies. &#8220;Energy Impact&#8221; clearly weights wakeups too heavily. (In the second table, with data from the 10.10.4 machine, the weight given to wakeups is less, but still too high.)<\/p>\n<p>Also, in the first table &#8220;Energy Impact&#8221; actually <em>decreases<\/em> when the timer frequency gets high enough. Presumably this is because the timer interval is so short that the OS has trouble putting the package into a idle power state. This leads to the absurd result that firing a timer at 1,000 Hz has about the same &#8220;Energy Impact&#8221; value as firing one at 100,000 Hz, when the package power of the latter is about 7.5x higher.<\/p>\n<p>Having said all that, it&#8217;s understandable why Apple uses formulations of this kind for &#8220;Energy Impact&#8221;.<\/p>\n<ul>\n<li>CPU usage and wakeup frequency are probably the two most important factors affecting a process&#8217;s power consumption, and they are factors that can be measured on a per-process basis.<\/li>\n<li>Having a single measure makes things easy for users; evaluating the relative important of multiple measures is more difficult.<\/li>\n<li>The exception for kernel processes (which always have an &#8220;Energy Impact&#8221; of 0) avoids OS X itself being blamed for high power consumption. This makes a certain amount of sense &#8212; it&#8217;s not like users can close the kernel &#8212; while also being somewhat misleading.<\/li>\n<\/ul>\n<p>If I were in charge of Apple&#8217;s Activity Monitor product, I&#8217;d do two things.<\/p>\n<ol>\n<li>I would compute a new formula for &#8220;Energy Impact&#8221;. I would measure the CPU usage, wakeup frequency (and any other inputs) and actual power consumption for a range of real-world programs, on a range of different Apple machines. From this data, hopefully a reasonably accurate model could be constructed. It wouldn&#8217;t be perfect, and it wouldn&#8217;t need to be perfect, but it should be possible to come up with something that reflects actual power consumption better than the existing formulations. Once formulated, I would then test the new version against synthetic microbenchmarks, like the ones I used above, to see how it holds up. Given the choice between accurately modelling real-world applications and accurately modelling synthetic microbenchmarks, I would definitely favour the former.<\/li>\n<li>I would publicly document the formula that is used so that developers can actually tell how their applications are being evaluated, and can optimize for that measure. You may think &#8220;but then developers will be optimizing for a synthetic measure rather than a real one&#8221; and you&#8217;d be right. That&#8217;s an inevitable consequence of giving a synthetic measure such prominence, and all the more reason for improving it.<\/li>\n<\/ol>\n<h3>Conclusion<\/h3>\n<p>&#8220;Energy Impact&#8221; is a flawed measure of an application&#8217;s power consumption. Nonetheless, it&#8217;s what many people use at this moment to evaluate the power consumption of OS X applications, so it&#8217;s worth understanding. And if you are an OS X application developer who wants to reduce the &#8220;Energy Impact&#8221; of your application, it&#8217;s clear that it&#8217;s best to focus first on reducing wakeup frequency, and then on reducing CPU usage.<\/p>\n<p>Because Activity Monitor is closed source code I don&#8217;t know if I&#8217;ve characterized &#8220;Energy Impact&#8221; exactly correctly. The evidence given above indicates that I am close on 10.9.5, but not as close on 10.10.4. I&#8217;d love to hear if anybody has evidence that either corroborates or contradicts the conclusions I&#8217;ve made here. Thank you.<\/p>\n<h3>Update<\/h3>\n<p>A commenter named comex has done some <a href=\"https:\/\/blog.mozilla.org\/nnethercote\/2015\/08\/26\/what-does-the-os-x-activity-monitors-energy-impact-actually-measure\/comment-page-1\/#comment-46775\">great detective work<\/a> and found on 10.10 and 10.11 Activity Monitor consults a Mac model-specific file in the <code>\/usr\/share\/pmenergy\/<\/code> directory. (Thank you, comex.)<\/p>\n<p>For example, my MacBook Air has a model number 7DF21CB3ED6977E5 and the file <code>Mac-7DF21CB3ED6977E5.plist<\/code> has the following list of key\/value pairs under the heading &#8220;energy_constants&#8221;.<\/p>\n<pre>kcpu_time\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1.0\r\nkcpu_wakeups\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 2.0e-4<\/pre>\n<p>This matches the previously seen formula, but with the wakeups &#8220;tax&#8221; being 200 microseconds, which matches what I hypothesized above.<\/p>\n<pre>kqos_default\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1.0e+00\r\nkqos_background\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 5.2e-01\r\nkqos_utility\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1.0e+00\r\nkqos_legacy\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 1.0e+00\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0\r\nkqos_user_initiated\u00a0\u00a0\u00a0\u00a0 1.0e+00\r\nkqos_user_interactive\u00a0\u00a0 1.0e+00<\/pre>\n<p>&#8220;QoS&#8221; refers to <em><a href=\"https:\/\/developer.apple.com\/library\/prerelease\/mac\/documentation\/Performance\/Conceptual\/power_efficiency_guidelines_osx\/PrioritizeWorkAtTheTaskLevel.html\">quality of service classes<\/a><\/em> which allow an application to mark some of its own work as lower priority. I&#8217;m not sure exactly how this is factored in, but from the numbers above it appears that operations done in the lowest-priority &#8220;background&#8221; class is considered to have an energy impact of about half that done in all the other classes.<\/p>\n<pre>kdiskio_bytesread\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 0.0\r\nkdiskio_byteswritten\u00a0\u00a0\u00a0 5.3e-10<\/pre>\n<p>These ones are straightforward. Note that the &#8220;tax&#8221; for disk reads is zero, and for disk writes it&#8217;s a very small number. I wrote a small program that wrote endlessly to disk and saw that the &#8220;Energy Impact&#8221; was slightly higher than the CPU percentage alone, which matches expectations.<\/p>\n<pre>kgpu_time\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 3.0e+00<\/pre>\n<p>It makes sense that GPU usage is included in the formula. It&#8217;s not clear if this refers to the integrated GPU or the separate (higher performance, higher power) GPU. It&#8217;s also interesting that the weighting is 3x.<\/p>\n<pre>knetwork_recv_bytes\u00a0\u00a0\u00a0\u00a0 0.0 \r\nknetwork_recv_packets\u00a0\u00a0 4.0e-6\r\nknetwork_sent_bytes\u00a0\u00a0\u00a0\u00a0 0.0\r\nknetwork_sent_packets\u00a0\u00a0 4.0e-6<\/pre>\n<p>These are also straightforward. In this case, the number of bytes sent is ignored, and only the number of packets matter, and the cost of reading and writing packets is considered equal.<\/p>\n<p>So, in conclusion, on 10.10 and 10.11, the formula used to compute &#8220;Energy Impact&#8221; is machine model-specific, and includes the following factors: CPU usage, wakeup frequency, quality of service class usage, and disk, GPU, and network activity.<\/p>\n<p>This is definitely an improvement over the formula used in 10.9, which is great to see. The parameters are also visible, if you know where to look! It would be wonderful if all these inputs, along with their relative weightings, could be seen at once in Activity Monitor. That way developers would have a much better sense of exactly how their application&#8217;s &#8220;Energy Impact&#8221; is determined.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>[Update: this post has been updated with significant new information. Look to the end.] Activity Monitor is a tool in Mac OS X that shows a variety of real-time process measurements. It is well-known and its &#8220;Energy Impact&#8221; measure (which was added in Mac OS X 10.9) is often consulted by users to compare the [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[487,281512],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/3107"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/users\/139"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/comments?post=3107"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/3107\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=3107"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=3107"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=3107"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}