SlideShare uma empresa Scribd logo
1 de 65
Baixar para ler offline
Understanding Java
Garbage Collection
and what you can do about it

Gil Tene, CTO & co-Founder, Azul Systems
©2011 Azul Systems, Inc.
This Talk’s Purpose / Goals
This talk is focused on GC education
This is not a “how to use flags to tune a collector” talk
This is a talk about how the “GC machine” works
Purpose: Once you understand how it works, you can
use your own brain...
You’ll learn just enough to be dangerous...
The “Azul makes the world’s greatest GC” stuff will
only come at the end, I promise...
©2011 Azul Systems, Inc.
About me: Gil Tene
co-founder, CTO
@Azul Systems
Have been working on
“think different” GC
approaches since 2002
Created Pauseless & C4
core GC algorithms
(Tene, Wolf)

A Long history building
Virtual & Physical
Machines, Operating
Systems, Enterprise
apps, etc...
©2011 Azul Systems, Inc.	

	

	

	

	

* working on real-world trash compaction issues, circa 2004
About Azul
Vega

We make scalable Virtual
Machines
Have built “whatever it takes
to get job done” since 2002
3 generations of custom SMP
Multi-core HW (Vega)
Now Pure software for
commodity x86 (Zing)

C4

“Industry firsts” in Garbage
collection, elastic memory,
Java virtualization, memory
scale
©2011 Azul Systems, Inc.
High level agenda
GC fundamentals and key mechanisms
Some GC terminology & metrics
Classifying currently available collectors
The “Application Memory Wall” problem
The C4 collector: What an actual solution looks like...

©2011 Azul Systems, Inc.
Memory use
How many of you use heap sizes of:
F

more than ½ GB?

F

more than 1 GB?

F

more than 2 GB?

F

more than 4 GB?

F

more than 10 GB?

F

more than 20 GB?

F

more than 50 GB?

©2011 Azul Systems, Inc.
Why should you care?

©2011 Azul Systems, Inc.
The story of the good little architect
A good architect must, first and foremost, be able to
impose their architectural choices on the project...
Early in Azul’s concurrent collector days, we
encountered an application exhibiting 18 second pauses
Upon investigation, we found the collector was performing 10s of
milliions of object finalizations per GC cycle
*We have since made reference processing fully concurrent...

Every single class written in the project had a finalizer
The only work the finalizers did was nulling every reference field

The right discipline for a C++ ref-counting environment
The wrong discipline for a precise garbage collected environment
©2011 Azul Systems, Inc.
Trying to solve GC problems in application
architecture is like throwing knives
You probably shouldn’t do it blindfolded
It takes practice and understanding to get it right
You can get very good at it, but do you really want to?
Will all the code you leverage be as good as yours?

Examples:
Object pooling
Off heap storage
Distributed heaps
...
(In most cases, you end up building your own garbage collector)
©2011 Azul Systems, Inc.
Most of what People seem to “know”
about Garbage Collection is wrong
In many cases, it’s much better than you may think
GC is extremely efficient. Much more so that malloc()
Dead objects cost nothing to collect
GC will find all the dead objects (including cyclic graphs)
...

In many cases, it’s much worse than you may think
Yes, it really does stop for ~1 sec per live GB.
No, GC does not mean you can’t have memory leaks
No, those pauses you eliminated from your 20 minute test are
not gone
...
©2011 Azul Systems, Inc.
Some GC Terminology

©2011 Azul Systems, Inc.
A Basic Terminology example:
What is a concurrent collector?
A Concurrent Collector performs garbage collection
work concurrently with the application’s own execution

A Parallel Collector uses multiple CPUs to perform
garbage collection

©2011 Azul Systems, Inc.
Classifying a collector’s operation
A Concurrent Collector performs garbage collection
work concurrently with the application’s own execution
A Parallel Collector uses multiple CPUs to perform
garbage collection
A Stop-the-World collector performs garbage
collection while the application is completely stopped
An Incremental collector performs a garbage collection
operation or phase as a series of smaller discrete
operations with (potentially long) gaps in between
Mostly means sometimes it isn’t (usually means a
different fall back mechanism exists)
©2011 Azul Systems, Inc.
Precise vs. Conservative Collection
A Collector is Conservative if it is unaware of all
object references at collection time, or is unsure
about whether a field is a reference or not
A Collector is Precise if it can fully identify and
process all object references at the time of collection
A collector MUST be precise in order to move objects
The COMPILERS need to produce a lot of information (OopMaps)

All commercial server JVMs use precise collectors
All commercial server JVMs use some form of a moving collector

©2011 Azul Systems, Inc.
Safepoints
A GC Safepoint is a point or range in a thread’s
execution where the collector can identify all the
references in that thread’s execution stack
“Safepoint” and “GC Safepoint” are often used interchangeably
But there are other types of safepoints, including ones that require
more information than a GC safepoint does (e.g. deoptimization)

“Bringing a thread to a safepoint” is the act of
getting a thread to reach a safepoint and not execute
past it
Close to, but not exactly the same as “stop at a safepoint”
e.g. JNI: you can keep running in, but not past the safepoint
Safepoint opportunities are (or should be) frequent

In a Global Safepoint all threads are at a Safepoint
©2011 Azul Systems, Inc.
What’s common to all
precise GC mechanisms?
Identify the live objects in the memory heap
Reclaim resources held by dead objects
Periodically relocate live objects
Examples:
Mark/Sweep/Compact (common for Old Generations)
Copying collector (common for Young Generations)
©2011 Azul Systems, Inc.
Mark (aka “Trace”)
Start from “roots” (thread stacks, statics, etc.)
“Paint” anything you can reach as “live”
At the end of a mark pass:
all reachable objects will be marked “live”
all non-reachable objects will be marked
“dead” (aka “non-live”).
Note: work is generally linear to “live set”
©2011 Azul Systems, Inc.
Sweep

Scan through the heap, identify “dead” objects and
track them somehow
(usually in some form of free list)

Note: work is generally linear to heap size

©2011 Azul Systems, Inc.
Compact
Over time, heap will get “swiss cheesed”: contiguous
dead space between objects may not be large
enough to fit new objects (aka “fragmentation”)
Compaction moves live objects together to reclaim
contiguous empty space (aka “relocate”)
Compaction has to correct all object references to
point to new object locations (aka “remap”)
Remap scan must cover all references that could
possibly point to relocated objects
Note: work is generally linear to “live set”
©2011 Azul Systems, Inc.
Copy
Copying collector moves all live objects from a
“from” space to a “to” space & reclaims “from” space
At start of copy, all objects are in “from” space and
all references point to “from” space.
Start from “root” references, copy any reachable
object to “to” space, correcting references as we go
At end of copy, all objects are in “to” space, and all
references point to “to” space
Note: work generally linear to “live set”
©2011 Azul Systems, Inc.
Mark/Sweep/Compact, Copy, Mark/Compact
Copy requires 2x the max. live set to be reliable
Mark/Compact [typically] requires 2x the max. live set
in order to fully recover garbage in each cycle
Mark/Sweep/Compact only requires 1x (plus some)
Copy and Mark/Compact are linear only to live set
Mark/Sweep/Compact linear (in sweep) to heap size
Mark/Sweep/(Compact) may be able to avoid some
moving work
Copying is [typically] “monolithic”
©2011 Azul Systems, Inc.
Generational Collection
Generational Hypothesis: most objects die young
Focus collection efforts on young generation:
Use a moving collector: work is linear to the live set
The live set in the young generation is a small % of the space
Promote objects that live long enough to older generations

Only collect older generations as they fill up
“Generational filter” reduces rate of allocation into older generations

Tends to be (order of magnitude) more efficient
Great way to keep up with high allocation rate
Practical necessity for keeping up with processor throughput
©2011 Azul Systems, Inc.
Generational Collection
Requires a “Remembered set”: a way to track all
references into the young generation from the outside
Remembered set is also part of “roots” for young
generation collection
No need for 2x the live set: Can “spill over” to old gen
Usually want to keep surviving objects in young
generation for a while before promoting them to the
old generation
Immediate promotion can dramatically reduce gen. filter efficiency
Waiting too long to promote can dramatically increase copying work
©2011 Azul Systems, Inc.
How does the remembered set work?
Generational collectors require a “Remembered set”: a
way to track all references into the young generation
from the outside
Each store of a NewGen reference into an OldGen
object needs to be intercepted and tracked
Common technique: “Card Marking”
A bit (or byte) indicating a word (or region) in OldGen is “suspect”

Write barrier used to track references
Common technique (e.g. HotSpot): blind stores on reference write
Variants: precise vs. imprecise card marking, conditional vs. nonconditional
©2011 Azul Systems, Inc.
The typical combos
in commercial server JVMS
Young generation usually uses a copying collector
Young generation is usually monolithic, stop-the-world

Old generation usually uses Mark/Sweep/Compact
Old generation may be STW, or Concurrent, or
mostly-Concurrent, or Incremental-STW, or mostlyIncremental-STW
©2011 Azul Systems, Inc.
Useful terms for discussing
garbage collection
Generational

Mutator

Collects young objects and long lived
objects separately.

Your program…

Parallel

Promotion

Can use multiple CPUs

Allocation into old generation

Concurrent
Runs concurrently with program

Pause
A time duration in which the
mutator is not running any code

Something that is done in a pause

Monolithic Stop-The-World
Something that must be done in
it’s entirety in a single pause
	

	

	

	

Finding all live objects

Sweeping
Locating the dead objects

Compaction

Stop-The-World (STW)

©2011 Azul Systems, Inc.	

Marking

	

Defragments heap
Moves objects in memory
Remaps all affected references
Frees contiguous memory regions
Useful metrics for discussing
garbage collection
Heap population (aka Live set)
How much of your heap is alive

Allocation rate

Cycle time
How long it takes the collector to free
up memory

Marking time

How fast you allocate

How long it takes the collector to find
all live objects

Mutation rate
How fast your program updates
references in memory

Heap Shape
The shape of the live object graph
* Hard to quantify as a metric...

Object Lifetime

Sweep time
How long it takes to locate dead
objects
* Relevant for Mark-Sweep

Compaction time
How long it takes to free up memory
by relocating objects

How long objects live

* Relevant for Mark-Compact

©2011 Azul Systems, Inc.
Empty memory
and CPU/throughput

©2011 Azul Systems, Inc.
Two Intuitive limits

If we had infinite empty memory, we would never have
to collect, and GC would take 0% of the CPU time
If we had exactly 1 byte of empty memory at all
times, the collector would have to work “very hard”,
and GC would take 100% of the CPU time
GC CPU % will follow a rough 1/x curve between these
two limit points, dropping as the amount of memory
increases.

©2011 Azul Systems, Inc.
Empty memory needs
(empty memory == CPU power)
The amount of empty memory in the heap is the
dominant factor controlling the amount of GC work
For both Copy and Mark/Compact collectors, the
amount of work per cycle is linear to live set
The amount of memory recovered per cycle is equal to
the amount of unused memory (heap size) - (live set)
The collector has to perform a GC cycle when the
empty memory runs out
A Copy or Mark/Compact collector’s efficiency doubles
with every doubling of the empty memory
©2011 Azul Systems, Inc.
What empty memory controls
Empty memory controls efficiency (amount of collector
work needed per amount of application work
performed)
Empty memory controls the frequency of pauses (if
the collector performs any Stop-the-world operations)
Empty memory DOES NOT control pause times (only
their frequency)
In Mark/Sweep/Compact collectors that pause for
sweeping, more empty memory means less frequent but
LARGER pauses
©2011 Azul Systems, Inc.
Some non-monolithic-STW stuff

©2011 Azul Systems, Inc.
Concurrent Marking
Mark all reachable objects as “live”, but object graph
is “mutating” under us.
Classic concurrent marking race: mutator may move
reference that has not yet been seen by the marker
into an object that has already been visited
If not intercepted or prevented in some way, will corrupt the heap

Example technique: track mutations, multi-pass marking
Track reference mutations during mark (e.g. in card table)
Re-visit all mutated references (and track new mutations)
When set is “small enough”, do a STW catch up (mostly concurrent)

Note: work grows with mutation rate, may fail to finish
©2011 Azul Systems, Inc.
Incremental Compaction
Track cross-region remembered sets (which region
points to which)
To compact a single region, only need to scan regions
that point into it to remap all potential references
identify regions sets that fit in limited time
Each such set of regions is a Stop-the-World increment
Safe to run application between (but not within) increments

Note: work can grow with the square of the heap size
The number of regions pointing into a single region is generally
linear to the heap size (the number of regions in the heap)
©2011 Azul Systems, Inc.
Delaying the inevitable
Compaction is inevitable in practice
And compacting anything requires scanning/fixing all references to it

Delay tactics focus on getting “easy empty space” first
This is the focus for the vast majority of GC tuning

Most objects die young [Generational]
So collect young objects only, as much as possible
But eventually, some old dead objects must be reclaimed

Most old dead space can be reclaimed without moving it
[e.g. CMS] track dead space in lists, and reuse it in place
But eventually, space gets fragmented, and needs to be moved

Much of the heap is not “popular” [e.g. G1, “Balanced”]
A non popular region will only be pointed to from a small % of the heap
So compact non-popular regions in short stop-the-world pauses
But eventually, popular objects and regions need to be compacted
©2011 Azul Systems, Inc.
Classifying common collectors

©2011 Azul Systems, Inc.
The typical combos
in commercial server JVMS
Young generation usually uses a copying collector
Young generation is usually monolithic, stop-the-world

Old generation usually uses a Mark/Sweep/Compact
collector
Old generation may be STW, or Concurrent, or mostly-Concurrent,
or Incremental-STW, or mostly-Incremental-STW

©2011 Azul Systems, Inc.
HotSpot™ ParallelGC
Collector mechanism classification

Monolithic Stop-the-world copying NewGen

Monolithic Stop-the-world Mark/Sweep/Compact OldGen

©2011 Azul Systems, Inc.
HotSpot™ ConcMarkSweepGC (aka CMS)
Collector mechanism classification
Monolithic Stop-the-world copying NewGen (ParNew)
Mostly Concurrent, non-compacting OldGen (CMS)
Mostly Concurrent marking
Mark concurrently while mutator is running
Track mutations in card marks
Revisit mutated cards (repeat as needed)
Stop-the-world to catch up on mutations, ref processing, etc.

Concurrent Sweeping
Does not Compact (maintains free list, does not move objects)

Fallback to Full Collection (Monolithic Stop the world).
Used for Compaction, etc.
©2011 Azul Systems, Inc.
HotSpot™ G1GC (aka “Garbage First”)
Collector mechanism classification
Monolithic Stop-the-world copying NewGen
Mostly Concurrent, OldGen marker
Mostly Concurrent marking
Stop-the-world to catch up on mutations, ref processing, etc.

Tracks inter-region relationships in remembered sets

Stop-the-world mostly incremental compacting old gen
Objective: “Avoid, as much as possible, having a Full GC…”
Compact sets of regions that can be scanned in limited time
Delay compaction of popular objects, popular regions

Fallback to Full Collection (Monolithic Stop the world).
Used for compacting popular objects, popular regions, etc.
©2011 Azul Systems, Inc.
The “Application Memory Wall”

©2011 Azul Systems, Inc.
Memory use
How many of you use heap sizes of:
F

more than ½ GB?

F

more than 1 GB?

F

more than 2 GB?

F

more than 4 GB?

F

more than 10 GB?

F

more than 20 GB?

F

more than 50 GB?

©2011 Azul Systems, Inc.
Reality check: servers in 2012
Retail prices, major web server store (US $, March 2012)
16 vCore, 96GB server

≈ $5K

16 vCore, 256GB server

≈ $9K

24 vCore, 384GB server

≈ $14K

32 vCore, 1TB server

≈ $35K

Cheap (< $1/GB/Month), and roughly linear to ~1TB
10s to 100s of GB/sec of memory bandwidth
©2011 Azul Systems, Inc.
The Application Memory Wall
A simple observation:
Application instances appear to be unable to
make effective use of modern server memory
capacities

The size of application instances as a % of a
server’s capacity is rapidly dropping

©2011 Azul Systems, Inc.
How much memory do applications need?
“640KB ought to be enough for anybody”
WRONG!
So what’s the right number?
6,400K?
64,000K?
640,000K?
6,400,000K?
64,000,000K?
There is no right number
Target moves at 50x-100x per decade
©2011 Azul Systems, Inc.	

	

	

	

	

	

“I've said some stupid things and
some wrong things, but not that.
No one involved in computers
would ever say that a certain
amount of memory is enough for
all time …” - Bill Gates, 1996
“Tiny” application history
Assuming Moore’s Law means:
2010

“transistor counts grow at ≈2x
every ≈18 months”
It also means memory size grows
≈100x every 10 years

1990

1980

??? GB apps on 256 GB
Application
Memory Wall

2000

1GB apps on a 2 – 4 GB server

10MB apps on a 32 – 64 MB server

100KB apps on a ¼ to ½ MB Server
“Tiny”: would be “silly” to distribute

©2011 Azul Systems, Inc.
What is causing the
Application Memory Wall?
Garbage Collection is a clear and dominant cause
There seem to be practical heap size limits for
applications with responsiveness requirements
[Virtually] All current commercial JVMs will exhibit a
multi-second pause on a normally utilized 2-4GB heap.
It’s a question of “When” and “How often”, not “If”.
GC tuning only moves the “when” and the “how often” around

Root cause: The link between scale and responsiveness
©2011 Azul Systems, Inc.
What quality of GC is responsible
for the Application Memory Wall?
It is NOT about overhead or efficiency:
CPU utilization, bottlenecks, memory consumption and utilization

It is NOT about speed
Average speeds, 90%, 99% speeds, are all perfectly fine

It is NOT about minor GC events (right now)
GC events in the 10s of msec are usually tolerable for most apps

It is NOT about the frequency of very large pauses
It is ALL about the worst observable pause behavior
People avoid building/deploying visibly broken systems
©2011 Azul Systems, Inc.
GC Problems

©2011 Azul Systems, Inc.
Framing the discussion:
Garbage Collection at modern server scales
Modern Servers have 100s of GB of memory
Each modern x86 core (when actually used) produces
garbage at a rate of ¼ - ½ GB/sec +
That’s many GB/sec of allocation in a server

Monolithic stop-the-world operations are the cause of
the current Application Memory Wall
©2011 Azul Systems, Inc.
The things that seem “hard” to do in GC
Robust concurrent marking
References keep changing
Multi-pass marking is sensitive to mutation rate
Weak, Soft, Final references “hard” to deal with concurrently

[Concurrent] Compaction…
It’s not the moving of the objects…
It’s the fixing of all those references that point to them
How do you deal with a mutator looking at a stale reference?
If you can’t, then remapping is a [monolithic] STW operation

Young Generation collection at scale
Young Generation collection is generally monolithic, Stop-The-World
Young generation pauses are only small because heaps are tiny
A 100GB heap will regularly have several GB of live young stuff…
©2011 Azul Systems, Inc.
How can we break through the
Application Memory Wall?

©2011 Azul Systems, Inc.
We need to solve the right problems
Focus on the causes of the Application Memory Wall
Root cause: Scale is artificially limited by responsiveness

Responsiveness must be unlinked from scale
Heap size, Live Set size, Allocation rate, Mutation rate

Responsiveness must be continually sustainable
Can’t ignore “rare” events

Eliminate all Stop-The-World Fallbacks
At modern server scales, any STW fall back is a failure
©2011 Azul Systems, Inc.
The problems that need solving
(areas where the state of the art needs improvement)

Robust Concurrent Marking
In the presence of high mutation and allocation rates
Cover modern runtime semantics (e.g. weak refs)

Compaction that is not monolithic-stop-the-world
Stay responsive while compacting many-GB heaps
Must be robust: not just a tactic to delay STW compaction
[current “incremental STW” attempts fall short on robustness]

Non-monolithic-stop-the-world Generational collection
Stay responsive while promoting multi-GB data spikes
Concurrent or “incremental STW” may both be ok
Surprisingly little work done in this specific area
©2011 Azul Systems, Inc.
Azul’s “C4” Collector
Continuously Concurrent Compacting Collector
Concurrent, compacting new generation
Concurrent, compacting old generation
Concurrent guaranteed-single-pass marker
Oblivious to mutation rate
Concurrent ref (weak, soft, final) processing

Concurrent Compactor
Objects moved without stopping mutator
References remapped without stopping mutator
Can relocate entire generation (New, Old) in every GC cycle

No stop-the-world fallback
Always compacts, and always does so concurrently
©2011 Azul Systems, Inc.
Sample responsiveness improvement

๏ SpecJBB + Slow churning 2GB LRU Cache
๏ Live set is ~2.5GB across all measurements
๏ Allocation rate is ~1.2GB/sec across all measurements
©2011 Azul Systems, Inc.
Fun with jHiccup
Zing 5, 1GB in an 8GB heap

Oracle HotSpot CMS, 1GB in an 8GB heap

Hiccups&by&Time&Interval&
Max"per"Interval"

99%"

99.90%"

Hiccups&by&Time&Interval&

99.99%"

Max"

Max"per"Interval"

20"
15"
10"
5"
0"

Max"

12000"
10000"
8000"
6000"
4000"
2000"

500"

1000"

1500"

2000"

2500"

3000"

3500"

0"

500"

1000"

&Elapsed&Time&(sec)&

1500"

2000"

2500"

3000"

3500"

&Elapsed&Time&(sec)&

Hiccups&by&Percen*le&Distribu*on&

Hiccups&by&Percen*le&Distribu*on&
14000"

20"

Hiccup&Dura*on&(msec)&

25"

Hiccup&Dura*on&(msec)&

99.99%"

0"
0"

Max=20.384&

15"
10"
5"
0"

99.90%"

14000"

Hiccup&Dura*on&(msec)&

Hiccup&Dura*on&(msec)&

25"

99%"

0%"

90%"

99%"

&
99.9%"
99.99%"
&
Percen*le&

99.999%"

99.9999%"

Max=13156.352&

12000"
10000"
8000"
6000"
4000"
2000"
0"

0%"

90%"

99%"

&99.9%"
&
Percen*le&

99.99%"

99.999%"
Zing 5, 1GB in an 8GB heap

Oracle HotSpot CMS, 1GB in an 8GB heap

Hiccups&by&Time&Interval&
Max"per"Interval"

99%"

99.90%"

Hiccups&by&Time&Interval&

99.99%"

Max"

Max"per"Interval"

12000"

99.99%"

Max"

12000"

10000"
8000"
6000"
4000"
2000"
0"

10000"
8000"
6000"
4000"
2000"
0"

0"

500"

1000"

1500"

2000"

2500"

3000"

3500"

0"

500"

1000"

&Elapsed&Time&(sec)&

1500"

2000"

2500"

3000"

3500"

&Elapsed&Time&(sec)&

Hiccups&by&Percen*le&Distribu*on&

Hiccups&by&Percen*le&Distribu*on&
14000"

12000"

12000"

Hiccup&Dura*on&(msec)&

14000"

Hiccup&Dura*on&(msec)&

99.90%"

14000"

Hiccup&Dura*on&(msec)&

Hiccup&Dura*on&(msec)&

14000"

99%"

10000"
8000"
6000"
4000"
2000"
0"

0%"

90%"
Max=20.384&

99%"

&
99.9%"
99.99%"
&
Percen*le&

99.999%"

99.9999%"

Max=13156.352&

10000"
8000"
6000"
4000"
2000"
0"

0%"

90%"

99%"

&99.9%"
&
Percen*le&

99.99%"

99.999%"
Instance capacity test: “Fat Portal”
CMS: Peaks at ~ 3GB / 45 concurrent users

* LifeRay portal on JBoss @ 99.9% SLA of 5 second response times
Instance capacity test: “Fat Portal”
C4: still smooth @ 800 concurrent users

* LifeRay portal on JBoss @ 99.9% SLA of 5 second response times
©2012 Azul Systems, Inc.
GC Tuning

©2011 Azul Systems, Inc.
Java GC tuning is “hard”…
Examples of actual command line GC tuning parameters:
Java -Xmx12g -XX:MaxPermSize=64M -XX:PermSize=32M -XX:MaxNewSize=2g
-XX:NewSize=1g -XX:SurvivorRatio=128 -XX:+UseParNewGC
-XX:+UseConcMarkSweepGC -XX:MaxTenuringThreshold=0
-XX:CMSInitiatingOccupancyFraction=60 -XX:+CMSParallelRemarkEnabled
-XX:+UseCMSInitiatingOccupancyOnly -XX:ParallelGCThreads=12
-XX:LargePageSizeInBytes=256m …
Java –Xms8g –Xmx8g –Xmn2g -XX:PermSize=64M -XX:MaxPermSize=256M
-XX:-OmitStackTraceInFastThrow -XX:SurvivorRatio=2 -XX:-UseAdaptiveSizePolicy
-XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled
-XX:+CMSParallelRemarkEnabled -XX:+CMSParallelSurvivorRemarkEnabled
-XX:CMSMaxAbortablePrecleanTime=10000 -XX:+UseCMSInitiatingOccupancyOnly
-XX:CMSInitiatingOccupancyFraction=63 -XX:+UseParNewGC –Xnoclassgc …
©2011 Azul Systems, Inc.
The complete guide to
Zing GC tuning

java -Xmx40g

©2011 Azul Systems, Inc.
Q&A
http:/
/www.azulsystems.com
G. Tene, B. Iyengar and M. Wolf
C4: The Continuously Concurrent Compacting Collector
In Proceedings of the international symposium on Memory management,
ISMM’11, ACM, pages 79-88
Jones, Richard; Hosking, Antony; Moss, Eliot (25 July 2011). 
The Garbage Collection Handbook: The Art of Automatic Memory
Management. CRC Press. ISBN 1420082795.

©2011 Azul Systems, Inc.

Mais conteúdo relacionado

Mais procurados

Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Marcos García
 
Java Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and TuningJava Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and TuningCarol McDonald
 
An Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAn Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAbhishek Asthana
 
Advancements ingc andc4overview_linkedin_oct2017
Advancements ingc andc4overview_linkedin_oct2017Advancements ingc andc4overview_linkedin_oct2017
Advancements ingc andc4overview_linkedin_oct2017Azul Systems Inc.
 
Exploring .NET memory management (iSense)
Exploring .NET memory management (iSense)Exploring .NET memory management (iSense)
Exploring .NET memory management (iSense)Maarten Balliauw
 
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management....NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...NETFest
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETMaarten Balliauw
 
Exploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinarExploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinarMaarten Balliauw
 
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...Maarten Balliauw
 
(JVM) Garbage Collection - Brown Bag Session
(JVM) Garbage Collection - Brown Bag Session(JVM) Garbage Collection - Brown Bag Session
(JVM) Garbage Collection - Brown Bag SessionJens Hadlich
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuningJerry Kurian
 
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory ManagementQuantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory ManagementEmery Berger
 
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...Maarten Balliauw
 
CodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory laneCodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory laneMaarten Balliauw
 
Garbage collection in .net (basic level)
Garbage collection in .net (basic level)Garbage collection in .net (basic level)
Garbage collection in .net (basic level)Larry Nung
 
Introduction to Twitter Storm
Introduction to Twitter StormIntroduction to Twitter Storm
Introduction to Twitter StormUwe Printz
 
Streams processing with Storm
Streams processing with StormStreams processing with Storm
Streams processing with StormMariusz Gil
 
The Newest in Session Types
The Newest in Session TypesThe Newest in Session Types
The Newest in Session TypesRoland Kuhn
 
Real time and reliable processing with Apache Storm
Real time and reliable processing with Apache StormReal time and reliable processing with Apache Storm
Real time and reliable processing with Apache StormAndrea Iacono
 

Mais procurados (20)

Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)Quick introduction to Java Garbage Collector (JVM GC)
Quick introduction to Java Garbage Collector (JVM GC)
 
Java Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and TuningJava Garbage Collection, Monitoring, and Tuning
Java Garbage Collection, Monitoring, and Tuning
 
An Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in JavaAn Introduction to JVM Internals and Garbage Collection in Java
An Introduction to JVM Internals and Garbage Collection in Java
 
Advancements ingc andc4overview_linkedin_oct2017
Advancements ingc andc4overview_linkedin_oct2017Advancements ingc andc4overview_linkedin_oct2017
Advancements ingc andc4overview_linkedin_oct2017
 
Exploring .NET memory management (iSense)
Exploring .NET memory management (iSense)Exploring .NET memory management (iSense)
Exploring .NET memory management (iSense)
 
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management....NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
.NET Fest 2018. Maarten Balliauw. Let’s refresh our memory! Memory management...
 
DotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NETDotNetFest - Let’s refresh our memory! Memory management in .NET
DotNetFest - Let’s refresh our memory! Memory management in .NET
 
Exploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinarExploring .NET memory management - JetBrains webinar
Exploring .NET memory management - JetBrains webinar
 
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
JetBrains Day Seoul - Exploring .NET’s memory management – a trip down memory...
 
(JVM) Garbage Collection - Brown Bag Session
(JVM) Garbage Collection - Brown Bag Session(JVM) Garbage Collection - Brown Bag Session
(JVM) Garbage Collection - Brown Bag Session
 
Java performance tuning
Java performance tuningJava performance tuning
Java performance tuning
 
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory ManagementQuantifying the Performance of Garbage Collection vs. Explicit Memory Management
Quantifying the Performance of Garbage Collection vs. Explicit Memory Management
 
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
JetBrains Australia 2019 - Exploring .NET’s memory management – a trip down m...
 
CodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory laneCodeStock - Exploring .NET memory management - a trip down memory lane
CodeStock - Exploring .NET memory management - a trip down memory lane
 
Storm Anatomy
Storm AnatomyStorm Anatomy
Storm Anatomy
 
Garbage collection in .net (basic level)
Garbage collection in .net (basic level)Garbage collection in .net (basic level)
Garbage collection in .net (basic level)
 
Introduction to Twitter Storm
Introduction to Twitter StormIntroduction to Twitter Storm
Introduction to Twitter Storm
 
Streams processing with Storm
Streams processing with StormStreams processing with Storm
Streams processing with Storm
 
The Newest in Session Types
The Newest in Session TypesThe Newest in Session Types
The Newest in Session Types
 
Real time and reliable processing with Apache Storm
Real time and reliable processing with Apache StormReal time and reliable processing with Apache Storm
Real time and reliable processing with Apache Storm
 

Destaque

Java Garbage Collection
Java Garbage CollectionJava Garbage Collection
Java Garbage CollectionVinay H G
 
GC @ jmaghreb2014
GC @ jmaghreb2014GC @ jmaghreb2014
GC @ jmaghreb2014Ivan Krylov
 
LatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode FundamentalsLatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode Fundamentalsdenis Udod
 
Programming JVM Bytecode
Programming JVM BytecodeProgramming JVM Bytecode
Programming JVM BytecodeJoe Kutner
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningCarol McDonald
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924yohanbeschi
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Anton Arhipov
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Anton Arhipov
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Anton Arhipov
 
JVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and ScalaJVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and ScalaTakipi
 
Vb.net session 09
Vb.net session 09Vb.net session 09
Vb.net session 09Niit Care
 
15 ooad uml-20
15 ooad uml-2015 ooad uml-20
15 ooad uml-20Niit Care
 
11 ds and algorithm session_16
11 ds and algorithm session_1611 ds and algorithm session_16
11 ds and algorithm session_16Niit Care
 
09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13Niit Care
 
Garbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika LangerGarbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika LangerJAXLondon_Conference
 

Destaque (20)

Java Garbage Collection
Java Garbage CollectionJava Garbage Collection
Java Garbage Collection
 
GC @ jmaghreb2014
GC @ jmaghreb2014GC @ jmaghreb2014
GC @ jmaghreb2014
 
LatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode FundamentalsLatJUG. Java Bytecode Fundamentals
LatJUG. Java Bytecode Fundamentals
 
Programming JVM Bytecode
Programming JVM BytecodeProgramming JVM Bytecode
Programming JVM Bytecode
 
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, TuningJava 5 6 Generics, Concurrency, Garbage Collection, Tuning
Java 5 6 Generics, Concurrency, Garbage Collection, Tuning
 
Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924Introduction to the Java bytecode - So@t - 20130924
Introduction to the Java bytecode - So@t - 20130924
 
Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012Mastering Java Bytecode - JAX.de 2012
Mastering Java Bytecode - JAX.de 2012
 
Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012Mastering java bytecode with ASM - GeeCON 2012
Mastering java bytecode with ASM - GeeCON 2012
 
Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011Java Bytecode For Discriminating Developers - GeeCON 2011
Java Bytecode For Discriminating Developers - GeeCON 2011
 
JVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and ScalaJVM bytecode - The secret language behind Java and Scala
JVM bytecode - The secret language behind Java and Scala
 
Vb.net session 09
Vb.net session 09Vb.net session 09
Vb.net session 09
 
Dacj 2-2 c
Dacj 2-2 cDacj 2-2 c
Dacj 2-2 c
 
15 ooad uml-20
15 ooad uml-2015 ooad uml-20
15 ooad uml-20
 
11 ds and algorithm session_16
11 ds and algorithm session_1611 ds and algorithm session_16
11 ds and algorithm session_16
 
 
Oops recap
Oops recapOops recap
Oops recap
 
09 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_1309 iec t1_s1_oo_ps_session_13
09 iec t1_s1_oo_ps_session_13
 
Garbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika LangerGarbage Collection Pause Times - Angelika Langer
Garbage Collection Pause Times - Angelika Langer
 
OOP Java
OOP JavaOOP Java
OOP Java
 
Rdbms xp 01
Rdbms xp 01Rdbms xp 01
Rdbms xp 01
 

Semelhante a Understanding Java Garbage Collection - And What You Can Do About It

Understanding Zulu Garbage Collection by Matt Schuetze, Director of Product M...
Understanding Zulu Garbage Collection by Matt Schuetze, Director of Product M...Understanding Zulu Garbage Collection by Matt Schuetze, Director of Product M...
Understanding Zulu Garbage Collection by Matt Schuetze, Director of Product M...zuluJDK
 
JVM Mechanics: A Peek Under the Hood
JVM Mechanics: A Peek Under the HoodJVM Mechanics: A Peek Under the Hood
JVM Mechanics: A Peek Under the HoodAzul Systems Inc.
 
Enabling Java in Latency-Sensitive Applications
Enabling Java in Latency-Sensitive ApplicationsEnabling Java in Latency-Sensitive Applications
Enabling Java in Latency-Sensitive ApplicationsAzul Systems Inc.
 
Garbage Collection in Hotspot JVM
Garbage Collection in Hotspot JVMGarbage Collection in Hotspot JVM
Garbage Collection in Hotspot JVMjaganmohanreddyk
 
“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage CollectionHaim Yadid
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Prashanth Kumar
 
Enabling Java in Latency Sensitive Applications by Gil Tene, CTO, Azul Systems
Enabling Java in Latency Sensitive Applications by Gil Tene, CTO, Azul SystemsEnabling Java in Latency Sensitive Applications by Gil Tene, CTO, Azul Systems
Enabling Java in Latency Sensitive Applications by Gil Tene, CTO, Azul SystemszuluJDK
 
Understanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil TeneUnderstanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil Tenejaxconf
 
Exploring .NET memory management - A trip down memory lane - Copenhagen .NET ...
Exploring .NET memory management - A trip down memory lane - Copenhagen .NET ...Exploring .NET memory management - A trip down memory lane - Copenhagen .NET ...
Exploring .NET memory management - A trip down memory lane - Copenhagen .NET ...Maarten Balliauw
 
Understanding Application Hiccups - and What You Can Do About Them
Understanding Application Hiccups - and What You Can Do About ThemUnderstanding Application Hiccups - and What You Can Do About Them
Understanding Application Hiccups - and What You Can Do About ThemAzul Systems Inc.
 
Garbage collection
Garbage collectionGarbage collection
Garbage collectionMudit Gupta
 
The Java Evolution Mismatch by Gil Tene, CTO at Azul Systems
The Java Evolution Mismatch by Gil Tene, CTO at Azul SystemsThe Java Evolution Mismatch by Gil Tene, CTO at Azul Systems
The Java Evolution Mismatch by Gil Tene, CTO at Azul SystemszuluJDK
 
Dev Environments: The Next Generation
Dev Environments: The Next GenerationDev Environments: The Next Generation
Dev Environments: The Next GenerationTravis Thieman
 
How NOT to Measure Latency, Gil Tene, London, Oct. 2013
How NOT to Measure Latency, Gil Tene, London, Oct. 2013How NOT to Measure Latency, Gil Tene, London, Oct. 2013
How NOT to Measure Latency, Gil Tene, London, Oct. 2013Azul Systems Inc.
 
The Java Evolution Mismatch - Why You Need a Better JVM
The Java Evolution Mismatch - Why You Need a Better JVMThe Java Evolution Mismatch - Why You Need a Better JVM
The Java Evolution Mismatch - Why You Need a Better JVMAzul Systems Inc.
 
ConFoo - Exploring .NET’s memory management – a trip down memory lane
ConFoo - Exploring .NET’s memory management – a trip down memory laneConFoo - Exploring .NET’s memory management – a trip down memory lane
ConFoo - Exploring .NET’s memory management – a trip down memory laneMaarten Balliauw
 
Enterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up SearchEnterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up SearchAzul Systems Inc.
 
GWT is Smarter Than You
GWT is Smarter Than YouGWT is Smarter Than You
GWT is Smarter Than YouRobert Cooper
 
Method Swizzling with Objective-C
Method Swizzling with Objective-CMethod Swizzling with Objective-C
Method Swizzling with Objective-CAdamFallon4
 

Semelhante a Understanding Java Garbage Collection - And What You Can Do About It (20)

Understanding Zulu Garbage Collection by Matt Schuetze, Director of Product M...
Understanding Zulu Garbage Collection by Matt Schuetze, Director of Product M...Understanding Zulu Garbage Collection by Matt Schuetze, Director of Product M...
Understanding Zulu Garbage Collection by Matt Schuetze, Director of Product M...
 
JVM Mechanics: A Peek Under the Hood
JVM Mechanics: A Peek Under the HoodJVM Mechanics: A Peek Under the Hood
JVM Mechanics: A Peek Under the Hood
 
Enabling Java in Latency-Sensitive Applications
Enabling Java in Latency-Sensitive ApplicationsEnabling Java in Latency-Sensitive Applications
Enabling Java in Latency-Sensitive Applications
 
Garbage Collection in Hotspot JVM
Garbage Collection in Hotspot JVMGarbage Collection in Hotspot JVM
Garbage Collection in Hotspot JVM
 
“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection“Show Me the Garbage!”, Understanding Garbage Collection
“Show Me the Garbage!”, Understanding Garbage Collection
 
Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)Memory Management in the Java Virtual Machine(Garbage collection)
Memory Management in the Java Virtual Machine(Garbage collection)
 
Enabling Java in Latency Sensitive Applications by Gil Tene, CTO, Azul Systems
Enabling Java in Latency Sensitive Applications by Gil Tene, CTO, Azul SystemsEnabling Java in Latency Sensitive Applications by Gil Tene, CTO, Azul Systems
Enabling Java in Latency Sensitive Applications by Gil Tene, CTO, Azul Systems
 
Understanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil TeneUnderstanding Java Garbage Collection and What You Can Do About It: Gil Tene
Understanding Java Garbage Collection and What You Can Do About It: Gil Tene
 
Exploring .NET memory management - A trip down memory lane - Copenhagen .NET ...
Exploring .NET memory management - A trip down memory lane - Copenhagen .NET ...Exploring .NET memory management - A trip down memory lane - Copenhagen .NET ...
Exploring .NET memory management - A trip down memory lane - Copenhagen .NET ...
 
Understanding Application Hiccups - and What You Can Do About Them
Understanding Application Hiccups - and What You Can Do About ThemUnderstanding Application Hiccups - and What You Can Do About Them
Understanding Application Hiccups - and What You Can Do About Them
 
Garbage collection
Garbage collectionGarbage collection
Garbage collection
 
The Java Evolution Mismatch by Gil Tene, CTO at Azul Systems
The Java Evolution Mismatch by Gil Tene, CTO at Azul SystemsThe Java Evolution Mismatch by Gil Tene, CTO at Azul Systems
The Java Evolution Mismatch by Gil Tene, CTO at Azul Systems
 
Dev Environments: The Next Generation
Dev Environments: The Next GenerationDev Environments: The Next Generation
Dev Environments: The Next Generation
 
How NOT to Measure Latency, Gil Tene, London, Oct. 2013
How NOT to Measure Latency, Gil Tene, London, Oct. 2013How NOT to Measure Latency, Gil Tene, London, Oct. 2013
How NOT to Measure Latency, Gil Tene, London, Oct. 2013
 
The Java Evolution Mismatch - Why You Need a Better JVM
The Java Evolution Mismatch - Why You Need a Better JVMThe Java Evolution Mismatch - Why You Need a Better JVM
The Java Evolution Mismatch - Why You Need a Better JVM
 
ConFoo - Exploring .NET’s memory management – a trip down memory lane
ConFoo - Exploring .NET’s memory management – a trip down memory laneConFoo - Exploring .NET’s memory management – a trip down memory lane
ConFoo - Exploring .NET’s memory management – a trip down memory lane
 
Enterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up SearchEnterprise Search Summit - Speeding Up Search
Enterprise Search Summit - Speeding Up Search
 
GWT is Smarter Than You
GWT is Smarter Than YouGWT is Smarter Than You
GWT is Smarter Than You
 
Garbage collection
Garbage collectionGarbage collection
Garbage collection
 
Method Swizzling with Objective-C
Method Swizzling with Objective-CMethod Swizzling with Objective-C
Method Swizzling with Objective-C
 

Mais de Azul Systems Inc.

Zulu Embedded Java Introduction
Zulu Embedded Java IntroductionZulu Embedded Java Introduction
Zulu Embedded Java IntroductionAzul Systems Inc.
 
What's New in the JVM in Java 8?
What's New in the JVM in Java 8?What's New in the JVM in Java 8?
What's New in the JVM in Java 8?Azul Systems Inc.
 
DotCMS Bootcamp: Enabling Java in Latency Sensitivie Environments
DotCMS Bootcamp: Enabling Java in Latency Sensitivie EnvironmentsDotCMS Bootcamp: Enabling Java in Latency Sensitivie Environments
DotCMS Bootcamp: Enabling Java in Latency Sensitivie EnvironmentsAzul Systems Inc.
 
ObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gapObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gapAzul Systems Inc.
 
Priming Java for Speed at Market Open
Priming Java for Speed at Market OpenPriming Java for Speed at Market Open
Priming Java for Speed at Market OpenAzul Systems Inc.
 
Azul Systems open source guide
Azul Systems open source guideAzul Systems open source guide
Azul Systems open source guideAzul Systems Inc.
 
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!Azul Systems Inc.
 
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and Tools
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and ToolsIntelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and Tools
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and ToolsAzul Systems Inc.
 
The evolution of OpenJDK: From Java's beginnings to 2014
The evolution of OpenJDK: From Java's beginnings to 2014The evolution of OpenJDK: From Java's beginnings to 2014
The evolution of OpenJDK: From Java's beginnings to 2014Azul Systems Inc.
 
Push Technology's latest data distribution benchmark with Solarflare and Zing
Push Technology's latest data distribution benchmark with Solarflare and ZingPush Technology's latest data distribution benchmark with Solarflare and Zing
Push Technology's latest data distribution benchmark with Solarflare and ZingAzul Systems Inc.
 
Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...Azul Systems Inc.
 
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)Speculative Locking: Breaking the Scale Barrier (JAOO 2005)
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)Azul Systems Inc.
 
Towards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding StyleTowards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding StyleAzul Systems Inc.
 
Experiences with Debugging Data Races
Experiences with Debugging Data RacesExperiences with Debugging Data Races
Experiences with Debugging Data RacesAzul Systems Inc.
 
Lock-Free, Wait-Free Hash Table
Lock-Free, Wait-Free Hash TableLock-Free, Wait-Free Hash Table
Lock-Free, Wait-Free Hash TableAzul Systems Inc.
 
How NOT to Write a Microbenchmark
How NOT to Write a MicrobenchmarkHow NOT to Write a Microbenchmark
How NOT to Write a MicrobenchmarkAzul Systems Inc.
 
The Art of Java Benchmarking
The Art of Java BenchmarkingThe Art of Java Benchmarking
The Art of Java BenchmarkingAzul Systems Inc.
 
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, Poland
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, PolandAzul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, Poland
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, PolandAzul Systems Inc.
 

Mais de Azul Systems Inc. (20)

Zulu Embedded Java Introduction
Zulu Embedded Java IntroductionZulu Embedded Java Introduction
Zulu Embedded Java Introduction
 
What's New in the JVM in Java 8?
What's New in the JVM in Java 8?What's New in the JVM in Java 8?
What's New in the JVM in Java 8?
 
DotCMS Bootcamp: Enabling Java in Latency Sensitivie Environments
DotCMS Bootcamp: Enabling Java in Latency Sensitivie EnvironmentsDotCMS Bootcamp: Enabling Java in Latency Sensitivie Environments
DotCMS Bootcamp: Enabling Java in Latency Sensitivie Environments
 
ObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gapObjectLayout: Closing the (last?) inherent C vs. Java speed gap
ObjectLayout: Closing the (last?) inherent C vs. Java speed gap
 
Priming Java for Speed at Market Open
Priming Java for Speed at Market OpenPriming Java for Speed at Market Open
Priming Java for Speed at Market Open
 
Azul Systems open source guide
Azul Systems open source guideAzul Systems open source guide
Azul Systems open source guide
 
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!
Start Fast and Stay Fast - Priming Java for Market Open with ReadyNow!
 
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and Tools
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and ToolsIntelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and Tools
Intelligent Trading Summit NY 2014: Understanding Latency: Key Lessons and Tools
 
The evolution of OpenJDK: From Java's beginnings to 2014
The evolution of OpenJDK: From Java's beginnings to 2014The evolution of OpenJDK: From Java's beginnings to 2014
The evolution of OpenJDK: From Java's beginnings to 2014
 
Push Technology's latest data distribution benchmark with Solarflare and Zing
Push Technology's latest data distribution benchmark with Solarflare and ZingPush Technology's latest data distribution benchmark with Solarflare and Zing
Push Technology's latest data distribution benchmark with Solarflare and Zing
 
Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...Webinar: Zing Vision: Answering your toughest production Java performance que...
Webinar: Zing Vision: Answering your toughest production Java performance que...
 
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)Speculative Locking: Breaking the Scale Barrier (JAOO 2005)
Speculative Locking: Breaking the Scale Barrier (JAOO 2005)
 
Java vs. C/C++
Java vs. C/C++Java vs. C/C++
Java vs. C/C++
 
What's Inside a JVM?
What's Inside a JVM?What's Inside a JVM?
What's Inside a JVM?
 
Towards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding StyleTowards a Scalable Non-Blocking Coding Style
Towards a Scalable Non-Blocking Coding Style
 
Experiences with Debugging Data Races
Experiences with Debugging Data RacesExperiences with Debugging Data Races
Experiences with Debugging Data Races
 
Lock-Free, Wait-Free Hash Table
Lock-Free, Wait-Free Hash TableLock-Free, Wait-Free Hash Table
Lock-Free, Wait-Free Hash Table
 
How NOT to Write a Microbenchmark
How NOT to Write a MicrobenchmarkHow NOT to Write a Microbenchmark
How NOT to Write a Microbenchmark
 
The Art of Java Benchmarking
The Art of Java BenchmarkingThe Art of Java Benchmarking
The Art of Java Benchmarking
 
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, Poland
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, PolandAzul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, Poland
Azul Zulu on Azure Overview -- OpenTech CEE Workshop, Warsaw, Poland
 

Último

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxhariprasad279825
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsPixlogix Infotech
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piececharlottematthew16
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .Alan Dix
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Commit University
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenHervé Boutemy
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity PlanDatabarracks
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 

Último (20)

Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Artificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptxArtificial intelligence in cctv survelliance.pptx
Artificial intelligence in cctv survelliance.pptx
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
The Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and ConsThe Ultimate Guide to Choosing WordPress Pros and Cons
The Ultimate Guide to Choosing WordPress Pros and Cons
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
Story boards and shot lists for my a level piece
Story boards and shot lists for my a level pieceStory boards and shot lists for my a level piece
Story boards and shot lists for my a level piece
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data PrivacyTrustArc Webinar - How to Build Consumer Trust Through Data Privacy
TrustArc Webinar - How to Build Consumer Trust Through Data Privacy
 
From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .From Family Reminiscence to Scholarly Archive .
From Family Reminiscence to Scholarly Archive .
 
Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!Nell’iperspazio con Rocket: il Framework Web di Rust!
Nell’iperspazio con Rocket: il Framework Web di Rust!
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
DevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache MavenDevoxxFR 2024 Reproducible Builds with Apache Maven
DevoxxFR 2024 Reproducible Builds with Apache Maven
 
How to write a Business Continuity Plan
How to write a Business Continuity PlanHow to write a Business Continuity Plan
How to write a Business Continuity Plan
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 

Understanding Java Garbage Collection - And What You Can Do About It

  • 1. Understanding Java Garbage Collection and what you can do about it Gil Tene, CTO & co-Founder, Azul Systems ©2011 Azul Systems, Inc.
  • 2. This Talk’s Purpose / Goals This talk is focused on GC education This is not a “how to use flags to tune a collector” talk This is a talk about how the “GC machine” works Purpose: Once you understand how it works, you can use your own brain... You’ll learn just enough to be dangerous... The “Azul makes the world’s greatest GC” stuff will only come at the end, I promise... ©2011 Azul Systems, Inc.
  • 3. About me: Gil Tene co-founder, CTO @Azul Systems Have been working on “think different” GC approaches since 2002 Created Pauseless & C4 core GC algorithms (Tene, Wolf) A Long history building Virtual & Physical Machines, Operating Systems, Enterprise apps, etc... ©2011 Azul Systems, Inc. * working on real-world trash compaction issues, circa 2004
  • 4. About Azul Vega We make scalable Virtual Machines Have built “whatever it takes to get job done” since 2002 3 generations of custom SMP Multi-core HW (Vega) Now Pure software for commodity x86 (Zing) C4 “Industry firsts” in Garbage collection, elastic memory, Java virtualization, memory scale ©2011 Azul Systems, Inc.
  • 5. High level agenda GC fundamentals and key mechanisms Some GC terminology & metrics Classifying currently available collectors The “Application Memory Wall” problem The C4 collector: What an actual solution looks like... ©2011 Azul Systems, Inc.
  • 6. Memory use How many of you use heap sizes of: F more than ½ GB? F more than 1 GB? F more than 2 GB? F more than 4 GB? F more than 10 GB? F more than 20 GB? F more than 50 GB? ©2011 Azul Systems, Inc.
  • 7. Why should you care? ©2011 Azul Systems, Inc.
  • 8. The story of the good little architect A good architect must, first and foremost, be able to impose their architectural choices on the project... Early in Azul’s concurrent collector days, we encountered an application exhibiting 18 second pauses Upon investigation, we found the collector was performing 10s of milliions of object finalizations per GC cycle *We have since made reference processing fully concurrent... Every single class written in the project had a finalizer The only work the finalizers did was nulling every reference field The right discipline for a C++ ref-counting environment The wrong discipline for a precise garbage collected environment ©2011 Azul Systems, Inc.
  • 9. Trying to solve GC problems in application architecture is like throwing knives You probably shouldn’t do it blindfolded It takes practice and understanding to get it right You can get very good at it, but do you really want to? Will all the code you leverage be as good as yours? Examples: Object pooling Off heap storage Distributed heaps ... (In most cases, you end up building your own garbage collector) ©2011 Azul Systems, Inc.
  • 10. Most of what People seem to “know” about Garbage Collection is wrong In many cases, it’s much better than you may think GC is extremely efficient. Much more so that malloc() Dead objects cost nothing to collect GC will find all the dead objects (including cyclic graphs) ... In many cases, it’s much worse than you may think Yes, it really does stop for ~1 sec per live GB. No, GC does not mean you can’t have memory leaks No, those pauses you eliminated from your 20 minute test are not gone ... ©2011 Azul Systems, Inc.
  • 11. Some GC Terminology ©2011 Azul Systems, Inc.
  • 12. A Basic Terminology example: What is a concurrent collector? A Concurrent Collector performs garbage collection work concurrently with the application’s own execution A Parallel Collector uses multiple CPUs to perform garbage collection ©2011 Azul Systems, Inc.
  • 13. Classifying a collector’s operation A Concurrent Collector performs garbage collection work concurrently with the application’s own execution A Parallel Collector uses multiple CPUs to perform garbage collection A Stop-the-World collector performs garbage collection while the application is completely stopped An Incremental collector performs a garbage collection operation or phase as a series of smaller discrete operations with (potentially long) gaps in between Mostly means sometimes it isn’t (usually means a different fall back mechanism exists) ©2011 Azul Systems, Inc.
  • 14. Precise vs. Conservative Collection A Collector is Conservative if it is unaware of all object references at collection time, or is unsure about whether a field is a reference or not A Collector is Precise if it can fully identify and process all object references at the time of collection A collector MUST be precise in order to move objects The COMPILERS need to produce a lot of information (OopMaps) All commercial server JVMs use precise collectors All commercial server JVMs use some form of a moving collector ©2011 Azul Systems, Inc.
  • 15. Safepoints A GC Safepoint is a point or range in a thread’s execution where the collector can identify all the references in that thread’s execution stack “Safepoint” and “GC Safepoint” are often used interchangeably But there are other types of safepoints, including ones that require more information than a GC safepoint does (e.g. deoptimization) “Bringing a thread to a safepoint” is the act of getting a thread to reach a safepoint and not execute past it Close to, but not exactly the same as “stop at a safepoint” e.g. JNI: you can keep running in, but not past the safepoint Safepoint opportunities are (or should be) frequent In a Global Safepoint all threads are at a Safepoint ©2011 Azul Systems, Inc.
  • 16. What’s common to all precise GC mechanisms? Identify the live objects in the memory heap Reclaim resources held by dead objects Periodically relocate live objects Examples: Mark/Sweep/Compact (common for Old Generations) Copying collector (common for Young Generations) ©2011 Azul Systems, Inc.
  • 17. Mark (aka “Trace”) Start from “roots” (thread stacks, statics, etc.) “Paint” anything you can reach as “live” At the end of a mark pass: all reachable objects will be marked “live” all non-reachable objects will be marked “dead” (aka “non-live”). Note: work is generally linear to “live set” ©2011 Azul Systems, Inc.
  • 18. Sweep Scan through the heap, identify “dead” objects and track them somehow (usually in some form of free list) Note: work is generally linear to heap size ©2011 Azul Systems, Inc.
  • 19. Compact Over time, heap will get “swiss cheesed”: contiguous dead space between objects may not be large enough to fit new objects (aka “fragmentation”) Compaction moves live objects together to reclaim contiguous empty space (aka “relocate”) Compaction has to correct all object references to point to new object locations (aka “remap”) Remap scan must cover all references that could possibly point to relocated objects Note: work is generally linear to “live set” ©2011 Azul Systems, Inc.
  • 20. Copy Copying collector moves all live objects from a “from” space to a “to” space & reclaims “from” space At start of copy, all objects are in “from” space and all references point to “from” space. Start from “root” references, copy any reachable object to “to” space, correcting references as we go At end of copy, all objects are in “to” space, and all references point to “to” space Note: work generally linear to “live set” ©2011 Azul Systems, Inc.
  • 21. Mark/Sweep/Compact, Copy, Mark/Compact Copy requires 2x the max. live set to be reliable Mark/Compact [typically] requires 2x the max. live set in order to fully recover garbage in each cycle Mark/Sweep/Compact only requires 1x (plus some) Copy and Mark/Compact are linear only to live set Mark/Sweep/Compact linear (in sweep) to heap size Mark/Sweep/(Compact) may be able to avoid some moving work Copying is [typically] “monolithic” ©2011 Azul Systems, Inc.
  • 22. Generational Collection Generational Hypothesis: most objects die young Focus collection efforts on young generation: Use a moving collector: work is linear to the live set The live set in the young generation is a small % of the space Promote objects that live long enough to older generations Only collect older generations as they fill up “Generational filter” reduces rate of allocation into older generations Tends to be (order of magnitude) more efficient Great way to keep up with high allocation rate Practical necessity for keeping up with processor throughput ©2011 Azul Systems, Inc.
  • 23. Generational Collection Requires a “Remembered set”: a way to track all references into the young generation from the outside Remembered set is also part of “roots” for young generation collection No need for 2x the live set: Can “spill over” to old gen Usually want to keep surviving objects in young generation for a while before promoting them to the old generation Immediate promotion can dramatically reduce gen. filter efficiency Waiting too long to promote can dramatically increase copying work ©2011 Azul Systems, Inc.
  • 24. How does the remembered set work? Generational collectors require a “Remembered set”: a way to track all references into the young generation from the outside Each store of a NewGen reference into an OldGen object needs to be intercepted and tracked Common technique: “Card Marking” A bit (or byte) indicating a word (or region) in OldGen is “suspect” Write barrier used to track references Common technique (e.g. HotSpot): blind stores on reference write Variants: precise vs. imprecise card marking, conditional vs. nonconditional ©2011 Azul Systems, Inc.
  • 25. The typical combos in commercial server JVMS Young generation usually uses a copying collector Young generation is usually monolithic, stop-the-world Old generation usually uses Mark/Sweep/Compact Old generation may be STW, or Concurrent, or mostly-Concurrent, or Incremental-STW, or mostlyIncremental-STW ©2011 Azul Systems, Inc.
  • 26. Useful terms for discussing garbage collection Generational Mutator Collects young objects and long lived objects separately. Your program… Parallel Promotion Can use multiple CPUs Allocation into old generation Concurrent Runs concurrently with program Pause A time duration in which the mutator is not running any code Something that is done in a pause Monolithic Stop-The-World Something that must be done in it’s entirety in a single pause Finding all live objects Sweeping Locating the dead objects Compaction Stop-The-World (STW) ©2011 Azul Systems, Inc. Marking Defragments heap Moves objects in memory Remaps all affected references Frees contiguous memory regions
  • 27. Useful metrics for discussing garbage collection Heap population (aka Live set) How much of your heap is alive Allocation rate Cycle time How long it takes the collector to free up memory Marking time How fast you allocate How long it takes the collector to find all live objects Mutation rate How fast your program updates references in memory Heap Shape The shape of the live object graph * Hard to quantify as a metric... Object Lifetime Sweep time How long it takes to locate dead objects * Relevant for Mark-Sweep Compaction time How long it takes to free up memory by relocating objects How long objects live * Relevant for Mark-Compact ©2011 Azul Systems, Inc.
  • 29. Two Intuitive limits If we had infinite empty memory, we would never have to collect, and GC would take 0% of the CPU time If we had exactly 1 byte of empty memory at all times, the collector would have to work “very hard”, and GC would take 100% of the CPU time GC CPU % will follow a rough 1/x curve between these two limit points, dropping as the amount of memory increases. ©2011 Azul Systems, Inc.
  • 30. Empty memory needs (empty memory == CPU power) The amount of empty memory in the heap is the dominant factor controlling the amount of GC work For both Copy and Mark/Compact collectors, the amount of work per cycle is linear to live set The amount of memory recovered per cycle is equal to the amount of unused memory (heap size) - (live set) The collector has to perform a GC cycle when the empty memory runs out A Copy or Mark/Compact collector’s efficiency doubles with every doubling of the empty memory ©2011 Azul Systems, Inc.
  • 31. What empty memory controls Empty memory controls efficiency (amount of collector work needed per amount of application work performed) Empty memory controls the frequency of pauses (if the collector performs any Stop-the-world operations) Empty memory DOES NOT control pause times (only their frequency) In Mark/Sweep/Compact collectors that pause for sweeping, more empty memory means less frequent but LARGER pauses ©2011 Azul Systems, Inc.
  • 33. Concurrent Marking Mark all reachable objects as “live”, but object graph is “mutating” under us. Classic concurrent marking race: mutator may move reference that has not yet been seen by the marker into an object that has already been visited If not intercepted or prevented in some way, will corrupt the heap Example technique: track mutations, multi-pass marking Track reference mutations during mark (e.g. in card table) Re-visit all mutated references (and track new mutations) When set is “small enough”, do a STW catch up (mostly concurrent) Note: work grows with mutation rate, may fail to finish ©2011 Azul Systems, Inc.
  • 34. Incremental Compaction Track cross-region remembered sets (which region points to which) To compact a single region, only need to scan regions that point into it to remap all potential references identify regions sets that fit in limited time Each such set of regions is a Stop-the-World increment Safe to run application between (but not within) increments Note: work can grow with the square of the heap size The number of regions pointing into a single region is generally linear to the heap size (the number of regions in the heap) ©2011 Azul Systems, Inc.
  • 35. Delaying the inevitable Compaction is inevitable in practice And compacting anything requires scanning/fixing all references to it Delay tactics focus on getting “easy empty space” first This is the focus for the vast majority of GC tuning Most objects die young [Generational] So collect young objects only, as much as possible But eventually, some old dead objects must be reclaimed Most old dead space can be reclaimed without moving it [e.g. CMS] track dead space in lists, and reuse it in place But eventually, space gets fragmented, and needs to be moved Much of the heap is not “popular” [e.g. G1, “Balanced”] A non popular region will only be pointed to from a small % of the heap So compact non-popular regions in short stop-the-world pauses But eventually, popular objects and regions need to be compacted ©2011 Azul Systems, Inc.
  • 37. The typical combos in commercial server JVMS Young generation usually uses a copying collector Young generation is usually monolithic, stop-the-world Old generation usually uses a Mark/Sweep/Compact collector Old generation may be STW, or Concurrent, or mostly-Concurrent, or Incremental-STW, or mostly-Incremental-STW ©2011 Azul Systems, Inc.
  • 38. HotSpot™ ParallelGC Collector mechanism classification Monolithic Stop-the-world copying NewGen Monolithic Stop-the-world Mark/Sweep/Compact OldGen ©2011 Azul Systems, Inc.
  • 39. HotSpot™ ConcMarkSweepGC (aka CMS) Collector mechanism classification Monolithic Stop-the-world copying NewGen (ParNew) Mostly Concurrent, non-compacting OldGen (CMS) Mostly Concurrent marking Mark concurrently while mutator is running Track mutations in card marks Revisit mutated cards (repeat as needed) Stop-the-world to catch up on mutations, ref processing, etc. Concurrent Sweeping Does not Compact (maintains free list, does not move objects) Fallback to Full Collection (Monolithic Stop the world). Used for Compaction, etc. ©2011 Azul Systems, Inc.
  • 40. HotSpot™ G1GC (aka “Garbage First”) Collector mechanism classification Monolithic Stop-the-world copying NewGen Mostly Concurrent, OldGen marker Mostly Concurrent marking Stop-the-world to catch up on mutations, ref processing, etc. Tracks inter-region relationships in remembered sets Stop-the-world mostly incremental compacting old gen Objective: “Avoid, as much as possible, having a Full GC…” Compact sets of regions that can be scanned in limited time Delay compaction of popular objects, popular regions Fallback to Full Collection (Monolithic Stop the world). Used for compacting popular objects, popular regions, etc. ©2011 Azul Systems, Inc.
  • 41. The “Application Memory Wall” ©2011 Azul Systems, Inc.
  • 42. Memory use How many of you use heap sizes of: F more than ½ GB? F more than 1 GB? F more than 2 GB? F more than 4 GB? F more than 10 GB? F more than 20 GB? F more than 50 GB? ©2011 Azul Systems, Inc.
  • 43. Reality check: servers in 2012 Retail prices, major web server store (US $, March 2012) 16 vCore, 96GB server ≈ $5K 16 vCore, 256GB server ≈ $9K 24 vCore, 384GB server ≈ $14K 32 vCore, 1TB server ≈ $35K Cheap (< $1/GB/Month), and roughly linear to ~1TB 10s to 100s of GB/sec of memory bandwidth ©2011 Azul Systems, Inc.
  • 44. The Application Memory Wall A simple observation: Application instances appear to be unable to make effective use of modern server memory capacities The size of application instances as a % of a server’s capacity is rapidly dropping ©2011 Azul Systems, Inc.
  • 45. How much memory do applications need? “640KB ought to be enough for anybody” WRONG! So what’s the right number? 6,400K? 64,000K? 640,000K? 6,400,000K? 64,000,000K? There is no right number Target moves at 50x-100x per decade ©2011 Azul Systems, Inc. “I've said some stupid things and some wrong things, but not that. No one involved in computers would ever say that a certain amount of memory is enough for all time …” - Bill Gates, 1996
  • 46. “Tiny” application history Assuming Moore’s Law means: 2010 “transistor counts grow at ≈2x every ≈18 months” It also means memory size grows ≈100x every 10 years 1990 1980 ??? GB apps on 256 GB Application Memory Wall 2000 1GB apps on a 2 – 4 GB server 10MB apps on a 32 – 64 MB server 100KB apps on a ¼ to ½ MB Server “Tiny”: would be “silly” to distribute ©2011 Azul Systems, Inc.
  • 47. What is causing the Application Memory Wall? Garbage Collection is a clear and dominant cause There seem to be practical heap size limits for applications with responsiveness requirements [Virtually] All current commercial JVMs will exhibit a multi-second pause on a normally utilized 2-4GB heap. It’s a question of “When” and “How often”, not “If”. GC tuning only moves the “when” and the “how often” around Root cause: The link between scale and responsiveness ©2011 Azul Systems, Inc.
  • 48. What quality of GC is responsible for the Application Memory Wall? It is NOT about overhead or efficiency: CPU utilization, bottlenecks, memory consumption and utilization It is NOT about speed Average speeds, 90%, 99% speeds, are all perfectly fine It is NOT about minor GC events (right now) GC events in the 10s of msec are usually tolerable for most apps It is NOT about the frequency of very large pauses It is ALL about the worst observable pause behavior People avoid building/deploying visibly broken systems ©2011 Azul Systems, Inc.
  • 49. GC Problems ©2011 Azul Systems, Inc.
  • 50. Framing the discussion: Garbage Collection at modern server scales Modern Servers have 100s of GB of memory Each modern x86 core (when actually used) produces garbage at a rate of ¼ - ½ GB/sec + That’s many GB/sec of allocation in a server Monolithic stop-the-world operations are the cause of the current Application Memory Wall ©2011 Azul Systems, Inc.
  • 51. The things that seem “hard” to do in GC Robust concurrent marking References keep changing Multi-pass marking is sensitive to mutation rate Weak, Soft, Final references “hard” to deal with concurrently [Concurrent] Compaction… It’s not the moving of the objects… It’s the fixing of all those references that point to them How do you deal with a mutator looking at a stale reference? If you can’t, then remapping is a [monolithic] STW operation Young Generation collection at scale Young Generation collection is generally monolithic, Stop-The-World Young generation pauses are only small because heaps are tiny A 100GB heap will regularly have several GB of live young stuff… ©2011 Azul Systems, Inc.
  • 52. How can we break through the Application Memory Wall? ©2011 Azul Systems, Inc.
  • 53. We need to solve the right problems Focus on the causes of the Application Memory Wall Root cause: Scale is artificially limited by responsiveness Responsiveness must be unlinked from scale Heap size, Live Set size, Allocation rate, Mutation rate Responsiveness must be continually sustainable Can’t ignore “rare” events Eliminate all Stop-The-World Fallbacks At modern server scales, any STW fall back is a failure ©2011 Azul Systems, Inc.
  • 54. The problems that need solving (areas where the state of the art needs improvement) Robust Concurrent Marking In the presence of high mutation and allocation rates Cover modern runtime semantics (e.g. weak refs) Compaction that is not monolithic-stop-the-world Stay responsive while compacting many-GB heaps Must be robust: not just a tactic to delay STW compaction [current “incremental STW” attempts fall short on robustness] Non-monolithic-stop-the-world Generational collection Stay responsive while promoting multi-GB data spikes Concurrent or “incremental STW” may both be ok Surprisingly little work done in this specific area ©2011 Azul Systems, Inc.
  • 55. Azul’s “C4” Collector Continuously Concurrent Compacting Collector Concurrent, compacting new generation Concurrent, compacting old generation Concurrent guaranteed-single-pass marker Oblivious to mutation rate Concurrent ref (weak, soft, final) processing Concurrent Compactor Objects moved without stopping mutator References remapped without stopping mutator Can relocate entire generation (New, Old) in every GC cycle No stop-the-world fallback Always compacts, and always does so concurrently ©2011 Azul Systems, Inc.
  • 56. Sample responsiveness improvement ๏ SpecJBB + Slow churning 2GB LRU Cache ๏ Live set is ~2.5GB across all measurements ๏ Allocation rate is ~1.2GB/sec across all measurements ©2011 Azul Systems, Inc.
  • 58. Zing 5, 1GB in an 8GB heap Oracle HotSpot CMS, 1GB in an 8GB heap Hiccups&by&Time&Interval& Max"per"Interval" 99%" 99.90%" Hiccups&by&Time&Interval& 99.99%" Max" Max"per"Interval" 20" 15" 10" 5" 0" Max" 12000" 10000" 8000" 6000" 4000" 2000" 500" 1000" 1500" 2000" 2500" 3000" 3500" 0" 500" 1000" &Elapsed&Time&(sec)& 1500" 2000" 2500" 3000" 3500" &Elapsed&Time&(sec)& Hiccups&by&Percen*le&Distribu*on& Hiccups&by&Percen*le&Distribu*on& 14000" 20" Hiccup&Dura*on&(msec)& 25" Hiccup&Dura*on&(msec)& 99.99%" 0" 0" Max=20.384& 15" 10" 5" 0" 99.90%" 14000" Hiccup&Dura*on&(msec)& Hiccup&Dura*on&(msec)& 25" 99%" 0%" 90%" 99%" & 99.9%" 99.99%" & Percen*le& 99.999%" 99.9999%" Max=13156.352& 12000" 10000" 8000" 6000" 4000" 2000" 0" 0%" 90%" 99%" &99.9%" & Percen*le& 99.99%" 99.999%"
  • 59. Zing 5, 1GB in an 8GB heap Oracle HotSpot CMS, 1GB in an 8GB heap Hiccups&by&Time&Interval& Max"per"Interval" 99%" 99.90%" Hiccups&by&Time&Interval& 99.99%" Max" Max"per"Interval" 12000" 99.99%" Max" 12000" 10000" 8000" 6000" 4000" 2000" 0" 10000" 8000" 6000" 4000" 2000" 0" 0" 500" 1000" 1500" 2000" 2500" 3000" 3500" 0" 500" 1000" &Elapsed&Time&(sec)& 1500" 2000" 2500" 3000" 3500" &Elapsed&Time&(sec)& Hiccups&by&Percen*le&Distribu*on& Hiccups&by&Percen*le&Distribu*on& 14000" 12000" 12000" Hiccup&Dura*on&(msec)& 14000" Hiccup&Dura*on&(msec)& 99.90%" 14000" Hiccup&Dura*on&(msec)& Hiccup&Dura*on&(msec)& 14000" 99%" 10000" 8000" 6000" 4000" 2000" 0" 0%" 90%" Max=20.384& 99%" & 99.9%" 99.99%" & Percen*le& 99.999%" 99.9999%" Max=13156.352& 10000" 8000" 6000" 4000" 2000" 0" 0%" 90%" 99%" &99.9%" & Percen*le& 99.99%" 99.999%"
  • 60. Instance capacity test: “Fat Portal” CMS: Peaks at ~ 3GB / 45 concurrent users * LifeRay portal on JBoss @ 99.9% SLA of 5 second response times
  • 61. Instance capacity test: “Fat Portal” C4: still smooth @ 800 concurrent users * LifeRay portal on JBoss @ 99.9% SLA of 5 second response times ©2012 Azul Systems, Inc.
  • 62. GC Tuning ©2011 Azul Systems, Inc.
  • 63. Java GC tuning is “hard”… Examples of actual command line GC tuning parameters: Java -Xmx12g -XX:MaxPermSize=64M -XX:PermSize=32M -XX:MaxNewSize=2g -XX:NewSize=1g -XX:SurvivorRatio=128 -XX:+UseParNewGC -XX:+UseConcMarkSweepGC -XX:MaxTenuringThreshold=0 -XX:CMSInitiatingOccupancyFraction=60 -XX:+CMSParallelRemarkEnabled -XX:+UseCMSInitiatingOccupancyOnly -XX:ParallelGCThreads=12 -XX:LargePageSizeInBytes=256m … Java –Xms8g –Xmx8g –Xmn2g -XX:PermSize=64M -XX:MaxPermSize=256M -XX:-OmitStackTraceInFastThrow -XX:SurvivorRatio=2 -XX:-UseAdaptiveSizePolicy -XX:+UseConcMarkSweepGC -XX:+CMSConcurrentMTEnabled -XX:+CMSParallelRemarkEnabled -XX:+CMSParallelSurvivorRemarkEnabled -XX:CMSMaxAbortablePrecleanTime=10000 -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=63 -XX:+UseParNewGC –Xnoclassgc … ©2011 Azul Systems, Inc.
  • 64. The complete guide to Zing GC tuning java -Xmx40g ©2011 Azul Systems, Inc.
  • 65. Q&A http:/ /www.azulsystems.com G. Tene, B. Iyengar and M. Wolf C4: The Continuously Concurrent Compacting Collector In Proceedings of the international symposium on Memory management, ISMM’11, ACM, pages 79-88 Jones, Richard; Hosking, Antony; Moss, Eliot (25 July 2011).  The Garbage Collection Handbook: The Art of Automatic Memory Management. CRC Press. ISBN 1420082795. ©2011 Azul Systems, Inc.