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 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 1 OptimalMemoryConsumption ∼ 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] memory malloc() free() time 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 memory GC time 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- Long- Mid- Living- Living- Living- Memory Memory Memory malloc() Bumppointer Long- Long- Mid- Short- Short- Short- Living- Living- Living- Living- Living- Living- Memory Memory Memory Memory Memory Memory malloc() Bumppointer Long- Mid- Long- Living- Living- Living- Memory Memory 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] memory malloc() free() time 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- Long- Mid- Living- Living- Living- Memory Memory Memory malloc() Bumppointer Long- Mid- Mid- Short- Long- Short- Living- Living- Living- Living- Living- Living- Memory Memory Memory Memory Memory Memory malloc() Bumppointer Mid- Mid- Long- Long- Living- Living- Living- Living- Memory Memory Memory Memory malloc() 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 tick() tick() tick() memory refresh(2) refresh(0) tick() tick() tick() tick() tick() refresh(4) refresh(7) t4 t5 t6 t8 t1 t2 t3 t7 time 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() ltm ltm ltm stm stm stm tick() mtm mtm mtm stm stm stm 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- Long- Mid- Mid- Mid- Short- Short- Short- Short- Living- Living- Living- Living- Living- Living- Living- Living- Living- Memory Memory Memory Memory Memory Memory Memory Memory 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
Recommend
More recommend