Storage Allocation in Bounded Time - PowerPoint PPT Presentation

1 / 53
About This Presentation
Title:

Storage Allocation in Bounded Time

Description:

Tight bound on storage requirement for defragmentation-free buddy allocator ... How to defragment partially to satisfy a single request within some bounded time ? ... – PowerPoint PPT presentation

Number of Views:60
Avg rating:3.0/5.0
Slides: 54
Provided by: Shar224
Category:

less

Transcript and Presenter's Notes

Title: Storage Allocation in Bounded Time


1
Storage Allocation in Bounded Time
Sharath R. CholletiSep 04, 2002Advisor Dr. Ron
K. Cytron
Center for Distributed Object Computing Department
of Computer Science Washington University
Supported by NSF ITR 0081214 and DARPA contract
number F33615-00-C-1697
2
Outline
  • Dynamic Storage Allocation
  • Buddy Allocation
  • Tight bound on storage requirement for
    defragmentation-free buddy allocator
  • Greedy Algorithm for partial defragmentation
  • Experiments
  • Conclusion

3
Dynamic Storage Allocation
Program
Heap
Allocation or Deallocation Request
Response
Allocator
  • Heap storage used by a program
  • Real-Time Systems
  • - Bounded time
  • Embedded Systems
  • - Limited resources

4
Fragmentation
  • What is it?

Heap
Where to allocate?
  • Not enough contiguous free space

5
Possible Solutions
  • Have a big enough heap
  • Defragmentation
  • Compaction
  • Unreasonably bounded
  • Real-Time Systems
  • - Bounded time
  • Embedded Systems
  • - Limited resources

6
Questions
  • How big a heap we need to avoid defragmentation?
  • How to defragment partially to satisfy a single
    request within some bounded time ?

7
Storage Allocation Free List
  • Linked list of free blocks
  • Search for desired fit
  • Worst-case entire list

8
Storage Allocation Knuths Buddy System
  • Free lists segregated by size

128
64
32
  • All the requests are rounded up to a power of 2

16
8
4
2
1
9
Buddy System (1)
  • Begin with one large block
  • Suppose we want a block of size 8

128
64
32
16
8
4
2
1
10
Buddy System (2)
  • Begin with one large block
  • Suppose we want a block of size 8
  • Subdivide recursively

128
64
32
16
8
4
2
1
11
Buddy System (3)
  • Begin with one large block
  • Suppose we want a block of size 8
  • Subdivide recursively

128
64
32
16
8
4
2
1
12
Buddy System (4)
  • Begin with one large block
  • Suppose we want a block of size 8
  • Subdivide recursively

128
64
32
16
8
4
2
1
13
Buddy System (5)
  • Begin with one large block
  • Suppose we want a block of size 8
  • Subdivide recursively
  • 2 blocks of size 8

128
64
32
16
8
4
2
1
14
Buddy System (6)
  • Begin with one large block
  • Suppose we want a block of size 8
  • Subdivide recursively
  • 2 blocks of size 8
  • One of those given to the program

128
64
32
16
8
4
Given to the program
2
1
15
Buddy System (7)
  • Coalescing
  • Only buddies coalesce

128
64
32
16
8
4
Deallocated
2
1
16
Buddy System Tree Notation
Free
Allocate block of size 1 byte
Occupied
16
8
4
2
1
17
Buddy System Tree Notation(2)
Free
Allocate block of size 1 byte
Occupied
16
8
4
2
1
18
Buddy System Tree Notation(3)
Free
Allocate block of size 1 byte
Occupied
16
8
4
2
1
19
Buddy System Tree Notation(4)
Free
Allocate block of size 1 byte
Occupied
16
8
4
2
1
20
Buddy System Tree Notation(5)
Free
Allocate block of size 1 byte -- Done
Occupied
16
8
4
2
1
21
Buddy System Tree Notation(6)
Free
Allocate block of size 4 bytes
Occupied
16
8
4
2
1
22
Questions
  • How big a heap we need to avoid defragmentation?
  • How to defragment partially to satisfy a single
    request within some bounded time ?

23
Trivial Bound
  • Definitions
  • Maxlive max number of bytes the program uses at
    any given time throughout its life time
  • Maxlive denoted by M
  • Rounded to next power of 2 (for Buddy System)
  • log denotes log base 2
  • Trivial Bound
  • kM, where k is the number of different block
    sizes
  • For buddy system the bound is M(log M),
  • as k log M (not counting the block size of
    maxlive)
  • The bound is very high
  • For example if M 210 B, we need 10 210 B

24
Heap of 2M is not sufficient
Free
M 16 bytes
  • Allocate 16 1-byte blocks

Occupied
32
16
8
4
2
1
25
Heap of 2M is not sufficient (2)
Free
M 16 bytes
  • Deallocate alternate blocks
  • Used storage 8 bytes

Occupied
32
16
8
4
2
1
26
Heap of 2M is not sufficient (3)
Free
M 16 bytes
  • Allocate 4 blocks of size 2 bytes
  • Used storage 16 bytes

Occupied
32
16
8
4
2
1
27
Heap of 2M is not sufficient (4)
Free
M 16 bytes
  • Deallocate alternate blocks
  • Used storage 8 bytes

Occupied
32
16
8
4
2
1
28
Heap of 2M is not sufficient (5)
Free
M 16 bytes
  • Allocate 2 blocks of size 4 bytes
  • Used storage 16 bytes

Occupied
32
16
8
4
2
1
29
Heap of 2M is not sufficient (6)
Free
M 16 bytes
  • Deallocate alternate blocks
  • Used storage 8 bytes

Occupied
32
16
8
4
2
1
30
Heap of 2M is not sufficient (7)
Free
M 16 bytes
  • Used storage 8 bytes
  • Want to allocate a block of 8 bytes!

Occupied
32
16
8
4
2
1
31
Tight Bound
  • Maxlive M
  • Max-blocksize n
  • n lt M
  • M(log n 2)/2 is necessary and sufficient for
    address-ordered buddy allocator
  • Proof sketch for sufficiency
  • P(k) For kltlog n, 2k block cannot be allocated
    beyond M(k 2)/2
  • Proof of sufficiency by induction on k

32
Proof Idea (sufficiency)
Free
M 16 bytes
  • 2k size block cannot be allocated beyond M(k2)/2

Occupied
  • For k0 it is M(02)/2 M

32
16
8
4
2
1
M
M/2
M/2
33
Proof Idea (sufficiency)
Free
M 16 bytes
  • Assume P(k) is true for 0ltkltlog n
  • Then prove for P(k1)
  • For klog n, 2(logn) size block cannot be
    allocated beyond M(log n2)/2

Occupied
32
16
8
4
2
1
M
M/2
M/2
34
Proof Idea (Necessary)
Free
M 16 bytes
  • M(log n2)/2 bytes necessary
  • Details presented in the thesis
  • Example when k1, i.e., block of size 2

Occupied
32
16
8
4
2
1
M
M/2
M/2
35
Tight Bound
  • M(log n2)/2
  • n max-blocksize
  • M(log M1)/2
  • when n M/2
  • Almost half of the trivial bound
  • For example, if M 210 B then 5.5 210 B is
    needed

36
Questions
  • How big a heap we need to avoid defragmentation?
  • How to defragment partially to satisfy a single
    request within some bounded time ?

37
Partial Defragmentation Relocation Example
Free
  • Need to allocate a block of 8 bytes
  • No free block of 8 bytes -- relocate

Occupied
Amount of storage relocated T(1) 1
32
16
8
4
2
1
38
Partial Defragmentation Relocation Example (2)
Free
  • Again need to allocate a block of 8 bytes
  • No free block of 8 bytes -- relocate

Occupied
Amount of storage relocated T(2) T(1)
(21) 1 4
32
16
8
4
2
1
39
Worst-case Relocation Heap of M bytes
  • Amount storage relocated in worst-case to get a
    free block of n
  • T(n/2)T(n/4)T(1)
  • n/2 T(n/4) T(n/8) T(1)
    T(n/4)T(1)
  • n/2 2T(n/4)T(n/8)T(1)
  • n(log n)/2

Free
Occupied
32
16
8
4
2
1
40
Defragmentation with Heap of 2M bytes
  • Theorem Greedy algorithm of selecting a
    minimally occupied chunk for relocation moves
    less than twice the storage an optimal algorithm
    would move.
  • Proof sketch, details in thesis
  • Optimal algorithm has to relocate at least the
    amount of storage present in a minimally occupied
    chunk (say X bytes)
  • Greedy algorithm selects a chunk with X bytes
    live storage
  • Let X is made up of blocks of size x1, x2, x3, ,
    xn bytes
  • For each xi, there exists a chunk of size xi with
    less than xi/2 live storage
  • Overall relocation X X/2 X/4 1 lt 2X
  • Less than twice optimal

41
Defragmentation with Heap of 2M bytes(2)
  • Lemma There is a 2k-byte chunk with less than
    2(k-1) bytes live storage.

Free
M 16 bytes
Occupied
32
16
8
4
2
1
42
Defragmentation with Heap of 2M bytes(3)
  • Worst-case relocation
  • n, if block of size n is requested
  • From the lemma and the theorem
  • How to find the minimally occupied chunk?
  • Go through the entire heap?

43
Heap Manager Algorithm
16
8
8
3
5
4
3
0
1
4
1
2
0
1
2
2
2
1
44
Heap Manager Algorithm(2)
  • Storage bound O(M)
  • Time bound O(M)
  • T(n) 2M/n T(n/4) T(n/8) T(4)
  • 2M/n 2M/(n/4) T(n/8)
    2T(n/16)T(4)
  • O(Mn0.695)

45
Experiments SPEC Benchmarks
  • Java -- check, compress, db, jack, javac, jess,
    mpegaudio, mtrt, raytrace
  • C cfrac, gawk, gs, p2c, ptc
  • Java traces using contaminated garbage collection
    (Dante, Steve, Matt)
  • Randomly generated traces (Delvin)
  • With 2M heap there is no relocation required!
  • Even for randomly generated traces

46
Compaction Methods
  • To compare overall partial defragmentation with
    heap of M
  • Left-first compaction
  • Right-first compaction
  • Naive Compaction

47
Java Benchmarks
48
C Benchmarks
49
Minimal vs Random Chunk Amount of Relocation
50
Minimal vs Random Chunk Number of Relocations
51
Conclusion Future Work
  • Tight bound for a defragmentation-free buddy
    allocator
  • Greedy algorithm for partial defragmentation
  • Experiments
  • 2M is good enough in practice!
  • Very less defragmentation even with heap of size
    M
  • Our algorithm does much better than compaction
  • Minimal vs Random Block Selection
  • Implementing the algorithm in JVM?
  • Contaminated Reference Counting

52
Questions?
53
Thanks
  • Advisor
  • Dr. Ron K. Cytron
  • Thesis Committee
  • Dr. Jeremy Buhler
  • Dr. Chris D. Gill
  • Dr. Chenyang Lu
  • DOC Group members and others
Write a Comment
User Comments (0)
About PowerShow.com