Tuning Garbage Collection in an Embedded Java Environment

Document Sample
Tuning Garbage Collection in an Embedded Java Environment Powered By Docstoc
					 Tuning Garbage Collection in an
 Embedded Java Environment

G. Chen, R. Shetty,
M. Kandemir,                    M. Wolczko
N. Vijaykrishnan, M. J. Irwin

Microsystems Design Lab         Sun Microsystems, Inc.
The Pennsylvania State
University
                                                         1
Objectives

 Investigatethe role of GC in energy
  consumption of energy-aware systems
 Find energy consumption improvements
  based on GC mechanism




                                     2
Roadmap

 Background   & Motivation
 KVM GC and Parameters
 Experiments setup
 Energy Characterization and
  Optimization
 Conclusions


                                3
Why Java ?

 Increasing   popularity of Java in portable
 devices.
  • portability
  • natural for web based applications
 Estimated number of Java enabled
 devices in 2005: 721 million
  • cell phones, PDAs, pagers etc.

                                                4
Characteristics of Embedded
Devices

 Small memory capacity
 Requirements of low energy
  consumption
 more (soft real-time, long duration sessions etc.)


 How  to incorporate the change ?
 Application independent - by adapting
  JVM to target requirements
                                                       5
Electrical Characteristics

 Devices  are required to reduce size and
  increase performance
 Technological Solution: 10 Technology
 Price: higher energy consumption




                                         6
Memory Energy Consumption

 Significantpart of overall energy
  consumption
 Memory types: Banked-RAM, ROM,
  Cache
 Characteristics: Dynamic, Leakage,
  Shutdown
 Advances in miniaturization result in
  higher energy leakage
                                          7
Why GC ?

 Independent of application, impacts
  memory management
 May be easily controlled
 May be used to shutdown memory
  banks



                                        8
KVM GC‟S

 Mark   & Sweep (M&S)
  • Simple
 M&S    + Compaction (M&C)
  • Handles fragmentation
  • 2KB chunks reserved for „Permanent data‟
    not included in GC
 Energy   tradeoff:
  • Simple wastes more memory
  • complicated - consumes more                9
More on M&C

 Compaction   occurs
  • No big enough entry in free list
  • When a need for more permanent memory
    arises
     compaction - garbage-occupied
 Until
  memory is considered live 


                                        10
Memory Wasted Waiting for GC




                               11
Experiment Setup - “Hardware”

 microSparc-IIep embedded processor
 100Mhz, 32bit, 5-stage pipeline
 On chip memories: ROM, RAM, Cache




                                       12
Experiment Energy Models

 Simulate KVM executing applications
 Accurately simulate hardware energy
  consumption
 Cache modeled as SRAM
 Scale parameters to 10  Technology
 Assume large leakage-energy


                                        13
Experiment Setup - Banked
Memory

 Assume   shutdown and turn-on
  capability of 16KB banks
 Simulate Turn-on cost (350 cycles)




                                       14
Experiment Setup - Benchmarks




                                15
Experiment Setup - Benchmarks
                          100%
System Energy Breakdown



                           90%
                           80%
                           70%
                           60%
                           50%
                           40%
                           30%
                           20%
                           10%
                            0%




                                                                                                              MathFP
                                                                         Kshape




                                                                                                                              Missiles
                                                                 Elite




                                                                                                  Manyballs
                                                                                           Kwml
                                                                                  Kvideo




                                                                                                                       Mini




                                                                                                                                                     Starcruiser
                                              Crypto

                                                       Dragon




                                                                                                                                         Scheduler
                                 Calculator




        Core                                                    heap(leakage)                                 heap(dynamic)
        Runtime Stack(leakage)                                  Runtime Stack(dynamic)                        ROM(leakage)
        ROM(dynamic)                                                                                                                                               16
Introducing Mode Control

         down unused memory banks
 Shutting
 Implemented on heap and stack


 The  price - the turning on / off process,
  is negligible



                                               17
                                                  % Energy




                                   10
                                        20
                                             30
                                                  40
                                                       50
                                                            60
                                                                 70
                                                                      80
                                                                           90
                                                                                100




                               0
                 Calculator

                     Crypto

                    Dragon

                       Elite

                    Kshape




 Heap
                     Kvideo

                      Kwml

                  Manyballs

                    MathFP
 Runtime Stack
                       Mini

                    Missiles

                 Scheduler

                 Starcruiser
                                                                                      Impact of Mode Control (M&S)




18
Increasing Frequency of GC

 Until garbage collection, memory banks
  might be on only storing garbage
 Increasing GC Frequency will help get
  rid of the garbage more quickly
 Tradeoff:
  Energy saved versus Energy spent on
  GC

                                       19
Controlling GC Frequency

 In the experiment:
  “After K calls to the allocator”
 In real implementation the policy should
  be f(memory allocated), or simply
  before turning on a new memory bank.



                                         20
                                % Heap Energy




                                 10
                                 20
                                 30
                                 40
                                 50
                                 60
                                 70
                                 80
                                 90
                                100




                                  0
                  Calculator

                      Crypto

                     Dragon




10
                        Elite




40
                     Kshape




75
                     Kvideo




100
                       Kwml




250
                  Manyballs

                     MathFP
                                                Impact of GC Frequency




                        Mini
   of Memory




                    Missiles

                  Scheduler
OutMode Control




                  Starcruiser
21
                                           % ROM Energy




                                 20
                                      40
                                           60
                                                80
                                                     100
                                                           120
                                                                 140
                                                                       160
                                                                             180
                                                                                   200




                             0
               Calculator

                   Crypto

                  Dragon

                     Elite

                  Kshape




Mode Control
                   Kvideo




10
                    Kwml




40
                Manyballs



75
                  MathFP
100
                     Mini
250


                  Missiles

               Scheduler

               Starcruiser
                                                                                         The Cost of Increasing GC Freq




 22
GC Frequency - Conclusions

 Dependent     on memory usage scheme
 Don‟t exaggerate !
 Frequency of ~70 gives good results
 Application dependently determining the
  GC frequency could be an optimal
  (the article is already published...)


                                        23
Modifying Object Allocation Style

 M&S  algorithms maintain a „free list‟
 More energy sensitive schemes:
 Active Bank
  • free list per block
  • Allocate first from active banks
 Active   Bank+
  • If cannot allocate from an already active
    bank - run GC
                                                24
                                           % Heap Energy




                                 10
                                      20
                                           30
                                                40
                                                     50
                                                          60
                                                               70
                                                                    80
                                                                         90
                                                                              100




                             0
               Calculator

                   Crypto




Mode Control
                  Dragon

                     Elite

                  Kshape




   First
                   Kvideo

                    Kwml




   Active
                Manyballs

   Active+GC      MathFP

                     Mini

                  Missiles

               Scheduler

               Starcruiser
                                                                                    Impact of Object Allocation Style




   25
Impact of Object Allocation Style
Explained

 Active   Bank ~ Mode Control
  • Coherent with observation that the younger
    die first
  • „Permanent‟ objects occupy the lower part
    of heap. The higher part is usually cleaned
    during GC



                                              26
Impact of Object Allocation Style
Explained

 Active   Bank + is better
  • Increases frequency of GC
  • reduces probability of turning on a new
    memory bank
  • Permanent objects are likely to be
    allocated more densely



                                              27
Compaction

 Compaction   may decrease number of
  active memory banks
 Tradeoff:
  Energy spent on compaction versus
  reduction of memory energy
  consumption


                                        28
                                         % Heap Energy



                                                                            100




                           0
                               10
                                    20
                                         30
                                              40
                                                   50
                                                        60
                                                             70
                                                                  80
                                                                       90
             Calculator

                 Crypto

                Dragon

                   Elite

                Kshape

                 Kvideo

                  Kwml




No Compact
              Manyballs

                MathFP

Compact            Mini

                Missiles

             Scheduler
                                                                                  Impact of Default Compaction




             Starcruiser
29
Impact of Default Compaction

 Disappointing...
 Better   compaction schemes ?
  • M&C+ Perform compaction after each GC
  • M&C2 Different compaction algorithm
 M&C2     versus M&C
  • cheaper marking and updating
  • more overhead per allocation

                                        30
                                           % Heap Energy




                                 10
                                      20
                                           30
                                                40
                                                     50
                                                          60
                                                               70
                                                                    80
                                                                         90
                                                                              100




                             0
               Calculator

                   Crypto

                  Dragon

                     Elite

                  Kshape




Mode Control
                   Kvideo

                    Kwml




M&C
                Manyballs



M&C2
                  MathFP

                     Mini
M&C+


                  Missiles

               Scheduler

               Starcruiser
                                                                                    Impact of Compaction Schemes




   31
Impact of Compaction -
Conclusions

 Compaction   does not achieve great
  savings
 Compaction though cannot be omitted
  • more memory will be needed for
    application due to fragmentation




                                        32
Impact of Cache

 Reduces   access to main memory:
  • Heap energy drops to 23% of overall
    energy
 Cache itself is a significant energy
  consumer



                                          33
Impact of GC Schemes in
Presence of Cache
                          15%
                          28%




                                34
Conclusions

 The combination of hardware
  mechanisms to lower energy leakage
  and software controlling it, may
  substantially reduce energy
  consumption
 Saving may be achieved without
  application awareness

                                       35
Conclusions

 GC  mechanisms, with minor
  modifications, can help reach the
  energy saving goal
 Mode Control, Allocation strategy, GC
  frequency are the most important.
 Compaction is usually necessary, its
  implementation affects energy
  consumption
                                          36