Correlating Power Usage with Performance Data using the Gecko Profiler and Intel Sandy Bridge

I ran a quick experiment after someone pointed out to me that second generation Intel GPU provide features for querying power management status of the CPU such as the current frequency and power usage of the CPU in Watts. I re-purposed the responsiveness correlation in the Gecko Profiler to instead use the average power consumption of the CPU over the last few milliseconds. This let you see the current power usage of Firefox as it does different tasks (JS, layout, gfx). The idea is similar to looking at throughput performance: Find that area of the code that has the highest power and energy consumption and optimize it. Here’s a sample:

Power Usage in the Gecko Profiler

Power Usage in the Gecko Profiler (View the profile yourself) Color=power usage, Height=Call depth, x=time

I should note that the data is expected to be noisy because I had applications running and the typical set of background processes you’d find on Mac. Nevertheless every profile I ran showed the power usage drop significantly at every point where Firefox was waiting for events so this proves that it is in fact working. I haven’t done much analysis on the data but a quick look at the profiles suggest that our SSE2 code is particularly power hungry.

A neat idea would be to compute the energy consumption from the power consumption and break it down into Gecko Modules.


The biggest roadblock to implementing this is that the power information isn’t available in user mode and I’m don’t think that APIs are widely exposed by operating system. Luckily Intel provides a sample library and driver that let you access this information. Once I had this in place it was simply a matter of querying this information rather then the event loop status like the Profiler normally does. Because this data requires a driver you wont see this feature hit the Profiler unless I see a big demand for it.

4 thoughts on “Correlating Power Usage with Performance Data using the Gecko Profiler and Intel Sandy Bridge

  1. Optimizing for power is somewhat less intuitive than optimizing for speed. Using large amounts of power isn’t necessarily bad. In the case of the SSE2 code it probably means that the code we’re running is very tight and efficient, we could use slower code here which would make the reported power numbers go down, but we’d likely end up using more power overall. There’s a saying “hurry up and go to sleep” which basically means if you do the work you need to do quickly you can go to sleep and save a lot of power.

    • Yes I completely agree. I think the real focus should be on energy consumption (time*power). From a few quick profiles for now I think the best thing to do is to focus on performance (time).

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s