Professional Documents
Culture Documents
IBM Java Garbage Collection Tuning PDF
IBM Java Garbage Collection Tuning PDF
Chris Bailey
Objectives
Overview
Questions/Answers
First step is ensure that the correct GC policy has been selected for
the workload type
Helpful to have an understanding of GC mechanisms
Object Allocation
Requires a contiguous area of Java heap
Driven by requests from:
The Java application
JNI code
Parallel GC (optthruput)
Parallel Mark Sweep Collector, with compaction avoidance
Created to make use of additional processors on server systems
Designed to increase performance for SMP and not degrade
performance for uni-processor systems
0 GB 2 GB
LOA
Heap Size
Heap Base Heap Limit
GC Helper Threads
Parallelism achieved through the use of GC Helper Threads
Parked set of threads that wake to share GC work
Main GC thread generates the root set of objects
Helper threads share the work for the rest of the phases
Number of helpers is one less than the number of processing
units
So helper threads and main GC thread equals the number of
processing units
Configurable using -Xgcthreads
Concurrent GC (optavgpause)
Reduces and makes more consistent the time spent inside Stop the
World GC
Reduction usually between 90 and 95%
Concurrent Kickoff
Dangling pointer!
Allocate Space
Survivor Space Survivor
Allocate Space
Space
Subpooling (subpool)
Goals:
Reduce allocation lock contention by distributing free memory into
multiple lists
Reduce allocation contention through use of atomic operations instead of
a heap lock
Prevent premature garbage collections by using a best fit (or closer to
best fit) policy instead of address ordered
Ideal for very large SMP systems where large amounts data is being
allocated
where there is heap lock contention
Monitoring GC Activity
Use of Verbose GC logging
only data that is required for GC performance tuning
Graph Verbose GC output using GC and Memory Visualizer (GCMV) from ISA
Performance Cost:
(very) basic testing shows a 2% overhead for GC duration of 200ms
eg. if application GC overhead is 5%, it would become 5.1%
Rule of thumb: if GC overhead is > 10%, youve most likely chosen the wrong one
If object is fits in the nursery but fills it, frequent nursery collects will have to occur
Too frequent nursery collects mean objects are likely to survive and need copying
Copying is an expensive process
If (Very) Large Objects are being used, a sufficiently large enough nursery is required
0x40000000 0xC0000000
0x0 0x80000000 0xFFFFFFFF
0x40000000 0xC0000000
0x0 0x80000000 0xFFFFFFFF
Libraries
On AIX:
0 GB 2 GB 4 GB
1 GB 3 GB
Kernel Libraries
0x40000000 0xC0000000
0x0 0x80000000 0xFFFFFFFF
Memory not allocated to the Java Heap is available to the native heap
0x40000000 0xC0000000
0x0 0x80000000 0xFFFFFFFF
VM Resources Libraries
0 GB 2 GB 4 GB
1 GB 3 GB
0x40000000 0xC0000000
0x0 0x80000000 0xFFFFFFFF
VM Resources
0 GB 2 GB 4 GB
1 GB 3 GB
0x3 0x7 0xD
0x40000000 0xC0000000
0x0 0x80000000 0xFFFFFFFF
VM Resources
0x40000000 0xC0000000
0x0 0x80000000 0xFFFFFFFF
VM Resources
TASK_SIZE PAGE_OFFSET
z/OS:
0 GB 2 GB
1 GB
Java Heap
0x40000000
0x0 0x7FFFFFFF
VM Resources
Moving to 64bit
Moving to 64bit remove the Java heap size limit
The maximum heap size setting should therefore be 43% larger than the
maximum occupancy of the application
Maximum occupancy + 43% means occupancy at 70% of total heap
Eg. For 70MB occupancy, 100MB Max heap required, which is 70MB +
43% of 70MB
Heap Occupancy
40%
Time
Heap Occupancy
-Xmaxf
Time
WebSphere Support Technical Exchange 48
IBM Software Group
Fixed or Variable??
Again, dependent on application
Nursery Tenured
General Advice:
Fix the new space size
Size the tenured space as you would for a flat heap
Summary
GC Policy should be chosen according to application scenario
Min=Max heap size is right for some applications, but not for others
View a Flash replay with step-by-step instructions for using the Electronic Service
Request (ESR) tool for submitting problems electronically:
http://www.ibm.com/software/websphere/support/d2w.html
Sign up to receive weekly technical My support emails:
http://www.ibm.com/software/support/einfo.html