190 likes | 341 Views
Increasing Memory Usage in Real-Time GC. Tobias Ritzau and Peter Fritzson Department of Computer and Information Science Linköpings universitet tobri@ida.liu.se http://www.ida.liu.se/~tobri. The Problem. Published “real” real-time garbage collectors consume too much memory
E N D
Increasing Memory Usage inReal-Time GC Tobias Ritzau and Peter Fritzson Department of Computer and Information Science Linköpings universitet tobri@ida.liu.se http://www.ida.liu.se/~tobri
The Problem • Published “real” real-time garbage collectors consume too much memory • A large portion of the overhead is caused by type information, internal fragmentation, and GC house keeping • However, most GC techniques also require a buffer to hold dead objects Increasing Memory Usage in Real-Time GC
Mark-Sweep Root Increasing Memory Usage in Real-Time GC
RT-Copying Increasing Memory Usage in Real-Time GC
RT-Mark-Sweep (JamaicaVM) Increasing Memory Usage in Real-Time GC
Available Memory • The amount of available memory using real-time garbage collection and a heap of 12 – 36 byte objects (equally distributed) is • Copying GC: 25% • Mark-Sweep (JamaicaVM): 31% • Reference Counting: 47% Increasing Memory Usage in Real-Time GC
Reference Counting 1 2 1 1 0 1 0 1 0 1 2 1 2 0 1 Root Increasing Memory Usage in Real-Time GC
Reference Counting • Disadvantages to overcome • Recursive freeing • External fragmentation • Reclaiming dead cyclic data structures • Execution speed Increasing Memory Usage in Real-Time GC
Recursive Freeing • The problem was solved for equally sized objects by Weizenbaum (1963) • Decrementing child references is postponed until the memory is reused • Still, all memory is available when it becomes unreachable • However, objects are not always of the same size… Increasing Memory Usage in Real-Time GC
External Fragmentation • As in most file systems, the heap can be divided into equally sized blocks • Small objects are linked using a list, while larger objects use a tree structure • Minor performance penalty for small objects • Weizenbaum’s technique to eliminate recursive freeing can be used on the blocks Increasing Memory Usage in Real-Time GC
Dead Cyclic Data Structures • Manual techniques cover most cases • Breaking cycles • Weak references • Balloon types • Automatic techniques are not real-time • A backup real-time mark-sweep GC can be used but that increases memory overhead Increasing Memory Usage in Real-Time GC
Execution Time • Peep hole optimization • Stack allocation • Object owning (Data flow analysis) Increasing Memory Usage in Real-Time GC
RT-Reference Counting • All operations are predictable in memory usage and execution time • Memory usage is increased by more than 50% for objects larger than 17 bytes • Dead cyclic data structures can be reclaimed (to the cost of memory overhead) Increasing Memory Usage in Real-Time GC
Impact of Block Size Increasing Memory Usage in Real-Time GC
Implementations • Real-Time Reference Counting has been implemented: • As CPP macros • In the JOSES Java compiler • In the Jamaica VM • However more optimizations are required • No backup GC has been implemented Increasing Memory Usage in Real-Time GC
Benchmarks b = dividing objects into blocks bs = spreading the blocks r = using reference counting t = running thousand simulations (= more blocks in use) Increasing Memory Usage in Real-Time GC
Future Work • Full implementation • RT-Mark compact • Memory Usage Analysis • Should critical systems use GC? • Can you not explicitly deallocate all garbage if you can give an upper bound of memory usage? Increasing Memory Usage in Real-Time GC
Conclusion • RT-Reference Counting drastically decrease the memory overhead of real-time systems with a GC • The block size have a minor impact on the memory overhead Increasing Memory Usage in Real-Time GC
Increasing Memory Usage in Real-Time GC Tobias Ritzau and Peter Fritzson Department of Computer and Information Science Linköpings universitet tobri@ida.liu.se http://www.ida.liu.se/~tobri