Professional Documents
Culture Documents
Java Sig2004 Garbagecollection
Java Sig2004 Garbagecollection
Agenda
JA-SIG 2004
Generational system
JA-SIG 2004
Young generation
Old generation
Permanent generation
Generational Garbage
Collection
Aging of objects
Program
Allocation
Young
Generation
Old
Generation
5
JA-SIG 2004
Throughput Collectors
JA-SIG 2004
JA-SIG 2004
Application
Threads
Parallel GC
InitialMark
Marking
ReMark
Sweeping
Reset
E Eden
O Old Generation Heap
O1 Old Generation Heap After A Concurrent Collection
JA-SIG 2004
Throughput Collectors
JA-SIG 2004
Throughput Collectors
Parallel Throughput
Collector
(Young Generation)
Mark-Sweep Collector
(Old Generation)
Application
Threads
E
S
Parallel GC
E
S
E
10
O O1
JA-SIG 2004
E Eden
S Survivor Space
O Old Generation Heap
O1 Old Generation Heap After Collection
Single Thread
GC
Throughput Collectors
11
JA-SIG 2004
12
JA-SIG 2004
Problems of Garbage
Collection
13
Adds latency
JA-SIG 2004
Applications like mobile and desktop GUIs (thick and thin client)
Requirements
Problems
See
GC frequency increase as heap fills up faster
GC takes over application time, leading to performance
JA-SIGproblems
2004
14
Requirements
15
JA-SIG 2004
Problems
See
16
JA-SIG 2004
Solution
17
JA-SIG 2004
Performance Tuning
Automatic tuning
18
JA-SIG 2004
19
JA-SIG 2004
20
What is it?
Empirical modeling
Theoretical projections
JA-SIG 2004
21
JA-SIG 2004
The Model
22
JA-SIG 2004
GC pauses
GC frequency
23
Total
Heap sizes
24
25
Data Calculated
26
JA-SIG 2004
General Recommendations
based on the model (1)
27
Reduce GC pauses
Reduce GC sequential overhead
JA-SIG 2004
General Recommendations
Based On The Model (2)
28
JA-SIG 2004
Empirical Modeling
29
Heap sizes
No. of Processors
GC sequential overhead
GC concurrent overhead, etc.
Application efficiency
JA-SIG 2004
30
JA-SIG 2004
31
JA-SIG 2004
GC pause (latency)
GC frequency
GC sequential load (bandwidth)
% CPU utilization, Speedup
Application efficiency
Allocation rate, Promotion rate
Size and duration of Short lived data
Size and duration of Long lived data
GC Portal
32
JA-SIG 2004
GC Portal
33
34
JA-SIG 2004
GC Portal
35
JA-SIG 2004
36
JA-SIG 2004
GC Portal
37
JA-SIG 2004
38
JA-SIG 2004
GC Portal
39
http://java.sun.com/developer/technicalArticles/Pro
gramming/GCPortal/index.html
http://sdc.sun.com/gcportal/
JA-SIG 2004
40
JA-SIG 2004
41
Use -XX:+DisableExplicitGC
Reducing Frequency Of GC
Frequency of a collection is dependent on
42
JA-SIG 2004
43
Oversized heap
44
JA-SIG 2004
45
46
JA-SIG 2004
Ergonomics
47
What is ergonomics?
Why do it?
When is it used?
JA-SIG 2004
What Is Ergonomics?
48
Compiler
Garbage collector
Heap size
JA-SIG 2004
AKA GC ergonomics
Why Do Ergonomics?
Better Performance
Ease of Use
49
JA-SIG 2004
Exceptions
50
2 CPUs, 2 Gbytes
JA-SIG 2004
Server compiler
Parallel GC collector
Maximum heap
Smaller of
Initial heap
Smaller of
51
physical memory
1 Gbyte
JA-SIG 2004
What is GC Ergonomics?
User specifies
GC tunes
52
JA-SIG 2004
Why Do GC Ergonomics?
Common complaints
Solution
53
JA-SIG 2004
Throughput goal
54
Minimum footprint
JA-SIG 2004
Throughput Example
Throughput Only
180000
170000
160000
150000
140000
130000
120000
110000
100000
90000
80000
70000
60000
50000
40000
30000
20000
250
500
750
1000
Time (sec)
55
JA-SIG 2004
1250
1500
1750
Throughput Example
Throughput Only
1700
1600
1500
1400
1300
1200
1100
1000
900
800
700
600
500
400
300
0
250
500
750
1000
Time (sec)
56
JA-SIG 2004
1250
1500
1750
Throughput Example
Throughput Only
65
60
55
50
45
40
35
30
25
20
15
10
5
0
0
250
500
750
1000
Time (sec)
57
JA-SIG 2004
1250
1500
1750
Pause Example
Pause Goal - 1250ms
1300
1200
1100
1000
900
800
700
600
500
400
300
200
250
500
750
1000
Time (s)
58
JA-SIG 2004
1250
1500
1750
Ergonomics Usage
-XX:GCTimeRatio=nnn
-XX:MaxGCPauseMillis=nnn
59
JA-SIG 2004
Ergonomics Strategy
60
JA-SIG 2004
61
JA-SIG 2004
62
JA-SIG 2004
Provides MBeans
GarbageCollectorMXBean
MemoryManagerMXBean
MemoryMXBean
MemoryPoolMXBean
Other MBeans
jconsole
63
JA-SIG 2004
jconsole jvmpid
jconsole - GarbageCollection
64
JA-SIG 2004
65
JA-SIG 2004
jstat
Compiler statistics
Class loader statistics
GC statistics
GC statistics include
cause of GC
generation information
66
JA-SIG 2004
capacity
utilization
jstat Usage
67
S0
S1
12.44
0.00
27.20 9.49
96.70 78
0.176
0.495
0.672
12.44
0.00
62.16 9.49
96.70 78
0.176
0.495
0.672
12.44 0.00
83.97 9.49
96.70 78
0.176
0.495
0.672
0.00
0.00
96.70 79
0.177
0.495
0.673
JA-SIG 2004
7.74
9.51
YGC
Summary
68
Resources
http://java.sun.com/docs/hotspot/index.html
http://java.sun.com/docs/hotspot/gc1.4.2/
http://developers.sun.com/techtopics/mobility/midp/articles/garbagecollection2/
http://http://java.sun.com/developer/technicalArticles/Programming/turbo/
http://java.sun.com/docs/hotspot/VMOptions.html
http://sdc.sun.com/gcportal/
http://java.sun.com/developer/technicalArticles/Programming/GCPortal/index.html
Contact:
Nagendra.Nagarajayya@Sun.Com
gc-portal-team@sun.com
69
JA-SIG 2004