Self-Collecting Mutators are Self-Compacting An analysis of memory - - PowerPoint PPT Presentation
Self-Collecting Mutators are Self-Compacting An analysis of memory - - PowerPoint PPT Presentation
Self-Collecting Mutators are Self-Compacting An analysis of memory consumption in real-periodic programs Stephanie Stroka Embedded Software Engineering University of Salzburg January 25, 2011 Motivation Periodic Memory Consumption Analysis
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Outline
1 Motivation 2 Periodic Memory Consumption Analysis 3 Implementation 4 Results 5 Outlook
Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
The ideal allocator
Fast memory allocation and deallocation No ”wasted” memory space
Internal fragmentation External fragmentation
Predictable time and memory consumption Fast compile-time
Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
The problem
Fast allocation ֒ → wasting memory Less fragmentation ֒ → slow allocation OptimalMemoryConsumption ∼
1 AllocationTime
Predictable memory consumption ֒ → unreasonable run-time (memory copying) ֒ → unreasonable compile-time (program analysis?!)
Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Typical program characteristics [1]
time memory malloc() free()
Figure 1: Periodic memory allocation and deallocation Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Memory consumption in Garbage Collectors
time memory GC
Figure 2: Garbage Collector loses periodic memory characteristics Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Periodic memory allocation in the heap
Bumppointer Long- Living- Memory Long- Living- Memory Mid- Living- Memory malloc() Bumppointer Long- Living- Memory Long- Living- Memory Mid- Living- Memory malloc() Short- Living- Memory Short- Living- Memory Short- Living- Memory Bumppointer Long- Living- Memory Long- Living- Memory Mid- Living- Memory malloc()
Figure 3: Periodic memory allocation and deallocation in the heap Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Typical program characteristics [2]
time memory malloc() free()
Figure 4: Periodic memory allocation with growing list Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Semi-periodic memory allocation in the heap
Bumppointer Long- Living- Memory Long- Living- Memory Mid- Living- Memory malloc() Bumppointer Long- Living- Memory Long- Living- Memory Mid- Living- Memory malloc() Short- Living- Memory Short- Living- Memory Bumppointer Long- Living- Memory Long- Living- Memory Mid- Living- Memory malloc() Mid- Living- Memory Mid- Living- Memory
Figure 5: Periodic memory allocation with growing list in the heap Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Analyzing techniques
To analyze periodic memory consumption, we need... an allocator that provides information about fragmentation ֒ → Compact-Fit a mutator that provides time information ֒ → Self-Collecting Mutator
Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Binding memory life-time to a clock
time memory tick() t1 t2 t3 t4 t5 t6 t7 t8 refresh(7) refresh(4) refresh(2) tick() tick() tick() tick() tick() tick() tick() refresh(0)
Figure 6: Periodic memory allocation with self-collecting mutators Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Implementation
SCM eager collection ֒ → all expired objects will be deallocated at scm tick() SCM‘s malloc function uses cf malloc() instead of ptmalloc2() Example program with scm malloc(), scm refresh() and scm tick()
stm stm mtm ltm stm stm mtm ltm stm stm mtm ltm tick() tick() tick() tick() tick() tick() tick()
Figure 7: Analyzing memory consumption behaviour with growing #ticks Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Results
Runtime increases with growing # ticks ֒ → tick(), refresh() and compaction() Memory consumption decreases with # ticks ֒ → max. fragmentation = #free() ֒ → ...unlikely, because of periodic characteristic Compaction causes compaction
Long- Living- Memory Long- Living- Memory Mid- Living- Memory Mid- Living- Memory Mid- Living- Memory Short- Living- Memory Short- Living- Memory Short- Living- Memory Short- Living- Memory
Figure 8: Compaction causes compaction Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Results
1 tick
k = 1, compaction = 160 k = 2, compaction = 520 k = 3, compaction = 0 k = 4, compaction = 0 ...
3 ticks
k = 1, compaction = 282 k = 2, compaction = 12 k = 3, compaction = 0 k = 4, compaction = 0
Stephanie Stroka Self-Collecting Mutators are Self-Compacting
Motivation Periodic Memory Consumption Analysis Implementation Results Outlook
Outlook
Analyze k for non-trivial programs Find optimal middle ground for memory consumption and compaction overhead Formalize relation of k and refresh()/tick()
Stephanie Stroka Self-Collecting Mutators are Self-Compacting