A Compacting Real-Time Memory Management System Silviu S. - - PowerPoint PPT Presentation

a compacting real time memory management system
SMART_READER_LITE
LIVE PREVIEW

A Compacting Real-Time Memory Management System Silviu S. - - PowerPoint PPT Presentation

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion A Compacting Real-Time Memory Management System Silviu S. Craciunas, Christoph M. Kirsch, Hannes Payer, Ana Sokolova, Horst Stadler, Robert Staudinger


slide-1
SLIDE 1

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

A Compacting Real-Time Memory Management System

Silviu S. Craciunas, Christoph M. Kirsch, Hannes Payer, Ana Sokolova, Horst Stadler, Robert Staudinger

Hannes Payer

Computational Systems Group, University of Salzburg

July 1, 2008

Hannes Payer Computational Systems Group, University of Salzburg

slide-2
SLIDE 2

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Overview

Introduction Compact-Fit Experiments Conclusion

Hannes Payer Computational Systems Group, University of Salzburg

slide-3
SLIDE 3

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Motivation

Traditional dynamic memory management systems are typically non-deterministic:

  • unpredictable response times of memory operations
  • unpredictable memory fragmentation

⇒ Dynamic memory management systems are typically not used in time-critical software components (hard real-time systems, device drivers . . . )

Hannes Payer Computational Systems Group, University of Salzburg

slide-4
SLIDE 4

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Predictable Memory Management System

Predictability in Time

The time a memory management operation takes is determined by the size of the object involved in the operation (allocation, deallocation, and dereference).

Predictability in Space

The number of actual allocations together with their sizes (not the

  • rder of invocations) determines how many more allocations of a

given size will succeed before running out of memory.

Hannes Payer Computational Systems Group, University of Salzburg

slide-5
SLIDE 5

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Solution Space

Time Space

unpredictable predictable unpredictable predictable

Hannes Payer Computational Systems Group, University of Salzburg

slide-6
SLIDE 6

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

What We Want?

A memory management system predictable in time and space (component of the real-time operating system Tiptoe) Properties:

  • malloc(n) takes at most O(n) time
  • free(n) takes at most O(n) time
  • memory access (dereference) takes small constant time
  • small and predictable memory fragmentation bound

Hannes Payer Computational Systems Group, University of Salzburg

slide-7
SLIDE 7

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Fragmentation Problem

10 20 30 40 50 60 70 80 90 not allocatable 35% free

fragmentation in a contiguous space ⇒ compaction ⇒ reference updates

Hannes Payer Computational Systems Group, University of Salzburg

slide-8
SLIDE 8

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Solution to Reference Updates

Application Indirection T able Memory Abstract Space Concrete Space

Hannes Payer Computational Systems Group, University of Salzburg

slide-9
SLIDE 9

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Solution to Reference Updates

Application Indirection T able Memory Abstract Space Concrete Space

Hannes Payer Computational Systems Group, University of Salzburg

slide-10
SLIDE 10

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Compaction

Trade-Off:

speed versus memory fragmentation

Requirement:

keep speed and memory fragmentation bounded and predictable

2 Extreme Non-Solutions:

  • keep memory perfectly compact
  • perform memory operations in constant time without

considering memory fragmentation

Hannes Payer Computational Systems Group, University of Salzburg

slide-11
SLIDE 11

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Concrete Address Space

  • concrete address space is divided into pages of equal size

16KB 16KB 16KB 16KB 16KB 16KB 16KB 16KB

Hannes Payer Computational Systems Group, University of Salzburg

slide-12
SLIDE 12

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Concrete Address Space

  • concrete address space is divided into pages of equal size
  • each page itself is divided into fixed-sized page-blocks

FREE

Hannes Payer Computational Systems Group, University of Salzburg

slide-13
SLIDE 13

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Concrete Address Space

  • concrete address space is divided into pages of equal size
  • each page itself is divided into fixed-sized page-blocks
  • n predefined page-block sizes ⇒ n different size-classes

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-14
SLIDE 14

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Concrete Address Space

  • concrete address space is divided into pages of equal size
  • each page itself is divided into fixed-sized page-blocks
  • n predefined page-block sizes ⇒ n different size-classes

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-15
SLIDE 15

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Concrete Address Space

  • concrete address space is divided into pages of equal size
  • each page itself is divided into fixed-sized page-blocks
  • n predefined page-block sizes ⇒ n different size-classes

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-16
SLIDE 16

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Concrete Address Space

  • concrete address space is divided into pages of equal size
  • each page itself is divided into fixed-sized page-blocks
  • n predefined page-block sizes ⇒ n different size-classes

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-17
SLIDE 17

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Concrete Address Space

  • concrete address space is divided into pages of equal size
  • each page itself is divided into fixed-sized page-blocks
  • n predefined page-block sizes ⇒ n different size-classes

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-18
SLIDE 18

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Concrete Address Space

  • concrete address space is divided into pages of equal size
  • each page itself is divided into fixed-sized page-blocks
  • n predefined page-block sizes ⇒ n different size-classes

size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-19
SLIDE 19

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Concrete Address Space

  • concrete address space is divided into pages of equal size
  • each page itself is divided into fixed-sized page-blocks
  • n predefined page-block sizes ⇒ n different size-classes

size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-20
SLIDE 20

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Deallocation May Involve Compaction

Size-Class Compact Invariant:

Each size-class can contain at most one not-full page.

Hannes Payer Computational Systems Group, University of Salzburg

slide-21
SLIDE 21

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Deallocation May Involve Compaction

Size-Class Compact Invariant:

Each size-class can contain at most one not-full page.

size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-22
SLIDE 22

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Deallocation May Involve Compaction

Size-Class Compact Invariant:

Each size-class can contain at most one not-full page.

size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-23
SLIDE 23

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Deallocation May Involve Compaction

Size-Class Compact Invariant:

Each size-class can contain at most one not-full page.

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-24
SLIDE 24

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Deallocation May Involve Compaction

Size-Class Compact Invariant:

Each size-class can contain at most one not-full page.

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-25
SLIDE 25

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Deallocation May Involve Compaction

Size-Class Compact Invariant:

Each size-class can contain at most one not-full page.

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-26
SLIDE 26

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Deallocation May Involve Compaction

Size-Class Compact Invariant:

Each size-class can contain at most one not-full page.

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-27
SLIDE 27

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Deallocation May Involve Compaction

Size-Class Compact Invariant:

Each size-class can contain at most one not-full page.

FREE size-class green size-class red size-class blue

MOVE

Hannes Payer Computational Systems Group, University of Salzburg

slide-28
SLIDE 28

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Deallocation May Involve Compaction

Size-Class Compact Invariant:

Each size-class can contain at most one not-full page.

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-29
SLIDE 29

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Compact-Fit Versions

  • Compact-fit moving version (CFM)
  • concrete space = physical memory
  • allocated objects are contiguous in physical memory
  • compaction: leads to movements in physical memory
  • Compact-fit non-moving version (CFNM)
  • concrete space = virtual memory (blocks)
  • allocated objects are not contiguous in physical memory, but

are contiguous in virtual memory

  • compaction: reprogramming block table

Hannes Payer Computational Systems Group, University of Salzburg

slide-30
SLIDE 30

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Compact-Fit Moving Version Complexity

  • malloc(n) takes Θ(1) time
  • free(n) takes O(n) time

because of compaction

  • memory access (dereference) takes Θ(1) time

because of abstract address space

  • memory fragmentation is bounded and predictable

Hannes Payer Computational Systems Group, University of Salzburg

slide-31
SLIDE 31

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Compact-Fit Non-Moving Version Complexity

  • malloc(n) takes Θ(n) time

because of maintaining the virtual memory

  • free(n) takes Θ(n) time

because of maintaining the virtual memory and compaction

  • memory access (dereference) takes Θ(1) time

because of abstract address space and virtual memory

  • memory fragmentation is bounded and predictable

Hannes Payer Computational Systems Group, University of Salzburg

slide-32
SLIDE 32

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Partial Compaction

Idea:

Allow an arbitrary number k of not-full pages within a size-class.

Result:

Each deallocation that happens when number not full pages ≤ k takes constant time, but fragmentation increases with k.

Effect:

This way we formalize, control, and implement the trade-off between temporal performance and memory fragmentation.

Hannes Payer Computational Systems Group, University of Salzburg

slide-33
SLIDE 33

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Partial Compaction

size-class red: k=2

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-34
SLIDE 34

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Partial Compaction

size-class red: k=2

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-35
SLIDE 35

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Partial Compaction

size-class red: k=2

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-36
SLIDE 36

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Partial Compaction

size-class red: k=2

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-37
SLIDE 37

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Partial Compaction

size-class red: k=2

FREE size-class green size-class red size-class blue

MOVE

Hannes Payer Computational Systems Group, University of Salzburg

slide-38
SLIDE 38

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Partial Compaction

size-class red: k=2

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-39
SLIDE 39

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Partial Compaction

size-class red: k=2

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-40
SLIDE 40

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Partial Compaction

size-class red: k=2

FREE size-class green size-class red size-class blue

Hannes Payer Computational Systems Group, University of Salzburg

slide-41
SLIDE 41

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Related Work

Time Space

unbounded in n O(n) O(log n) O(1)

unpredictable predictable

First-fit: malloc Best-fit: malloc DL: malloc First-fit: free, deref Best-fit: free, deref DL: free, deref TLSF: malloc, free, deref Half-fit: malloc, free, deref CFM: free CFNM: malloc, free Jamaica: malloc, free, deref Jamaica: deref CFM: malloc, deref CFNM: deref M e t r

  • n
  • m

e Hannes Payer Computational Systems Group, University of Salzburg

slide-42
SLIDE 42

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Incremental Allocation Benchmark

50 100 250 500 1000 2500 5000 10000 20000 40000 200 400 600 800 1000 1200 1400 1600 1800 Number of instructions Number of allocation operations of increasing size CFM CFNM First-fit Best-fit DL TLSF Half-fit First-fit Best-fit TLSF Half-fit CFM DL CFNM

Hannes Payer Computational Systems Group, University of Salzburg

slide-43
SLIDE 43

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Incremental Free Benchmark

100 250 500 1000 2500 5000 200 400 600 800 1000 1200 1400 1600 1800 Number of instructions Number of deallocation operations of increasing size CFNM CFM First-fit Best-fit DL TLSF Half-fit First-fit Best-fit TLSF Half-fit CFM DL CFNM

Hannes Payer Computational Systems Group, University of Salzburg

slide-44
SLIDE 44

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Incremental Free Partial Compaction

100 250 500 1000 2000 3500 200 400 600 800 1000 1200 1400 1600 1800 Number of instructions Number of deallocation operations of increasing size CFM CFNM First-fit Best-fit DL TLSF Half-fit First-fit Best-fit TLSF Half-fit CFM DL CFNM

Hannes Payer Computational Systems Group, University of Salzburg

slide-45
SLIDE 45

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Fragmentation

1 10 100 1000 5000 2000 4000 6000 8000 10000 12000 14000 16000 Number of allocatable objects Object size CFM 1 CFM 2 CFM 3,4 CFM 5 CFM 6,7,8,9 TLSF CFM 1 CFM 2 CFM 3 CFM 4 CFM 5 CFM 6 CFM 7 CFM 8 CFM 9 TLSF

Hannes Payer Computational Systems Group, University of Salzburg

slide-46
SLIDE 46

Introduction Fragmentation Problem Compact-Fit Partial Compaction Experiments Conclusion

Conclusion and Future Work

Contribution:

  • Compact-fit is predictable in time and space
  • moving and non-moving Compact-fit implementations

Future work:

  • virtual machine implementation
  • source-to-source translator
  • concurrency and multi-processor support
  • static program analysis can help to optimize the k for the

partial compaction strategy http://tiptoe.cs.uni-salzburg.at/compact-fit

Hannes Payer Computational Systems Group, University of Salzburg