Page 1
Haskell in Green Land: Analyzing the Energy Behavior of a Purely Functional Language
Luís Gabriel Lima1, Gilberto Melfe2, Francisco Soares-Neto1, Paulo Lieuthier1, João Paulo Fernandes2, and Fernando Castor1
1 {lgnfl, fmssn, pvjl, castor}@cin.ufpe.br2 [email protected] , [email protected]
1
Page 2
Global energy system is unsustainable
2
Page 5
Haskell has feelings too!
5
Page 6
rq
6
Can we save energy by refactoring Haskell
programs to use different data structure
implementations or concurrent
programming constructs?
Page 7
Experimental Setup
2x10-core Intel Xeon E5-2660 v2 processors (Ivy Bridge) 256GB of DDR3 1600MHz RAM
Criterion
RAPL
7
Page 8
Study 1: Purely functional data structures
8
Page 9
RQ1. How do different implementations of
the same abstractions compare in terms of
run time and energy efficiency?
9
Page 10
RQ2. For concrete operations, what is the
relationship between their performance
and energy consumption?
10
Page 11
Study 1: Edison Library
Collections Associative Collections Sequences
EnumSet
StandardSet
UnbalancedSet
LazyPairingHeap
LeftistHeap
MinHeap
SkewHeap
SplayHeap
AssocList
PatriciaLoMap
StandardMap
TernaryTrie
BankersQueue
SimpleQueue
BinaryRandList
JoinList
RandList
BraunSeq
FingerSeq
ListSeq
RevSeq
SizedSeq
MyersStack
11
Page 12
Study 1: Benchmark
iters operation base aux
1
1000
1
1000
5000
1
10000
10
5000
10
add
addAll
clear
contains
containsAll
iterator
remove
removeAll
toArray
retainAll
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
100000
1000
n.a.
1
1000
n.a.
1
1000
n.a.
1000
12
Page 13
13
iters = 0; while iters < 10
retainAll base aux;iters++;
Page 14
640 configurations6000+ executions
14
Page 15
Study 2: Results
15
http://green-haskell.github.io
Page 16
Study 1: Results
16
Page 17
Study 1: Findings
17
RQ1. How do different implementations of the same abstractions
compare in terms of runtime and energy efficiency?
RQ2. For concrete operations, what is the relationship between their
performance and their energy consumption?
Energy is proportional to execution time.
Full details on green-haskell.github.io.
Page 18
Study 2: Concurrent programming constructs
18
Page 19
19
RQ1. Do alternative thread management
constructs have different impacts on energy
consumption?
Page 20
20
RQ2. Do alternative data-sharing primitives
have different impacts on energy
consumption?
Page 21
Study 2: Concurrency Primitives
Thread management: forkIO, forkOn,
forkOS
22
Page 22
Study 2: Concurrency Primitives
Data sharing: MVar, TVar, TMVar
23
Page 23
9 benchmarks: IO, memory, synchronization bound
Up to 9 variants per benchmark
9 configurations for # of processors
24
Page 24
Study 2: Results
25
http://green-haskell.github.io
Page 25
26
Small changes can produce big savings
Page 26
Faster is not always greener
27
Page 27
28
There is no overall winner
Page 29
Made two tools energy-aware:
Haskell profiler
Criterion
31
Page 30
fsklsdfnjdsfjsadfhjksdhflkjsdhflkjsah
32
Page 31
fsklsdfnjdsfjsadfhjksdhflkjsdhflkjsah
33
Population: 56483 (2013)
Haskell programmers: 0 (est.)
Page 32
34
http://green-haskell.github.io
Page 33
35
http://green-haskell.github.io
Page 34
36
http://green-haskell.github.io
Page 35
37
http://green-haskell.github.io