An Adaptive, Region-based Allocator for Java - PowerPoint PPT Presentation

About This Presentation
Title:

An Adaptive, Region-based Allocator for Java

Description:

inheriting its caller's region. New regions are freed before exiting. Escaping Objects ... Requiring all such methods to inherit caller's region. Allocation Sites ... – PowerPoint PPT presentation

Number of Views:19
Avg rating:3.0/5.0
Slides: 37
Provided by: Tom80
Category:

less

Transcript and Presenter's Notes

Title: An Adaptive, Region-based Allocator for Java


1
An Adaptive, Region-based Allocator for Java
  • Feng Qian Laurie Hendren
  • 2002

2
Roadmap
  • Stack allocation
  • A better algorithm
  • Implementation issues
  • Experiments results
  • Future enhancements

3
Stack Allocation - Advantages
  • Non Escaping objects can be allocated on the
    stack
  • Objects on the stack can be freed without GC
    intervention

4
Stack Allocation - Disadvantages
  • Static escape analysis requires whole program
    analysis
  • Cant work with Dynamic Class Loading
  • Large arrays
  • Objects created in a loop with overlapping
    lifetimes

5
The Solution
  • Treat local regions as stack frames extensions
  • Stackable objects can be created in local regions
  • Regions which contain only non-escaping objects
    are freed when the stack frame is popped

6
Adaptive Escape Analysis
  • Dynamically categorize allocation sites as local
    or non-local
  • Detect escaping objects by write barriers
  • Mark region as dirty and give to GC
  • Mark allocation site as non-local
  • As execution proceeds, local regions are more
    likely to stay clean

7
Topics - Implementation
  • Regions
  • Escaping Objects
  • Allocation Sites
  • The Allocator

8
Regions
  • Region points to a list of pages in the heap
  • Token represents regions
  • Global and Free regions
  • Local regions

9
Global Region
  • Objects created in non-local allocation sites
  • Pages containing objects that have escaped local
    regions
  • Work with GC

10
Free Region
  • List of free pages
  • The Global and Local Regions takes pages from
    this region

11
Local Regions
  • Used as a stack extension
  • Assigned to activations stack frame
  • A method activation obtains a region by
  • getting a new region from the allocator
  • inheriting its callers region
  • New regions are freed before exiting

12
Escaping Objects
  • Escaping Object - pointed by an object in another
    region
  • Write barriers before bytecode instructions
  • putstatic
  • putfield lhs.frhs
  • aastore

13
Escaping Objects
  • What about methods returning objects ?
  • Inserting write barriers before bytecode areturn
  • Requiring all such methods to inherit callers
    region

14
Allocation Sites
  • Allocation sites are uniquely indexed
  • Allocation sites are all initialized to local
  • Each object stores its allocation site in its
    header
  • An allocation site becomes non-local when an
    object allocated at the site escapes
  • A bit vector is used to record states of
    allocation sites

15
The Allocator
  • Different GCs have different heap organizations
  • Mark Sweep use a single space heap
  • Copying Collectors use two spaces heap
  • Generational Collectors use many spaces for aging
    areas
  • The heap we discuss is where new objects are
    allocated

16
Memory Organization
17
NewRegion
  • Free region tokens are managed by a stack
  • NewRegion pops a region and returns it
  • If no region is left then the Global region is
    returned

18
FreeRegion
  • If the Dirty field is clean, add the pages to the
    Free region
  • Else, add the pages to the Global region
  • Push region token to the tokens stack

19
Alloc
  • Only local sites allocate from local regions
  • First try to allocate memory from the first page
  • Add a new page if necessary
  • Look for a bunch of continuous pages for large
    object

20
Lazy Region Allocation
  • Many activation records have empty regions
  • methods that do not allocate objects
  • non-local allocations
  • Call NewRegion only when a new region is needed

21
Adaptive VM
  • Assign unique indexes to allocation sites at
    compilation
  • Store allocation site index in object header
  • Store region ID in the stack frame
  • Methods prologue and epilogue have more
    instructions
  • Write barriers before specific bytecodes

22
Prototype Implementation
  • Jikes RVM - baseline compiler
  • Semi-space copying collector
  • Fixed page size
  • Objects taking multiple pages

23
Experimental Results
  • Allocation sites
  • Effects of regions and page sizes on collections
    and fragmentation
  • Allocation behavior
  • Behavior of write barriers
  • Effect of adaptation

24
Allocation Sites
25
Effect of regions and page sizes on collections
and fragmentation
26
Allocation Behavior
27
Behavior of write barriers
28
Region reclaimed space
29
Region allocated at runtime
30
Effect of adaptation
31
Effect of adaptation
32
Effect of adaptation
  • Current scheme predicts future objects will
    escape after one object from that site escapes
  • Without adaptation predicts future objects
    non-escaping

33
Summary
  • Page size is important - overhead in froth and
    expensive searches is low
  • For many benchmarks a high percent of memory can
    be put in local regions
  • The average write barrier operations are low cost
  • Adaptation finds local sites

34
Runtime Improvements
  • The overhead of current implementation is still
    too high !
  • Functions used by region management are written
    in Java
  • Ongoing work on a more optimized version

35
Possible Enhancements
  • Use more than one bit to find non-local
    allocation sites
  • Use a dirty bit per page and not per region
  • Periodically reset allocation sites to local

36
The End
Write a Comment
User Comments (0)
About PowerShow.com