increasing memory usage in real-time gc

19
Increasing Memory Increasing Memory Usage in Usage in Real-Time GC Real-Time GC Tobias Ritzau and Peter Fritzson Tobias Ritzau and Peter Fritzson Department of Computer and Information Department of Computer and Information Science Science Linköpings universitet Linköpings universitet [email protected] [email protected] http://www.ida.liu.se/~tobri http://www.ida.liu.se/~tobri

Upload: cailean-kerrane

Post on 30-Dec-2015

47 views

Category:

Documents


0 download

DESCRIPTION

Increasing Memory Usage in Real-Time GC. Tobias Ritzau and Peter Fritzson Department of Computer and Information Science Linköpings universitet [email protected] http://www.ida.liu.se/~tobri. The Problem. Published “real” real-time garbage collectors consume too much memory - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Increasing Memory Usage in Real-Time GC

Increasing Memory Usage inIncreasing Memory Usage inReal-Time GCReal-Time GCTobias Ritzau and Peter FritzsonTobias Ritzau and Peter Fritzson

Department of Computer and Information ScienceDepartment of Computer and Information ScienceLinköpings universitetLinköpings universitet

[email protected]@ida.liu.sehttp://www.ida.liu.se/~tobrihttp://www.ida.liu.se/~tobri

Page 2: Increasing Memory Usage in Real-Time GC

227-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

The ProblemThe Problem

Published “real” real-time garbage Published “real” real-time garbage collectors consume too much memorycollectors consume too much memory

A large portion of the overhead is caused A large portion of the overhead is caused by type information, internal fragmentation, by type information, internal fragmentation, and GC house keepingand GC house keeping

However, most GC techniques also However, most GC techniques also require a buffer to hold dead objectsrequire a buffer to hold dead objects

Page 3: Increasing Memory Usage in Real-Time GC

337-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

Mark-SweepMark-SweepRoot

Page 4: Increasing Memory Usage in Real-Time GC

667-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

RT-CopyingRT-Copying

Page 5: Increasing Memory Usage in Real-Time GC

777-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

RT-Mark-Sweep (JamaicaVM)RT-Mark-Sweep (JamaicaVM)

Page 6: Increasing Memory Usage in Real-Time GC

887-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

Available MemoryAvailable Memory

The amount of available memory using The amount of available memory using real-time garbage collection and a heap of real-time garbage collection and a heap of 12 – 36 byte objects (equally distributed) is12 – 36 byte objects (equally distributed) is Copying GC: Copying GC: 25%25% Mark-Sweep (JamaicaVM):Mark-Sweep (JamaicaVM): 31%31% Reference Counting:Reference Counting: 47%47%

Page 7: Increasing Memory Usage in Real-Time GC

997-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

Reference CountingReference Counting

1

1

1

2

1

21

10

0

Root

1

2

0

01

Page 8: Increasing Memory Usage in Real-Time GC

10107-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

Reference CountingReference Counting

Disadvantages to overcomeDisadvantages to overcome Recursive freeingRecursive freeing External fragmentationExternal fragmentation Reclaiming dead cyclic data structuresReclaiming dead cyclic data structures Execution speedExecution speed

Page 9: Increasing Memory Usage in Real-Time GC

11117-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

Recursive FreeingRecursive Freeing

The problem was solved for equally sized The problem was solved for equally sized objects by Weizenbaum (1963)objects by Weizenbaum (1963)

Decrementing child references is Decrementing child references is postponed until the memory is reusedpostponed until the memory is reused

Still, all memory is available when it Still, all memory is available when it becomes unreachablebecomes unreachable

However, objects are not always of the However, objects are not always of the same size…same size…

Page 10: Increasing Memory Usage in Real-Time GC

12127-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

External FragmentationExternal Fragmentation

As in most file systems, the heap can be As in most file systems, the heap can be divided into equally sized blocksdivided into equally sized blocksSmall objects are linked using a list, while Small objects are linked using a list, while larger objects use a tree structurelarger objects use a tree structureMinor performance penalty for small Minor performance penalty for small objectsobjectsWeizenbaum’s technique to eliminate Weizenbaum’s technique to eliminate recursive freeing can be used on the recursive freeing can be used on the blocksblocks

Page 11: Increasing Memory Usage in Real-Time GC

13137-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

Dead Cyclic Data StructuresDead Cyclic Data Structures

Manual techniques cover most casesManual techniques cover most cases Breaking cyclesBreaking cycles Weak referencesWeak references Balloon typesBalloon types

Automatic techniques are not real-timeAutomatic techniques are not real-time

A backup real-time mark-sweep GC can A backup real-time mark-sweep GC can be used but that increases memory be used but that increases memory overheadoverhead

Page 12: Increasing Memory Usage in Real-Time GC

14147-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

Execution TimeExecution Time

Peep hole optimizationPeep hole optimization

Stack allocationStack allocation

Object owning (Data flow analysis)Object owning (Data flow analysis)

Page 13: Increasing Memory Usage in Real-Time GC

15157-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

RT-Reference CountingRT-Reference Counting

All operations are predictable in memory All operations are predictable in memory usage and execution timeusage and execution time

Memory usage is increased by more than Memory usage is increased by more than 50% for objects larger than 17 bytes50% for objects larger than 17 bytes

Dead cyclic data structures can be Dead cyclic data structures can be reclaimed (to the cost of memory reclaimed (to the cost of memory overhead)overhead)

Page 14: Increasing Memory Usage in Real-Time GC

16167-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

Impact of Block SizeImpact of Block Size

0%

20%

40%

60%

80%

100%

0 16 32 48 64 80 96 112 128

Average object size (bytes)

Mem

ory

ove

rhea

d

16 byte blocks

32 byte blocks

64 byte blocks

Page 15: Increasing Memory Usage in Real-Time GC

19197-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

ImplementationsImplementations

Real-Time Reference Counting has been Real-Time Reference Counting has been implemented:implemented: As CPP macrosAs CPP macros In the JOSES Java compilerIn the JOSES Java compiler In the Jamaica VMIn the Jamaica VM

However more optimizations are requiredHowever more optimizations are required

No backup GC has been implementedNo backup GC has been implemented

Page 16: Increasing Memory Usage in Real-Time GC

20207-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

BenchmarksBenchmarks

-5051015202530354045

b bs r rb rbs t tb tbs tr trb trbs

%

b = dividing objects into blocksbs = spreading the blocksr = using reference countingt = running thousand simulations (= more blocks in use)

Page 17: Increasing Memory Usage in Real-Time GC

21217-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

Future WorkFuture Work

Full implementationFull implementation

RT-Mark compactRT-Mark compact

Memory Usage AnalysisMemory Usage Analysis Should critical systems use GC?Should critical systems use GC? Can you not explicitly deallocate all garbage if Can you not explicitly deallocate all garbage if

you can give an upper bound of memory you can give an upper bound of memory usage?usage?

Page 18: Increasing Memory Usage in Real-Time GC

22227-9 October, 20027-9 October, 2002 Increasing Memory Usage in Real-Time GCIncreasing Memory Usage in Real-Time GC

ConclusionConclusion

RT-Reference Counting drastically RT-Reference Counting drastically decrease the memory overhead of real-decrease the memory overhead of real-time systems with a GCtime systems with a GC

The block size have a minor impact on the The block size have a minor impact on the memory overheadmemory overhead

Page 19: Increasing Memory Usage in Real-Time GC

Increasing Memory Increasing Memory Usage in Real-Time GCUsage in Real-Time GC

Tobias Ritzau and Peter FritzsonTobias Ritzau and Peter Fritzson

Department of Computer and Information ScienceDepartment of Computer and Information ScienceLinköpings universitetLinköpings universitet

[email protected]@ida.liu.sehttp://www.ida.liu.se/~tobrihttp://www.ida.liu.se/~tobri