Dynamic Object Sampling
for Pretenuring
Maria Jump
Department of Computer Sciences
The University of Texas at Austin
mjump@cs.utexas.edu
Stephen M. Blackburn Kathryn S. McKinley
Department of Computer Science Department of Computer Sciences
Australia National University The University of Texas at Austin
Steve.Blackburn@anu.edu.au mckinley@cs.utexas.edu
Current Trends
Object-oriented languages
Lots of small objects
Runtime system treats them uniformly
Objects have distinctive properties
Lifetime, access frequency, locality,
calling context, thread usage, etc.
PROBLEM: How can we discover and
exploit object properties?
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 2
Gathering Object Statistics
Offline statistics
Inconsistent with Java
Obscure phase behavior
Online statistics
Profiling all objects
Dynamic Object Sampling
Statistics only for selected objects
Use to estimate behavior of all objects
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 3
Example: Using Object
Lifetimes for Pretenuring
PROBLEM: Long-lived objects are
allocated into the nursery
SOLUTION: Allocate long-lived objects
directly into mature space
CHALLENGE: Correlating lifetime
behavior with allocation site
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 4
Outline
Motivation
Dynamic Object Sampling
Mechanism
Dynamic Lifetime Prediction
Accuracy vs. Cost
Dynamic Pretenuring
Allocation Survival Phases
Coverage, Accuracy, and Performance
Conclusions
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 5
Dynamic Object Sampling
Modify a bump-pointer allocator
Sample one object every n bytes
Memory chunk:
(for n=128) Sample Tag
128 256 384
Bump Pointer
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 6
Bump-Pointer Allocator
VM_Address alloc(int bytes)
throws VM_PragmaInline { Slow Path
VM_Addresss oldCursor = cursor;
VM_Address newCursor = oldCursor.add(bytes);
(newCursor.GT(sampleLimit))
if (newCursor.GT(limit))
sample(bytes);
return allocSlow(bytes);
cursor = newCursor;
return oldCursor; Sample Path
(Intermediate) :
} 1) adds sample tag
2) collects statistics
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 7
During Garbage Collection
Use GC to update statistics
Trace live objects
Update transient and total statistics
survivor
What’s in the Sample Tag?
SAMPLE TAG FOUND!
1. decode tag word
2. collect statistics
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 8
Dynamic Lifetime Prediction
Encode allocation site identifier into
the object sampling sample tag
Allocation site is a good lifetime predictor
[Blackburn et al.]
Compiler maps identifiers to sites
Accuracy vs. Cost tradeoff
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 9
Implementation and
Experimental Methodology
Jikes RVM 2.3.0.1 with MMTk
SPEC JVM benchmarks, SPEC JBB 2000
with constant workload
3.2 GHz Intel Pentium 4 w/ hyperthreading,
1GB main memory, Linux 2.6.0
Generational/Mark-Sweep (GenMS)
4MB bounded nursery
Pseudoadaptive compilation
Report application time only [Eeckhout et al.]
2nd run methodology
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 10
Accuracy of Sampling
javac
Accuracy
92.5%
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 11
Cost of Sampling
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 12
Object Sampling for
Dynamic Pretenuring
Accurately and efficiently estimate
allocation-site lifetimes
At garbage collection time
Calculate survival rate per allocation site
Compute transient and total statistics
Pretenure:
if (survival rate >= threshold)
then change the allocation target
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 13
Dynamic Allocation Target
case NURSERY_SPACE: table lookup
region = nursery.alloc(…);
if (shortLived(site))
region = nursery.alloc(…);
break;
else
region = matureAlloc(…);
break;
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 14
Dynamic Allocation
Target Overhead
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 15
Dynamic Pretenuring Overhead
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 16
Allocation Phases
Current survival rate is not a
guarantee of future survival
Sampling in older space is ineffective
Collections are infrequent
Small amount of allocation
Periodically allocate site in nursery
BACKSAMPLING
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 17
Backsampling
Protects the system from bad choices
Reduces effectiveness of good choices
When to Backsample?
Backsample
Trigger
= n * f Growth
function:
Number of allocations Constant
for pretenuring Linear
decision Exponential
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 18
Dynamic Pretenuring Policies
Configurations
Parameters cfg1 cfg2 cfg3
sampling interval 256 256 256
minimum samples 8 4 10
pretenuring threshold 80% 80% 85%
backsampling policy linear exponential linear
backsampling shift 1 4 1
decay shift 0 0 1
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 19
Coverage: How much?
45
Long-Lived Pretenuring
40 Pretenured Threshold
None
(% of Total Allocations)
35 100%
Long-Lived Objects
95%
90%
30
85%
80%
25 75%
20
15
10
5
0
jbb javac db mtrt jack raytrace jess compress
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 20
Accuracy: Are we right?
Predicted Long-Lived Objects
45
Incorrect Pretenuring
(% of Total Allocations)
40 Correct Threshold
None
35 100%
95%
30 90%
85%
80%
25 75%
20
15
10
5
0
jbb javac db mtrt jack raytrace jess compress
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 21
GC Time: javac
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 22
Total Time: javac
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 23
Conclusions
Lifetime estimation for dynamic pretenuring
Accurately and efficiently estimates allocation-
site lifetimes
Pretenuring long-lived allocation-sites can
improve runtime
Few opportunities in our programs
Dynamic Object Sampling
Low-overhead
High accuracy
Generic mechanism
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 24
Questions?
Thank You
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 25
GC Time: jess
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 26
Total Time: jess
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 27
Coverage: How much?
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 28
Accuracy: Are we right?
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 29
Coverage: How much?
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 30
Coverage: How much?
45
40
(% of Total Allocations)
35
Long-Lived Objects
30
25
20
15
10
5
0
jbb javac db mtrt jack raytrace jess compress
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 31
Coverage: How much?
45
40
(% of Total Allocations)
35
Long-Lived Objects
30
25
20
15
10
5
0
jbb javac db mtrt jack raytrace jess compress
ISMM, Oct. 25, 2004 Jump, Blackburn, McKinley 32