Initial Explorations on Design Pattern Energy Usage (GREENS 12)

Post on 28-Jun-2015

119 views 1 download

Tags:

Transcript of Initial Explorations on Design Pattern Energy Usage (GREENS 12)

INITIAL EXPLORATIONSON DESIGN PATTERN

ENERGY USAGE

Cagri SahinJames Clause

Lori Pollock

Furkan CayciIrene Lizeth Manotas Gutiérrez

Fouad KiamilevKristina Winbladh

Computer and InformationSciences Department

Electrical and ComputerEngineering Department

University of Delaware

This work was supported in part by an award from the University of Delaware Research Foundation (UDRF).

MOTIVATION

Historically, software developers have left concerns about power consumption to lower-level engineers.

MOTIVATION

Historically, software developers have left concerns about power consumption to lower-level engineers.

Hardwarecpu, disk, etc.

MOTIVATION

Historically, software developers have left concerns about power consumption to lower-level engineers.

Hardwarecpu, disk, etc.

Operating systems

MOTIVATION

Historically, software developers have left concerns about power consumption to lower-level engineers.

Hardwarecpu, disk, etc.

Operating systems

Compilers

MOTIVATION

While this strategy has been successful, it is likely that encouraging software developers to participate in the process can result in more efficient applications.

Historically, software developers have left concerns about power consumption to lower-level engineers.

Hardwarecpu, disk, etc.

Operating systems

Compilers

Powe

rpr

ofile

(w)

Desig

n pr

oper

ties

Desig

nar

tifac

ts

foo:

25

foo:

46

Robustness ReliabilityMaintainabilityFault toleranceAvailabilityPerformance

Actor

System

Use Case

Use cases

OperationAttributeClass Name

*1

OperationAttributeClass Name<<extends>>

OperationAttributeClass Name

Class diagrams

Object Name Object Name

Synchronous

Simple Message

Sequence diagrams

OVERALL APPROACH

Powe

rpr

ofile

(w)

Desig

n pr

oper

ties

Desig

nar

tifac

ts

foo:

25

foo:

46

Robustness ReliabilityMaintainabilityFault toleranceAvailabilityPerformance

Actor

System

Use Case

Use cases

OperationAttributeClass Name

*1

OperationAttributeClass Name<<extends>>

OperationAttributeClass Name

Class diagrams

Object Name Object Name

Synchronous

Simple Message

Sequence diagrams

OVERALL APPROACH

EXPERIMENTAL DATATable IENERGY USAGE MEASUREMENT OBTAINED BY RUNNING THE BEFORE AND AFTER VERSIONS OF THE DESIGN PATTERNS.

Design pattern # Iterations Energy usage # Objects # Messages

Before (J) After (J) Difference (J) Difference periteration (J)

% Change Before After Before After

Creational

Abstract factory 500 87.78 106.69 18.91 0.0378 21.55 11 13 7 12Builder 750 111.75 113.08 1.33 0.0018 1.19 3 6 18 32

Factory method 500 118.13 118.06 �0.08 �0.0002 �0.07 3 3 1 2Prototype 750 99.60 98.68 �0.93 �0.0012 �0.93 7 7 3 9Singleton 250 98.70 99.11 0.42 0.0017 0.42 2 2 7 12

Structural

Bridge 35 99.78 99.54 �0.24 �0.0070 �0.24 6 11 3 6Composite 175 97.15 102.14 4.99 0.0285 5.14 17 19 10 11Decorator 115 13.92 113.13 99.21 0.8627 712.89 14 24 14 15Flyweight 500 92.89 38.94 �53.95 �0.1079 �58.08 60 6 60 60

Proxy 500 104.33 66.28 �38.05 �0.0761 �36.47 5 2 3 6

Behavioral

Command 750 98.32 96.53 �1.79 �0.0024 �1.82 7 7 29 29Mediator 250 120.55 109.02 �11.53 �0.0461 �9.56 4 5 23 26Observer 400 61.62 99.95 38.33 0.0958 62.20 3 7 4 8Strategy 500 115.73 115.52 �0.21 �0.0004 �0.18 4 3 9 12

Visitor 90 104.89 97.04 �7.86 �0.0873 �7.49 10 14 16 26

Joules of the application before and after applying eachdesign pattern. The fifth column, Difference, shows thedifference in total energy usage between the before and afterversions of applying the design patterns. Positive numbersindicate that applying the design pattern increased energyusage, and negative numbers indicate that applying thedesign pattern reduced energy usage. The next column inthe table, Difference per iteration, shows the difference intotal energy usage per iteration (i.e., the difference in thetotal energy usage divided by the number of iterations).Again, positive numbers indicate that the applying the designpattern increased the energy usage, and negative numbersindicate that applying the design pattern reduced energyusage. The seventh column in the table, % Change showsthe percentage change in total energy usage between thebefore and after version for each design pattern. The finalfour columns provide a count of the number of objectsinstantiated and the number of messages passed between theobjects for the before and after versions of the applications.

D. RQ1: Feasibility

The purpose of our first research question is to serve asa sanity check for both our power monitoring tool and ourassumption that applying a design pattern will impact theenergy usage of an application. As Table I shows, our powermonitoring tool is capable of detecting differences in theamount of energy used by the applications. For example, thebefore version of the application for abstract factory used⇡ 87 J of energy and the after version of application forthe proxy pattern used ⇡ 66 J of energy. Moreover, thesemeasurements also indicate that our tool is able to detect

relatively small differences in the amounts of energy used(e.g., the energy usage of the before and after versions ofthe application for factory method differ only by 0.08 J).

The results shown in the table also support our assumptionthat applying a design pattern impacts energy usage. For all15 design patterns, we detected a difference in the amountof energy used between the before and after versions of theapplication.

E. RQ2: Impact

Our motivation for investigating the impact on energyusage of applying design patterns is to gain knowledge thatcan be leveraged by application designers. As the data inTable I shows, the impacts of applying design patterns canvary greatly. For some design patterns (e.g., factory method,prototype, bridge, and strategy) the impact of applying thepattern is relatively small (less than 1%. While for other pat-terns the impact is moderate (e.g., abstract factory, flyweight,decorator, observer) or even substantial (e.g., decorator).

Note that while in absolute terms the difference in energyusage per iteration is small (0.0002 J to 0.8672 J), thereare several points to keep in mind. First, the Spartan-6 isdesigned to be an extremely low-power system. A typicaldesktop or server computer will consume significantly moreenergy. Second, our application of the design patterns wasminimal. We used the smallest number of classes and thesimplest actions possible. Finally, the amount of energyused is shown per iteration (e.g., this is the difference inthe amount of energy used by a single dynamic executionof a section of code changed by the application of thepattern). In a typical application, code associated with the

EXPERIMENTAL DATATable IENERGY USAGE MEASUREMENT OBTAINED BY RUNNING THE BEFORE AND AFTER VERSIONS OF THE DESIGN PATTERNS.

Design pattern # Iterations Energy usage # Objects # Messages

Before (J) After (J) Difference (J) Difference periteration (J)

% Change Before After Before After

Creational

Abstract factory 500 87.78 106.69 18.91 0.0378 21.55 11 13 7 12Builder 750 111.75 113.08 1.33 0.0018 1.19 3 6 18 32

Factory method 500 118.13 118.06 �0.08 �0.0002 �0.07 3 3 1 2Prototype 750 99.60 98.68 �0.93 �0.0012 �0.93 7 7 3 9Singleton 250 98.70 99.11 0.42 0.0017 0.42 2 2 7 12

Structural

Bridge 35 99.78 99.54 �0.24 �0.0070 �0.24 6 11 3 6Composite 175 97.15 102.14 4.99 0.0285 5.14 17 19 10 11Decorator 115 13.92 113.13 99.21 0.8627 712.89 14 24 14 15Flyweight 500 92.89 38.94 �53.95 �0.1079 �58.08 60 6 60 60

Proxy 500 104.33 66.28 �38.05 �0.0761 �36.47 5 2 3 6

Behavioral

Command 750 98.32 96.53 �1.79 �0.0024 �1.82 7 7 29 29Mediator 250 120.55 109.02 �11.53 �0.0461 �9.56 4 5 23 26Observer 400 61.62 99.95 38.33 0.0958 62.20 3 7 4 8Strategy 500 115.73 115.52 �0.21 �0.0004 �0.18 4 3 9 12

Visitor 90 104.89 97.04 �7.86 �0.0873 �7.49 10 14 16 26

Joules of the application before and after applying eachdesign pattern. The fifth column, Difference, shows thedifference in total energy usage between the before and afterversions of applying the design patterns. Positive numbersindicate that applying the design pattern increased energyusage, and negative numbers indicate that applying thedesign pattern reduced energy usage. The next column inthe table, Difference per iteration, shows the difference intotal energy usage per iteration (i.e., the difference in thetotal energy usage divided by the number of iterations).Again, positive numbers indicate that the applying the designpattern increased the energy usage, and negative numbersindicate that applying the design pattern reduced energyusage. The seventh column in the table, % Change showsthe percentage change in total energy usage between thebefore and after version for each design pattern. The finalfour columns provide a count of the number of objectsinstantiated and the number of messages passed between theobjects for the before and after versions of the applications.

D. RQ1: Feasibility

The purpose of our first research question is to serve asa sanity check for both our power monitoring tool and ourassumption that applying a design pattern will impact theenergy usage of an application. As Table I shows, our powermonitoring tool is capable of detecting differences in theamount of energy used by the applications. For example, thebefore version of the application for abstract factory used⇡ 87 J of energy and the after version of application forthe proxy pattern used ⇡ 66 J of energy. Moreover, thesemeasurements also indicate that our tool is able to detect

relatively small differences in the amounts of energy used(e.g., the energy usage of the before and after versions ofthe application for factory method differ only by 0.08 J).

The results shown in the table also support our assumptionthat applying a design pattern impacts energy usage. For all15 design patterns, we detected a difference in the amountof energy used between the before and after versions of theapplication.

E. RQ2: Impact

Our motivation for investigating the impact on energyusage of applying design patterns is to gain knowledge thatcan be leveraged by application designers. As the data inTable I shows, the impacts of applying design patterns canvary greatly. For some design patterns (e.g., factory method,prototype, bridge, and strategy) the impact of applying thepattern is relatively small (less than 1%. While for other pat-terns the impact is moderate (e.g., abstract factory, flyweight,decorator, observer) or even substantial (e.g., decorator).

Note that while in absolute terms the difference in energyusage per iteration is small (0.0002 J to 0.8672 J), thereare several points to keep in mind. First, the Spartan-6 isdesigned to be an extremely low-power system. A typicaldesktop or server computer will consume significantly moreenergy. Second, our application of the design patterns wasminimal. We used the smallest number of classes and thesimplest actions possible. Finally, the amount of energyused is shown per iteration (e.g., this is the difference inthe amount of energy used by a single dynamic executionof a section of code changed by the application of thepattern). In a typical application, code associated with the

1. Design patterns do impact energy consumption.

EXPERIMENTAL DATATable IENERGY USAGE MEASUREMENT OBTAINED BY RUNNING THE BEFORE AND AFTER VERSIONS OF THE DESIGN PATTERNS.

Design pattern # Iterations Energy usage # Objects # Messages

Before (J) After (J) Difference (J) Difference periteration (J)

% Change Before After Before After

Creational

Abstract factory 500 87.78 106.69 18.91 0.0378 21.55 11 13 7 12Builder 750 111.75 113.08 1.33 0.0018 1.19 3 6 18 32

Factory method 500 118.13 118.06 �0.08 �0.0002 �0.07 3 3 1 2Prototype 750 99.60 98.68 �0.93 �0.0012 �0.93 7 7 3 9Singleton 250 98.70 99.11 0.42 0.0017 0.42 2 2 7 12

Structural

Bridge 35 99.78 99.54 �0.24 �0.0070 �0.24 6 11 3 6Composite 175 97.15 102.14 4.99 0.0285 5.14 17 19 10 11Decorator 115 13.92 113.13 99.21 0.8627 712.89 14 24 14 15Flyweight 500 92.89 38.94 �53.95 �0.1079 �58.08 60 6 60 60

Proxy 500 104.33 66.28 �38.05 �0.0761 �36.47 5 2 3 6

Behavioral

Command 750 98.32 96.53 �1.79 �0.0024 �1.82 7 7 29 29Mediator 250 120.55 109.02 �11.53 �0.0461 �9.56 4 5 23 26Observer 400 61.62 99.95 38.33 0.0958 62.20 3 7 4 8Strategy 500 115.73 115.52 �0.21 �0.0004 �0.18 4 3 9 12

Visitor 90 104.89 97.04 �7.86 �0.0873 �7.49 10 14 16 26

Joules of the application before and after applying eachdesign pattern. The fifth column, Difference, shows thedifference in total energy usage between the before and afterversions of applying the design patterns. Positive numbersindicate that applying the design pattern increased energyusage, and negative numbers indicate that applying thedesign pattern reduced energy usage. The next column inthe table, Difference per iteration, shows the difference intotal energy usage per iteration (i.e., the difference in thetotal energy usage divided by the number of iterations).Again, positive numbers indicate that the applying the designpattern increased the energy usage, and negative numbersindicate that applying the design pattern reduced energyusage. The seventh column in the table, % Change showsthe percentage change in total energy usage between thebefore and after version for each design pattern. The finalfour columns provide a count of the number of objectsinstantiated and the number of messages passed between theobjects for the before and after versions of the applications.

D. RQ1: Feasibility

The purpose of our first research question is to serve asa sanity check for both our power monitoring tool and ourassumption that applying a design pattern will impact theenergy usage of an application. As Table I shows, our powermonitoring tool is capable of detecting differences in theamount of energy used by the applications. For example, thebefore version of the application for abstract factory used⇡ 87 J of energy and the after version of application forthe proxy pattern used ⇡ 66 J of energy. Moreover, thesemeasurements also indicate that our tool is able to detect

relatively small differences in the amounts of energy used(e.g., the energy usage of the before and after versions ofthe application for factory method differ only by 0.08 J).

The results shown in the table also support our assumptionthat applying a design pattern impacts energy usage. For all15 design patterns, we detected a difference in the amountof energy used between the before and after versions of theapplication.

E. RQ2: Impact

Our motivation for investigating the impact on energyusage of applying design patterns is to gain knowledge thatcan be leveraged by application designers. As the data inTable I shows, the impacts of applying design patterns canvary greatly. For some design patterns (e.g., factory method,prototype, bridge, and strategy) the impact of applying thepattern is relatively small (less than 1%. While for other pat-terns the impact is moderate (e.g., abstract factory, flyweight,decorator, observer) or even substantial (e.g., decorator).

Note that while in absolute terms the difference in energyusage per iteration is small (0.0002 J to 0.8672 J), thereare several points to keep in mind. First, the Spartan-6 isdesigned to be an extremely low-power system. A typicaldesktop or server computer will consume significantly moreenergy. Second, our application of the design patterns wasminimal. We used the smallest number of classes and thesimplest actions possible. Finally, the amount of energyused is shown per iteration (e.g., this is the difference inthe amount of energy used by a single dynamic executionof a section of code changed by the application of thepattern). In a typical application, code associated with the

1. Design patterns do impact energy consumption.

2. Impact within a category is inconsistent.

EXPERIMENTAL DATATable IENERGY USAGE MEASUREMENT OBTAINED BY RUNNING THE BEFORE AND AFTER VERSIONS OF THE DESIGN PATTERNS.

Design pattern # Iterations Energy usage # Objects # Messages

Before (J) After (J) Difference (J) Difference periteration (J)

% Change Before After Before After

Creational

Abstract factory 500 87.78 106.69 18.91 0.0378 21.55 11 13 7 12Builder 750 111.75 113.08 1.33 0.0018 1.19 3 6 18 32

Factory method 500 118.13 118.06 �0.08 �0.0002 �0.07 3 3 1 2Prototype 750 99.60 98.68 �0.93 �0.0012 �0.93 7 7 3 9Singleton 250 98.70 99.11 0.42 0.0017 0.42 2 2 7 12

Structural

Bridge 35 99.78 99.54 �0.24 �0.0070 �0.24 6 11 3 6Composite 175 97.15 102.14 4.99 0.0285 5.14 17 19 10 11Decorator 115 13.92 113.13 99.21 0.8627 712.89 14 24 14 15Flyweight 500 92.89 38.94 �53.95 �0.1079 �58.08 60 6 60 60

Proxy 500 104.33 66.28 �38.05 �0.0761 �36.47 5 2 3 6

Behavioral

Command 750 98.32 96.53 �1.79 �0.0024 �1.82 7 7 29 29Mediator 250 120.55 109.02 �11.53 �0.0461 �9.56 4 5 23 26Observer 400 61.62 99.95 38.33 0.0958 62.20 3 7 4 8Strategy 500 115.73 115.52 �0.21 �0.0004 �0.18 4 3 9 12

Visitor 90 104.89 97.04 �7.86 �0.0873 �7.49 10 14 16 26

Joules of the application before and after applying eachdesign pattern. The fifth column, Difference, shows thedifference in total energy usage between the before and afterversions of applying the design patterns. Positive numbersindicate that applying the design pattern increased energyusage, and negative numbers indicate that applying thedesign pattern reduced energy usage. The next column inthe table, Difference per iteration, shows the difference intotal energy usage per iteration (i.e., the difference in thetotal energy usage divided by the number of iterations).Again, positive numbers indicate that the applying the designpattern increased the energy usage, and negative numbersindicate that applying the design pattern reduced energyusage. The seventh column in the table, % Change showsthe percentage change in total energy usage between thebefore and after version for each design pattern. The finalfour columns provide a count of the number of objectsinstantiated and the number of messages passed between theobjects for the before and after versions of the applications.

D. RQ1: Feasibility

The purpose of our first research question is to serve asa sanity check for both our power monitoring tool and ourassumption that applying a design pattern will impact theenergy usage of an application. As Table I shows, our powermonitoring tool is capable of detecting differences in theamount of energy used by the applications. For example, thebefore version of the application for abstract factory used⇡ 87 J of energy and the after version of application forthe proxy pattern used ⇡ 66 J of energy. Moreover, thesemeasurements also indicate that our tool is able to detect

relatively small differences in the amounts of energy used(e.g., the energy usage of the before and after versions ofthe application for factory method differ only by 0.08 J).

The results shown in the table also support our assumptionthat applying a design pattern impacts energy usage. For all15 design patterns, we detected a difference in the amountof energy used between the before and after versions of theapplication.

E. RQ2: Impact

Our motivation for investigating the impact on energyusage of applying design patterns is to gain knowledge thatcan be leveraged by application designers. As the data inTable I shows, the impacts of applying design patterns canvary greatly. For some design patterns (e.g., factory method,prototype, bridge, and strategy) the impact of applying thepattern is relatively small (less than 1%. While for other pat-terns the impact is moderate (e.g., abstract factory, flyweight,decorator, observer) or even substantial (e.g., decorator).

Note that while in absolute terms the difference in energyusage per iteration is small (0.0002 J to 0.8672 J), thereare several points to keep in mind. First, the Spartan-6 isdesigned to be an extremely low-power system. A typicaldesktop or server computer will consume significantly moreenergy. Second, our application of the design patterns wasminimal. We used the smallest number of classes and thesimplest actions possible. Finally, the amount of energyused is shown per iteration (e.g., this is the difference inthe amount of energy used by a single dynamic executionof a section of code changed by the application of thepattern). In a typical application, code associated with the

1. Design patterns do impact energy consumption.

2. Impact within a category is inconsistent.

3. At the design level, it’s unclear how to predict the impact.

ISSUES / DISCUSSION

CONCLUSION

ISSUES / DISCUSSION

1. Power monitoring tools / infrastructure

CONCLUSION

ISSUES / DISCUSSION

1. Power monitoring tools / infrastructure

2. Experimental subjects

CONCLUSION

ISSUES / DISCUSSION

1. Power monitoring tools / infrastructure

2. Experimental subjects

3. Prediction metrics

CONCLUSION

ISSUES / DISCUSSION

1. Power monitoring tools / infrastructure

2. Experimental subjects

3. Prediction metrics

CONCLUSION

Questions?