energy metering and tracking with icount and quanto ipsn 2009 tutorial – san francisco – april...

Post on 20-Dec-2015

217 Views

Category:

Documents

3 Downloads

Preview:

Click to see full reader

TRANSCRIPT

Energy Metering and Tracking with iCount and Quanto

IPSN 2009 Tutorial – San Francisco – April 16th, 2009

Prabal DuttaRodrigo FonsecaThoma Schmid

quanto /’kwänto/

Portuguese (from Latin quantu)

interrogative pronoun - how much, what amount, what quantity, what number, what price

Introductionstell us about yourselves

prabal@eecs.berkeley.edurodrigo.fonseca@gmail.com

thomas.schmid@ucla.edu

Schedule

• 1:00 – 2:30 Presentation• 2:30 – 3:00 Break• 3:00 – 5:00 Hands on

• Goals:– Present the concepts behind Quanto– Get you excited by instrumenting, running, and

analyzing simple applications

Outline

• Demo: Blink• Introduction• How much energy? iCount

– Principles– Calibration

• What is using my energy?– Energy breakdown

• Why is it using my energy?– Activity Tracking

• Quanto in Practice– Architecture– Interesting Findings– Recording Information

• Hands on Session

Blink Demo

7

Blink: What’s happening?

48 seconds of Blink

DedicatedResources

LogicalThreads ofExecution

SharedResources

8

Energy Pie Chart

Red Green Blue CPU

Where have all the Joules gone?

“Slice” by device

“Track” by activity

48 seconds of Blink

9

Blink: Instrumentation

module BlinkC () { uses interface Timer<TMilli> as Timer0; uses interface Timer<TMilli> as Timer1; uses interface Timer<TMilli> as Timer2; uses interface Leds; uses interface Boot;}

Implementation { event void Boot.booted() {

call Timer0.startPeriodic(250);

call Timer1.startPeriodic(500);

call Timer2.startPeriodic(1000); }

event void Timer0.fired() { call Leds.led0Toggle(); } event void Timer1.fired() { call Leds.led1Toggle(); } event void Timer2.fired() { call Leds.led2Toggle(); }}

module BlinkC () { uses interface Timer<TMilli> as Timer0; uses interface Timer<TMilli> as Timer1; uses interface Timer<TMilli> as Timer2; uses interface Leds; uses interface Boot;}

Implementation { event void Boot.booted() { call CPUActivity.set(ACT_LED0); call Timer0.startPeriodic(250); call CPUActivity.set(ACT_LED1); call Timer1.startPeriodic(500); call CPUActivity.set(ACT_LED2); call Timer2.startPeriodic(1000); }

event void Timer0.fired() { call Leds.led0Toggle(); } event void Timer1.fired() { call Leds.led1Toggle(); } event void Timer2.fired() { call Leds.led2Toggle(); }}

10

Real applications:Many services making concurrent use of same hardware

Hardware Power SupplySensorsMCU Radio Storage

“Trio Network”[Dutta06]

11

Three basic challenges

• Energy metering– Measure energy usage– i(t) p(t) ∫p(t)dt

• Energy breakdown– Slice usage horizontally– Allocate usage to energy

sinks

• Activity tracking– Dice usage vertically– Track causal connections

iCount

iCount+

P-states+

Regression

Labels

Outline

• Demo: Blink• Introduction• How much energy? iCount

– Principles– Calibration

• What is using my energy?– Energy breakdown

• Why is it using my energy?– Activity Tracking

• Quanto in Practice– Architecture– Interesting Findings– Toolchain

• Hands on Session

13

Three basic challenges

• Energy metering– Measure energy usage– i(t) p(t) ∫p(t)dt

• Energy breakdown– Slice usage horizontally– Allocate usage to energy

sinks

• Activity tracking– Dice usage vertically– Track causal connections

iCount

Labels

iCount+

P-states+

Regression

14

Measuring: wide horizontal/vertical dynamic range

TX packet at 1% duty cycle (20 ms / 2 s)

4,000 ms

640,000 ms

86,400,000 ms

[Farkas00]

30 ms

15

Dynamic range in power draw exceeds 10,000:1

< 1 µW

> 50 mW

16

Current energy metering techniques are inadequate

cumbersome, expensive, not distributed,not scalable, not embedded, low resolution

cumbersome, expensive, not distributed,not scalable, not embedded,

low resolution, low responsiveness, high quiescent power

low responsiveness, high cost, high quiescent power

DS2438ADM1191BQ2019BQ27500 [Jiang07]

17

Key insight: Switching regulators inherently meter energy

If your platform has a PFM switching regulator…(many do)

add a wire

iCountenergymeterdesign

18

How does it work?

Source: Maxim Semiconductor

Cin

LxVin

VinCout

Vout

Rload

iLX

Energize

Transfer

Monitor

S1

S2

VLX

E=½Li2

PFMRegulator

19

Each cycle transfers a fixed energy quanta to the load

ΔE=½Li2

P=ΔE/Δt

Counting cycles translates to measuring energy

Regulator Cycles

20

This simple design works surprisingly well

MAX1724

Prototype implementation

[HydroWatch]

(UCB)

[Benchmark](UCB)

[Quanto](UCB)

[Quanto+](UCLA)

[Senseweb](WSU)

21

Hardware costs: wire and counter

“wire”Counter

HydroSolar Node (v2)

22

iCount Performance summary

Performance Metric iCount

Range 1 µA – 100 mA

Accuracy ±10% (±20%, full range)

Resolution 0.1 µJ – 0.5 µJ

Read latency 24 µs

Power overhead 0.01% - 1%

Responsiveness < 125 µs

Precision±1.5% (over 2 secs,

N=167)

Stability ±1% (over 1 week)*

* Frequency averaged over 1 second

Outline

• Demo: Blink• Introduction• How much energy? iCount

– Principles– Calibration

• What is using my energy?– Energy breakdown

• Why is it using my energy?– Activity Tracking

• Quanto in Practice– Architecture– Interesting Findings– Toolchain

• Hands on Session

24

Three basic challenges

• Energy metering– Measure energy usage– i(t) p(t) ∫p(t)dt

• Energy breakdown– Slice usage horizontally– Allocate usage to energy

sinks

• Activity tracking– Dice usage vertically– Track causal connections

iCount

Labels

iCount+

P-states+

Regression

25

Slicing: breaking down the envelope into its parts

Marc A. Viredaz and Deborah A. Wallach,“Power Evaluation of a Handheld Computer”,IEEE Micro, Jan-Feb, 2003

“Itsy”

26

Not all energy sinks can be instrumented

MCU

Radio

Power

Flash Sensors LEDs

Power Data Control

USART

DMA

OSC

Timer ADC

RX TX

LNAPA

CPU

27

A different approach to energy slicing: power state tracking*OnOff

* H. Zeng et al. “ECOSystem: Managing Energy as a First Class Operating Systems Resource”, ASPLOS’02, 2002.

Export device power states

Through a narrow interface

OS tracks/logs state transitions

28

Estimate energy breakdowns with regression

• For every power state transition– Snapshot system-wide power states (α1,…, αn)

– Snapshot global energy usage (ΔE)– Snapshot system clock (Δt)

• Generate an equation of the formΔE/Δt = α1p1 +… +, αnpn

(p’s are the unknown power draws)

• Solve for p’s using weighted multivariate least squares

High-resolution, high-speed energy meter key for good results

Δt

ΔE

α’s pi

29

Example power state equations

ΔE/Δt = α1p1 + α2p2 + α3p3 + α4p4

+ α5p5

2/1 = 1·p1 + 1·p2 + 1·p3 + 1·p4

+ 0·p5

3/1.1 = 1·p1 + 1·p2 + 1·p3 + 1·p4

+ 1·p5

1/0.4 = 1·p1 + 0·p2 + 1·p3 + 1·p4

+ 1·p5

0/0.4 = 1·p1 + 0·p2 + 0·p3 + 1·p4

+ 1·p5

1/0.6 = 1·p1 + 0·p2 + 0·p3 + 0·p4

+ 1·p5

0/0.6 = 1·p1 + 0·p2 + 0·p3 + 0·p4

+ 0·p5

ΔE

α’s pi

Y = ΔE/ΔtAP = YP = A-1Y

W = diag( √(Δt*ΔE) )P = (ATWA)-1ATWY

Outline

• Demo: Blink• Introduction• How much energy? iCount

– Principles– Calibration

• What is using my energy?– Energy breakdown

• Why is it using my energy?– Activity Tracking

• Quanto in Practice– Architecture– Interesting Findings– Toolchain

• Hands on Session

31

Three basic challenges

• Energy metering– Measure energy usage– i(t) p(t) ∫p(t)dt

• Energy breakdown– Slice usage horizontally– Allocate usage to energy

sinks

• Activity tracking– Dice usage vertically– Track causal connections

iCount

Labels

iCount+

P-states+

Regression

32

Tracking: gap between what is measured and what matters

• Itsy measured– Breakdown by

subsystem– For each application

• PowerScope measured:– Breakdown by PC– Breakdown by PID

Marc A. Viredaz and Deborah A. Wallach,“Power Evaluation of a Handheld Computer”,IEEE Micro, Jan-Feb, 2003

Jason Flinn and M. Satyanarayanan,“Energy-Aware Adaptation for Mobile Apps.”,SOSP’99, Kiawah Island, SC, 1999

33

What’s wrong with subsystems, PCs, and PIDs?

• Subsystem– No distinction between different logical activities– Is radio sending a routing beacon or data packet?

• Program Counter– Pinpoints code hotspots– But, not the data on which the code operates– Routing beacon? Time sync packet? Data packet?

• Process ID– Most sensornet applications are I/O bound– Most energy is spent outside the CPU– For I/O-bound processes, PID-based sampling is

biased

34

Activities* are what actually matters

* M.B. Jones et al., “Modular Real-Time Resource Management in the Rialto Operating System”, HotOS’95, 1995. G. Banga et al. “Resource Containers: A New Facility for Resource Management in Server Systems”, OSDI’99, 1999. H. Zeng et al. “ECOSystem: Managing Energy as a First Class Operating Systems Resource”, ASPLOS’02, 2002.

• A causally-connected set of operations…• whose distinct resource consumptions…• should be grouped together for accounting*

35

Three steps to activity tracking

• Annotating– Any abstraction can introduce an annotation– Associates an activity “label” with an execution– Labels are < origin-node : activity-identifier > pairs

• Propagating– System software transfers activity labels– Across subsystems, nodes, and deferred

computations

• Recording– Track, log, and post-process resource usage

36

Annotating an activity “paints” causally-connected actions

• “Sensing” involves– Sensor...– CPU, ADC, I2C bus, …

• “Storing” involves– Flash…– CPU, SPI bus, timers, …

• Initiate annotation withCPUActivity.set(<label>)

• Quanto automatically propagates labels

...CPUActivity.set(ACT_SENSING);Sensor.read();...CPUActivity.set(ACT_STORING);Flash.write(...);...

CPU

Sensor

Flash

Node A

Act: sensingAct: storing

37

Propagating labels over deferred computations

• Examples– CPU Post task (deferred function call) CPU– CPU Queue object CPU

• Task Scheduler– Add activity field to task structure– Set activity field on task posting– Restore activity on task invocation

• Queue– Tag each entry with its activity label– Write activity label on enqueue– Restore activity label on dequeue

38

Propagating labels over the network

CPU

Flash

Radio

Node B

CPU

Sensor

Radio Node A

Act: sensing Act: sending

Proxy Rx activity Packet Tx

• Add hidden field to packet• Sender’s OS sets activity

field

Radio.send(message_t* msg) {

. . .

msg->header->activity = CPUActivity.get();

. . .

}

39

Propagating unknown labels using proxy activities

CPU

Flash

Radio

Node B

CPU

Sensor

Radio Node A

Act: sensing Act: sending

Proxy Rx activity Packet Tx

• Every interrupt causes energy consumption

• before activity label is identified– Interrupt CPU– Timer CPU– Radio CPU

• Proxy activity provides ephemeral label

• Binding with real activity occurs when label is clear

message_t* Radio.recv(message_t* msg,

void* payload, uint8_t len) {

. . .

CPUActivity.bind(msg->hdr->activity);

. . .

}

40

Concurrent activities on shared resources

async command void Timer.start() {

call TimerActivity.add(call CPUActivity.get());

...

}

async event void HardwareTimer.fired() {

signal Timer.fired();

call TimerActivity.remove(call CPUActivity.get());

...

}

Activity A

Activity B

Timer Power State

Timer.firedTimer.start

Timer.firedTimer.start

A A/B BTimer Activities

Add A Add B Rem A Rem BTime

41

Three basic challenges

• Energy metering– Measure energy usage– i(t) p(t) ∫p(t)dt

• Energy breakdown– Slice usage horizontally– Allocate usage to energy

sinks

• Activity tracking– Dice usage vertically– Track causal connections

iCount

iCount+

P-states+

Regression

Labels

Outline

• Demo: Blink• Introduction• How much energy? iCount

– Principles– Calibration

• What is using my energy?– Energy breakdown

• Why is it using my energy?– Activity Tracking

• Quanto in Practice– Architecture– Interesting Findings– Recording Information

• Hands on Session

43

Summary of Quanto energy profiling architecture

Device Drivers

Hardware

Application

Operating System

<PowerStateTrack>, <SingleActivityTrack>, <MultiActivityTrack>, <EnergyMeter>

<PowerState>, <SingleActivity>, <MultiActivity>

propagate labels over deferred computations

monitor/expose power statessave/restore/expose activity

meter energy usage

annotate code with activity labels

propagate labels to/from devices

log and process activity/power data

44

Interesting Findings: catching power bugs.Why is TIMERA firing at 16Hz?!?

45

How much time and energy does using DMA really save?

Using DMA can subvert MAC layer fairness

46

What’s the cost of false alarms in Low-Power Listening?

Preamble DTX

RX D

Tlisten Noise

Overhearing adds significant unpredictability to node lifetime

47

Recording: log, export, and post-process data

• Challenge is getting data off the node• Reason most applications are still toys

Burst:10KB RAM Log

+ UART Out

Burst128K FIFO Log+ UART Out

Continuous:Compression+ UART Out

Continuous:Parallel Out+ Ethernet

Logging Solutions

• Log to RAM:– 12 bytes per logged event– Buffer for 700 events– Dump to UART once buffer is full

• Log to parallel port– Fast, real-time logging– Not scalable to multiple nodes

• Log to the UART, compressed– Blink running at 50ms, no compression: logging takes 80.9%

of CPU time– With compression: 25% of CPU time, compression of

3.84X (each log entry ~ 3.1 bytes)– Not enough for larger applications

• RadioCountToLeds, 2 nodes @100ms:– 427 ev/s– With LPL: 1617 ev/s

Logging Solutions

• Don’t trace: count• Step 1: online accounting of activities

– Time per activity per resource– Almost ready

• Step 2: online regression– Accumulating power state info– Doing regression online

• Current Status– The next release of Quanto will have online

accounting of the activity times

Hands-on Section

• Instrument, record data, process, visualize– Basic: Blink– Cross-network: RadioCountToLeds

• If we have time:– LPL: Bounce– Another example: FTSP

Questions

References

• Quanto Website:– http://quanto.cs.berkeley.edu

• Quanto code:– tinyos-2.x-contrib/berkeley/quanto

• Network Management Interface:

• Papers:– “Energy Metering for Free: Augmenting Switching Regulators

for Real-Time Monitoring” Prabal Dutta, Mark Feldmeier, Joseph Paradiso, David Culler. IPSN’08

– “Quanto: Tracking Energy in Networked Embedded Systems”, Rodrigo Fonseca, Prabal Dutta, Philip Levis, and Ion Stoica. OSDI’08

top related