SlideShare ist ein Scribd-Unternehmen logo
1 von 298
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




©2011 Azul Systems, Inc.
This Talk’s Purpose / Goals
                    This talk is focused on GC education




©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




©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




©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...




©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...




©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.
©2011 Azul Systems, Inc.
About me: Gil Tene

                  co-founder, CTO
                  @Azul Systems




©2011 Azul Systems, Inc.
About me: Gil Tene

                  co-founder, CTO
                  @Azul Systems

                  Have been working on
                  a “think different” GC
                  approaches since 2002




©2011 Azul Systems, Inc.
About me: Gil Tene

                  co-founder, CTO
                  @Azul Systems

                  Have been working on
                  a “think different” GC
                  approaches since 2002




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

©2011 Azul Systems, Inc.
About me: Gil Tene

                  co-founder, CTO
                  @Azul Systems

                  Have been working on
                  a “think different” GC
                  approaches since 2002

                  Created Pauseless & C4
                  core GC algorithms
                  (Tene, Wolf)




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

©2011 Azul Systems, Inc.
About me: Gil Tene

                  co-founder, CTO
                  @Azul Systems

                  Have been working on
                  a “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...                     * working on real-world trash compaction issues, circa 2004

©2011 Azul Systems, Inc.
About Azul




©2011 Azul Systems, Inc.
About Azul

               We make scalable Virtual
               Machines




©2011 Azul Systems, Inc.
About Azul

               We make scalable Virtual
               Machines

               Have built “whatever it takes
               to get job done” since 2002




©2011 Azul Systems, Inc.
About Azul

               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)




©2011 Azul Systems, Inc.
About Azul

               We make scalable Virtual                  Vega
               Machines

               Have built “whatever it takes
               to get job done” since 2002

               3 generations of custom SMP
               Multi-core HW (Vega)




©2011 Azul Systems, Inc.
About Azul

               We make scalable Virtual                  Vega

               Machines

               Have built “whatever it takes
               to get job done” since 2002

               3 generations of custom SMP
               Multi-core HW (Vega)




©2011 Azul Systems, Inc.
About Azul

               We make scalable Virtual                  Vega

               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)




©2011 Azul Systems, Inc.
About Azul

               We make scalable Virtual                  Vega

               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

©2011 Azul Systems, Inc.
About Azul

               We make scalable Virtual                  Vega

               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




©2011 Azul Systems, Inc.
High level agenda

                    GC fundamentals and key mechanisms




©2011 Azul Systems, Inc.
High level agenda

                    GC fundamentals and key mechanisms

                    Some GC terminology & metrics




©2011 Azul Systems, Inc.
High level agenda

                    GC fundamentals and key mechanisms

                    Some GC terminology & metrics

                    Classifying currently available collectors




©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




©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




©2011 Azul Systems, Inc.
Memory use




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




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

                                   more than ½ GB?




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

                                   more than ½ GB?

                                   more than 1 GB?




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

                                   more than ½ GB?

                                   more than 1 GB?

                                   more than 2 GB?




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

                                   more than ½ GB?

                                   more than 1 GB?

                                   more than 2 GB?

                                   more than 4 GB?




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

                                   more than ½ GB?

                                   more than 1 GB?

                                   more than 2 GB?

                                   more than 4 GB?

                                   more than 10 GB?




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

                                   more than ½ GB?

                                   more than 1 GB?

                                   more than 2 GB?

                                   more than 4 GB?

                                   more than 10 GB?

                                   more than 20 GB?


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

                                   more than ½ GB?

                                   more than 1 GB?

                                   more than 2 GB?

                                   more than 4 GB?

                                   more than 10 GB?

                                   more than 20 GB?

                                   more than 50 GB?
©2011 Azul Systems, Inc.
Memory use
                   How many of you use heap sizes of:

                                   more than ½ GB?

                                   more than 1 GB?

                                   more than 2 GB?

                                   more than 4 GB?

                                   more than 10 GB?

                                   more than 20 GB?

                                   more than 50 GB?
©2011 Azul Systems, Inc.
Why should you care about GC?




©2011 Azul Systems, Inc.
The story of the good little architect




©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...




©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




©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
                            millions of object finalizations per GC cycle




©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
                            millions of object finalizations per GC cycle
                             *We have since made reference processing fully concurrent...




©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
                            millions of object finalizations per GC cycle
                             *We have since made reference processing fully concurrent...


                 Every single class written in the project has a finalizer




©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
                            millions of object finalizations per GC cycle
                             *We have since made reference processing fully concurrent...


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




©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
                            millions of object finalizations per GC cycle
                             *We have since made reference processing fully concurrent...


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

                 The right discipline for a C++ ref-counting environment

©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
                            millions of object finalizations per GC cycle
                             *We have since made reference processing fully concurrent...


                 Every single class written in the project has 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




©2011 Azul Systems, Inc.
Trying to solve GC problems in application
                architecture is like throwing knives
                 You probably shouldn’t do it blindfolded




©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




©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?




©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




©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)
                            ...




©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?




©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




©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




©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




©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



©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




©2011 Azul Systems, Inc.
Precise vs. Conservative Collection

                 A Collector is Conservative if it is unaware of some
                 object references at collection time, or is unsure
                 about whether a field is a reference or not




©2011 Azul Systems, Inc.
Precise vs. Conservative Collection

                 A Collector is Conservative if it is unaware of some
                 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




©2011 Azul Systems, Inc.
Precise vs. Conservative Collection

                 A Collector is Conservative if it is unaware of some
                 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




©2011 Azul Systems, Inc.
Precise vs. Conservative Collection

                 A Collector is Conservative if it is unaware of some
                 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)




©2011 Azul Systems, Inc.
Precise vs. Conservative Collection

                 A Collector is Conservative if it is unaware of some
                 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




©2011 Azul Systems, Inc.
Precise vs. Conservative Collection

                 A Collector is Conservative if it is unaware of some
                 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




©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




©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




©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)




©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




©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”




©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




©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


©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?




©2011 Azul Systems, Inc.
What’s common to all
                                    precise GC mechanisms?

                     Identify the live objects in the memory heap




©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




©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




©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”)




©2011 Azul Systems, Inc.
Mark (aka “Trace”)


                     Start from “roots” (thread stacks, statics, etc.)




©2011 Azul Systems, Inc.
Mark (aka “Trace”)


                     Start from “roots” (thread stacks, statics, etc.)
                     “Paint” anything you can reach as “live”




©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”).




©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




©2011 Azul Systems, Inc.
Sweep



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




©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




©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”)




©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”)




©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”)




©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


©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




©2011 Azul Systems, Inc.
Copy

                     A copying collector moves all lives objects from a
                     “from” space to a “to” space & reclaims “from” space




©2011 Azul Systems, Inc.
Copy

                     A copying collector moves all lives 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.




©2011 Azul Systems, Inc.
Copy

                     A copying collector moves all lives 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




©2011 Azul Systems, Inc.
Copy

                     A copying collector moves all lives 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



©2011 Azul Systems, Inc.
Copy

                     A copying collector moves all lives 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




©2011 Azul Systems, Inc.
Mark/Sweep/Compact, Copy, Mark/Compact

                     Copy requires 2x the max. live set to be reliable




©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




©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)




©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




©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




©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


©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




©2011 Azul Systems, Inc.
Generational Collection
                 Generational Hypothesis: most objects die young




©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




©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




©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




©2011 Azul Systems, Inc.
Generational Collection

                     Requires a “Remembered set”: a way to track all
                     references into the young generation from the outside




©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




©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




©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.
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?




©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




©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 and OldGen
                     object needs to be intercepted and tracked




©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 and 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”




©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 and 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. non-
                             conditional
©2011 Azul Systems, Inc.
The typical combos
                                in commercial server JVMS




©2011 Azul Systems, Inc.
The typical combos
                                in commercial server JVMS

                     Young generation usually uses a copying collector




©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




©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




©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 mostly-
                     Incremental-STW


©2011 Azul Systems, Inc.
Useful terms for discussing
                                           garbage collection
                            Mutator                                Generational
                               Your program…                         Collects young objects and long lived
                                                                     objects separately.
                            Parallel
                               Can use multiple CPUs
                                                                   Promotion
                                                                     Allocation into old generation
                            Concurrent
                               Runs concurrently with program
                                                                   Marking
                                                                     Finding all live objects
                            Pause
                               A time duration in which the
                                                                   Sweeping
                               mutator is not running any code       Locating the dead objects

                            Stop-The-World (STW)                   Compaction
                               Something that is done in a pause     Defragments heap
                                                                     Moves objects in memory
                            Monolithic Stop-The-World
                                                                     Remaps all affected references
                               Something that must be done in
                                                                     Frees contiguous memory regions
                               it’s entirety in a single pause

©2011 Azul Systems, Inc.
Useful terms for discussing
                                           garbage collection
                            Mutator                                Generational
                               Your program…                         Collects young objects and long lived
                                                                     objects separately.
                            Parallel
                               Can use multiple CPUs
                                                                   Promotion
                                                                     Allocation into old generation
                            Concurrent
                               Runs concurrently with program
                                                                   Marking
                                                                     Finding all live objects
                            Pause
                               A time duration in which the
                                                                   Sweeping
                               mutator is not running any code       Locating the dead objects

                            Stop-The-World (STW)                   Compaction
                               Something that is done in a pause     Defragments heap
                                                                     Moves objects in memory
                            Monolithic Stop-The-World
                                                                     Remaps all affected references
                               Something that must be done in
                                                                     Frees contiguous memory regions
                               it’s entirety in a single pause

©2011 Azul Systems, Inc.
Useful metrics for discussing
                                         garbage collection
                            Heap population (aka Live set)          Cycle time
                               How much of your heap is alive         How long it takes the collector to free
                                                                      up memory
                            Allocation rate
                               How fast you allocate                Marking time
                                                                      How long it takes the collector to find
                            Mutation rate                             all live objects
                               How fast your program updates
                               references in memory                 Sweep time
                                                                      How long it takes to locate dead
                            Heap Shape                                objects
                               The shape of the live object graph     * Relevant for Mark-Sweep
                               * Hard to quantify as a metric...
                                                                    Compaction time
                            Object Lifetime                           How long it takes to free up memory
                               How long objects live                  by relocating objects
                                                                      * Relevant for Mark-Compact


©2011 Azul Systems, Inc.
Useful metrics for discussing
                                         garbage collection
                            Heap population (aka Live set)          Cycle time
                               How much of your heap is alive         How long it takes the collector to free
                                                                      up memory
                            Allocation rate
                               How fast you allocate                Marking time
                                                                      How long it takes the collector to find
                            Mutation rate                             all live objects
                               How fast your program updates
                               references in memory                 Sweep time
                                                                      How long it takes to locate dead
                            Heap Shape                                objects
                               The shape of the live object graph     * Relevant for Mark-Sweep
                               * Hard to quantify as a metric...
                                                                    Compaction time
                            Object Lifetime                           How long it takes to free up memory
                               How long objects live                  by relocating objects
                                                                      * Relevant for Mark-Compact


©2011 Azul Systems, Inc.
Useful metrics for discussing
                                         garbage collection
                            Heap population (aka Live set)          Cycle time
                               How much of your heap is alive         How long it takes the collector to free
                                                                      up memory
                            Allocation rate
                               How fast you allocate                Marking time
                                                                      How long it takes the collector to find
                            Mutation rate                             all live objects
                               How fast your program updates
                               references in memory                 Sweep time
                                                                      How long it takes to locate dead
                            Heap Shape                                objects
                               The shape of the live object graph     * Relevant for Mark-Sweep
                               * Hard to quantify as a metric...
                                                                    Compaction time
                            Object Lifetime                           How long it takes to free up memory
                               How long objects live                  by relocating objects
                                                                      * Relevant for Mark-Compact


©2011 Azul Systems, Inc.
Useful metrics for discussing
                                         garbage collection
                            Heap population (aka Live set)          Cycle time
                               How much of your heap is alive         How long it takes the collector to free
                                                                      up memory
                            Allocation rate
                               How fast you allocate                Marking time
                                                                      How long it takes the collector to find
                            Mutation rate                             all live objects
                               How fast your program updates
                               references in memory                 Sweep time
                                                                      How long it takes to locate dead
                            Heap Shape                                objects
                               The shape of the live object graph     * Relevant for Mark-Sweep
                               * Hard to quantify as a metric...
                                                                    Compaction time
                            Object Lifetime                           How long it takes to free up memory
                               How long objects live                  by relocating objects
                                                                      * Relevant for Mark-Compact


©2011 Azul Systems, Inc.
Useful metrics for discussing
                                         garbage collection
                            Heap population (aka Live set)          Cycle time
                               How much of your heap is alive         How long it takes the collector to free
                                                                      up memory
                            Allocation rate
                               How fast you allocate                Marking time
                                                                      How long it takes the collector to find
                            Mutation rate                             all live objects
                               How fast your program updates
                               references in memory                 Sweep time
                                                                      How long it takes to locate dead
                            Heap Shape                                objects
                               The shape of the live object graph     * Relevant for Mark-Sweep
                               * Hard to quantify as a metric...
                                                                    Compaction time
                            Object Lifetime                           How long it takes to free up memory
                               How long objects live                  by relocating objects
                                                                      * Relevant for Mark-Compact


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




©2011 Azul Systems, Inc.
Two Intuitive limits




©2011 Azul Systems, Inc.
Two Intuitive limits


                     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




©2011 Azul Systems, Inc.
Two Intuitive limits


                     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
                     If we had infinite empty memory, we would never have
                     to collect, and GC would take 0% of the CPU time




©2011 Azul Systems, Inc.
Two Intuitive limits


                     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
                     If we had infinite empty memory, we would never have
                     to collect, and GC would take 0% 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)




©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




©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




©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)




©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



©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




©2011 Azul Systems, Inc.
What empty memory controls

                     Empty memory controls efficiency (amount of collector
                     work needed per amount of application work
                     performed)




©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)




©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)




©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




©2011 Azul Systems, Inc.
Concurrent Marking
                     Mark all reachable objects as “live”, but object graph
                     is “mutating” under us.




©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




©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)


©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




©2011 Azul Systems, Inc.
Incremental Compaction

                     Track cross-region remembered sets (which region
                     points to which)




©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




©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




©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




©2011 Azul Systems, Inc.
Delaying the inevitable
                 Some form of copying/compaction is inevitable in practice
                            And compacting anything requires scanning/fixing all references to it




©2011 Azul Systems, Inc.
Delaying the inevitable
                 Some form of copying/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




©2011 Azul Systems, Inc.
Delaying the inevitable
                 Some form of copying/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. Hope for short STW.
                            But eventually, some old dead objects must be reclaimed




©2011 Azul Systems, Inc.
Delaying the inevitable
                 Some form of copying/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. Hope for short STW.
                            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




©2011 Azul Systems, Inc.
Delaying the inevitable
                 Some form of copying/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. Hope for short STW.
                            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




©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




©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




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




                Monolithic Stop-the-world copying NewGen




©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




©2011 Azul Systems, Inc.
HotSpot™ ConcMarkSweepGC (aka CMS)
                                    Collector mechanism classification

                     Monolithic Stop-the-world copying NewGen (ParNew)




©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)




©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




©2011 Azul Systems, Inc.
HotSpot™ G1GC (aka “Garbage First”)
                                     Collector mechanism classification

                     Monolithic Stop-the-world copying NewGen




©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




©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




©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:

                                   more than ½ GB?

                                   more than 1 GB?

                                   more than 2 GB?

                                   more than 4 GB?

                                   more than 10 GB?

                                   more than 20 GB?

                                   more than 50 GB?
©2011 Azul Systems, Inc.
Reality check: servers in 2012
Reality check: servers in 2012

Retail prices, major web server store (US $, May 2012)
  16 vCore, 96GB server        ≈ $5K
  16 vCore, 256GB server       ≈ $9K
  24 vCore, 384GB server       ≈ $14K
  32 vCore, 1TB server         ≈ $35K
Reality check: servers in 2012

Retail prices, major web server store (US $, May 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
Reality check: servers in 2012

Retail prices, major web server store (US $, May 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
The Application Memory Wall
                       A simple observation:




©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




©2011 Azul Systems, Inc.
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012
Understanding gc qconny2012

Weitere ähnliche Inhalte

Andere mochten auch

(Prog213) (introduction to programming)v1
(Prog213) (introduction to programming)v1(Prog213) (introduction to programming)v1
(Prog213) (introduction to programming)v1
Aaron Angeles
 
Using technology to maintain course quality- delivery a city course in the co...
Using technology to maintain course quality- delivery a city course in the co...Using technology to maintain course quality- delivery a city course in the co...
Using technology to maintain course quality- delivery a city course in the co...
HMVT Teaching and Learning Space
 
Life cycle of a star
Life cycle of a starLife cycle of a star
Life cycle of a star
mramsey4
 

Andere mochten auch (20)

Leading Change and Coaching
Leading Change and CoachingLeading Change and Coaching
Leading Change and Coaching
 
(Prog213) (introduction to programming)v1
(Prog213) (introduction to programming)v1(Prog213) (introduction to programming)v1
(Prog213) (introduction to programming)v1
 
『PHP逆引きレシピ』とセキュリティのこと
『PHP逆引きレシピ』とセキュリティのこと『PHP逆引きレシピ』とセキュリティのこと
『PHP逆引きレシピ』とセキュリティのこと
 
Handson Automating the Use of Web APIs through Lightweight Semantics
Handson Automating the Use of Web APIs through Lightweight SemanticsHandson Automating the Use of Web APIs through Lightweight Semantics
Handson Automating the Use of Web APIs through Lightweight Semantics
 
Scrum horoscope
Scrum horoscopeScrum horoscope
Scrum horoscope
 
CodeIgniterによるPhwittr
CodeIgniterによるPhwittrCodeIgniterによるPhwittr
CodeIgniterによるPhwittr
 
Sesja coachingowa ib
Sesja coachingowa ibSesja coachingowa ib
Sesja coachingowa ib
 
Diseno e implementacion de centro de procesamiento de datos en la ips centro ...
Diseno e implementacion de centro de procesamiento de datos en la ips centro ...Diseno e implementacion de centro de procesamiento de datos en la ips centro ...
Diseno e implementacion de centro de procesamiento de datos en la ips centro ...
 
OBD II Stack Solutions and Services
OBD II Stack Solutions and ServicesOBD II Stack Solutions and Services
OBD II Stack Solutions and Services
 
Vlsi design services
Vlsi design servicesVlsi design services
Vlsi design services
 
Using technology to maintain course quality- delivery a city course in the co...
Using technology to maintain course quality- delivery a city course in the co...Using technology to maintain course quality- delivery a city course in the co...
Using technology to maintain course quality- delivery a city course in the co...
 
Book entes 2015
Book entes 2015Book entes 2015
Book entes 2015
 
ATTACK Toolkit Webinar on Big Tobacco's Emerging Marketing
ATTACK Toolkit Webinar on Big Tobacco's Emerging MarketingATTACK Toolkit Webinar on Big Tobacco's Emerging Marketing
ATTACK Toolkit Webinar on Big Tobacco's Emerging Marketing
 
Say no to aborsi
Say no to aborsiSay no to aborsi
Say no to aborsi
 
Веб-аналитика для чайников
Веб-аналитика для чайниковВеб-аналитика для чайников
Веб-аналитика для чайников
 
CodeIgniterユーザガイドの翻訳に参加しよう!
CodeIgniterユーザガイドの翻訳に参加しよう!CodeIgniterユーザガイドの翻訳に参加しよう!
CodeIgniterユーザガイドの翻訳に参加しよう!
 
Why BDD is misunderstood?
Why BDD is misunderstood?Why BDD is misunderstood?
Why BDD is misunderstood?
 
Lara Morgan - Its Up To You - Fresh Business Thinking LIVE at Cass Business S...
Lara Morgan - Its Up To You - Fresh Business Thinking LIVE at Cass Business S...Lara Morgan - Its Up To You - Fresh Business Thinking LIVE at Cass Business S...
Lara Morgan - Its Up To You - Fresh Business Thinking LIVE at Cass Business S...
 
Вам не нужен сайт!
Вам не нужен сайт!Вам не нужен сайт!
Вам не нужен сайт!
 
Life cycle of a star
Life cycle of a starLife cycle of a star
Life cycle of a star
 

Ähnlich wie Understanding gc qconny2012

OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...
OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...
OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...
OpenNebula Project
 
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
ZeroTurnaround
 
Eclipse Modeling pour fabriquer ses DSL par Etienne Juliot
Eclipse Modeling pour fabriquer ses DSL par Etienne JuliotEclipse Modeling pour fabriquer ses DSL par Etienne Juliot
Eclipse Modeling pour fabriquer ses DSL par Etienne Juliot
EclipseDayParis
 

Ähnlich wie Understanding gc qconny2012 (20)

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
 
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
 
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
 
Understanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About ItUnderstanding Java Garbage Collection - And What You Can Do About It
Understanding Java Garbage Collection - And What You Can Do About It
 
Enabling Java in Latency-Sensitive Applications
Enabling Java in Latency-Sensitive ApplicationsEnabling Java in Latency-Sensitive Applications
Enabling Java in Latency-Sensitive Applications
 
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
 
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
 
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
 
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
 
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
 
GC @ jmaghreb2014
GC @ jmaghreb2014GC @ jmaghreb2014
GC @ jmaghreb2014
 
OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...
OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...
OpenNebulaConf 2016 - The Lightweight Approach to Build Cloud CyberSecurity E...
 
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
Top Java IDE keyboard shortcuts for Eclipse, IntelliJIDEA, NetBeans (report p...
 
Dev Environments: The Next Generation
Dev Environments: The Next GenerationDev Environments: The Next Generation
Dev Environments: The Next Generation
 
Eclipse Modeling pour fabriquer ses DSL par Etienne Juliot
Eclipse Modeling pour fabriquer ses DSL par Etienne JuliotEclipse Modeling pour fabriquer ses DSL par Etienne Juliot
Eclipse Modeling pour fabriquer ses DSL par Etienne Juliot
 
Deloitte Cem Ams 25 May2011
Deloitte Cem Ams 25 May2011Deloitte Cem Ams 25 May2011
Deloitte Cem Ams 25 May2011
 
Cr java concept by vikas jagtap
Cr java  concept by vikas jagtapCr java  concept by vikas jagtap
Cr java concept by vikas jagtap
 
Why Cloud Computing has to go the FOSS way
Why Cloud Computing has to go the FOSS wayWhy Cloud Computing has to go the FOSS way
Why Cloud Computing has to go the FOSS way
 
mqm-Agile
mqm-Agilemqm-Agile
mqm-Agile
 
Using AWS, Eucalyptus and Chef for the Optimal Hybrid Cloud
Using AWS, Eucalyptus and Chef for the Optimal Hybrid CloudUsing AWS, Eucalyptus and Chef for the Optimal Hybrid Cloud
Using AWS, Eucalyptus and Chef for the Optimal Hybrid Cloud
 

Kürzlich hochgeladen

Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
ciinovamais
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Kürzlich hochgeladen (20)

2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptxSKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
SKILL OF INTRODUCING THE LESSON MICRO SKILLS.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Dyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptxDyslexia AI Workshop for Slideshare.pptx
Dyslexia AI Workshop for Slideshare.pptx
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 

Understanding gc qconny2012

  • 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 ©2011 Azul Systems, Inc.
  • 3. This Talk’s Purpose / Goals This talk is focused on GC education ©2011 Azul Systems, Inc.
  • 4. 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 ©2011 Azul Systems, Inc.
  • 5. 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 ©2011 Azul Systems, Inc.
  • 6. 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... ©2011 Azul Systems, Inc.
  • 7. 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... ©2011 Azul Systems, Inc.
  • 8. 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.
  • 10. About me: Gil Tene co-founder, CTO @Azul Systems ©2011 Azul Systems, Inc.
  • 11. About me: Gil Tene co-founder, CTO @Azul Systems Have been working on a “think different” GC approaches since 2002 ©2011 Azul Systems, Inc.
  • 12. About me: Gil Tene co-founder, CTO @Azul Systems Have been working on a “think different” GC approaches since 2002 * working on real-world trash compaction issues, circa 2004 ©2011 Azul Systems, Inc.
  • 13. About me: Gil Tene co-founder, CTO @Azul Systems Have been working on a “think different” GC approaches since 2002 Created Pauseless & C4 core GC algorithms (Tene, Wolf) * working on real-world trash compaction issues, circa 2004 ©2011 Azul Systems, Inc.
  • 14. About me: Gil Tene co-founder, CTO @Azul Systems Have been working on a “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... * working on real-world trash compaction issues, circa 2004 ©2011 Azul Systems, Inc.
  • 15. About Azul ©2011 Azul Systems, Inc.
  • 16. About Azul We make scalable Virtual Machines ©2011 Azul Systems, Inc.
  • 17. About Azul We make scalable Virtual Machines Have built “whatever it takes to get job done” since 2002 ©2011 Azul Systems, Inc.
  • 18. About Azul 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) ©2011 Azul Systems, Inc.
  • 19. About Azul We make scalable Virtual Vega Machines Have built “whatever it takes to get job done” since 2002 3 generations of custom SMP Multi-core HW (Vega) ©2011 Azul Systems, Inc.
  • 20. About Azul We make scalable Virtual Vega Machines Have built “whatever it takes to get job done” since 2002 3 generations of custom SMP Multi-core HW (Vega) ©2011 Azul Systems, Inc.
  • 21. About Azul We make scalable Virtual Vega 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) ©2011 Azul Systems, Inc.
  • 22. About Azul We make scalable Virtual Vega 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 ©2011 Azul Systems, Inc.
  • 23. About Azul We make scalable Virtual Vega 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.
  • 24. High level agenda ©2011 Azul Systems, Inc.
  • 25. High level agenda GC fundamentals and key mechanisms ©2011 Azul Systems, Inc.
  • 26. High level agenda GC fundamentals and key mechanisms Some GC terminology & metrics ©2011 Azul Systems, Inc.
  • 27. High level agenda GC fundamentals and key mechanisms Some GC terminology & metrics Classifying currently available collectors ©2011 Azul Systems, Inc.
  • 28. High level agenda GC fundamentals and key mechanisms Some GC terminology & metrics Classifying currently available collectors The “Application Memory Wall” problem ©2011 Azul Systems, Inc.
  • 29. 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.
  • 30. Memory use ©2011 Azul Systems, Inc.
  • 31. Memory use ©2011 Azul Systems, Inc.
  • 32. Memory use How many of you use heap sizes of: ©2011 Azul Systems, Inc.
  • 33. Memory use How many of you use heap sizes of:  more than ½ GB? ©2011 Azul Systems, Inc.
  • 34. Memory use How many of you use heap sizes of:  more than ½ GB?  more than 1 GB? ©2011 Azul Systems, Inc.
  • 35. Memory use How many of you use heap sizes of:  more than ½ GB?  more than 1 GB?  more than 2 GB? ©2011 Azul Systems, Inc.
  • 36. Memory use How many of you use heap sizes of:  more than ½ GB?  more than 1 GB?  more than 2 GB?  more than 4 GB? ©2011 Azul Systems, Inc.
  • 37. Memory use How many of you use heap sizes of:  more than ½ GB?  more than 1 GB?  more than 2 GB?  more than 4 GB?  more than 10 GB? ©2011 Azul Systems, Inc.
  • 38. Memory use How many of you use heap sizes of:  more than ½ GB?  more than 1 GB?  more than 2 GB?  more than 4 GB?  more than 10 GB?  more than 20 GB? ©2011 Azul Systems, Inc.
  • 39. Memory use How many of you use heap sizes of:  more than ½ GB?  more than 1 GB?  more than 2 GB?  more than 4 GB?  more than 10 GB?  more than 20 GB?  more than 50 GB? ©2011 Azul Systems, Inc.
  • 40. Memory use How many of you use heap sizes of:  more than ½ GB?  more than 1 GB?  more than 2 GB?  more than 4 GB?  more than 10 GB?  more than 20 GB?  more than 50 GB? ©2011 Azul Systems, Inc.
  • 41. Why should you care about GC? ©2011 Azul Systems, Inc.
  • 42. The story of the good little architect ©2011 Azul Systems, Inc.
  • 43. The story of the good little architect A good architect must, first and foremost, be able to impose their architectural choices on the project... ©2011 Azul Systems, Inc.
  • 44. 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 ©2011 Azul Systems, Inc.
  • 45. 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 millions of object finalizations per GC cycle ©2011 Azul Systems, Inc.
  • 46. 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 millions of object finalizations per GC cycle *We have since made reference processing fully concurrent... ©2011 Azul Systems, Inc.
  • 47. 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 millions of object finalizations per GC cycle *We have since made reference processing fully concurrent... Every single class written in the project has a finalizer ©2011 Azul Systems, Inc.
  • 48. 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 millions of object finalizations per GC cycle *We have since made reference processing fully concurrent... Every single class written in the project has a finalizer The only work the finalizers did was nulling every reference field ©2011 Azul Systems, Inc.
  • 49. 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 millions of object finalizations per GC cycle *We have since made reference processing fully concurrent... Every single class written in the project has a finalizer The only work the finalizers did was nulling every reference field The right discipline for a C++ ref-counting environment ©2011 Azul Systems, Inc.
  • 50. 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 millions of object finalizations per GC cycle *We have since made reference processing fully concurrent... Every single class written in the project has 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.
  • 51. Trying to solve GC problems in application architecture is like throwing knives ©2011 Azul Systems, Inc.
  • 52. Trying to solve GC problems in application architecture is like throwing knives You probably shouldn’t do it blindfolded ©2011 Azul Systems, Inc.
  • 53. 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 ©2011 Azul Systems, Inc.
  • 54. 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? ©2011 Azul Systems, Inc.
  • 55. 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.
  • 56. Most of what People seem to “know” about Garbage Collection is wrong ©2011 Azul Systems, Inc.
  • 57. 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) ... ©2011 Azul Systems, Inc.
  • 58. 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.
  • 59. Some GC Terminology ©2011 Azul Systems, Inc.
  • 60. A Basic Terminology example: What is a concurrent collector? ©2011 Azul Systems, Inc.
  • 61. A Basic Terminology example: What is a concurrent collector? A Concurrent Collector performs garbage collection work concurrently with the application’s own execution ©2011 Azul Systems, Inc.
  • 62. 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.
  • 63. 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 ©2011 Azul Systems, Inc.
  • 64. 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 ©2011 Azul Systems, Inc.
  • 65. 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 ©2011 Azul Systems, Inc.
  • 66. 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.
  • 67. Precise vs. Conservative Collection ©2011 Azul Systems, Inc.
  • 68. Precise vs. Conservative Collection A Collector is Conservative if it is unaware of some object references at collection time, or is unsure about whether a field is a reference or not ©2011 Azul Systems, Inc.
  • 69. Precise vs. Conservative Collection A Collector is Conservative if it is unaware of some 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 ©2011 Azul Systems, Inc.
  • 70. Precise vs. Conservative Collection A Collector is Conservative if it is unaware of some 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 ©2011 Azul Systems, Inc.
  • 71. Precise vs. Conservative Collection A Collector is Conservative if it is unaware of some 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) ©2011 Azul Systems, Inc.
  • 72. Precise vs. Conservative Collection A Collector is Conservative if it is unaware of some 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 ©2011 Azul Systems, Inc.
  • 73. Precise vs. Conservative Collection A Collector is Conservative if it is unaware of some 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.
  • 75. 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 ©2011 Azul Systems, Inc.
  • 76. 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 ©2011 Azul Systems, Inc.
  • 77. 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) ©2011 Azul Systems, Inc.
  • 78. 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 ©2011 Azul Systems, Inc.
  • 79. 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” ©2011 Azul Systems, Inc.
  • 80. 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 ©2011 Azul Systems, Inc.
  • 81. 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 ©2011 Azul Systems, Inc.
  • 82. 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.
  • 83. What’s common to all precise GC mechanisms? ©2011 Azul Systems, Inc.
  • 84. What’s common to all precise GC mechanisms? Identify the live objects in the memory heap ©2011 Azul Systems, Inc.
  • 85. What’s common to all precise GC mechanisms? Identify the live objects in the memory heap Reclaim resources held by dead objects ©2011 Azul Systems, Inc.
  • 86. 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 ©2011 Azul Systems, Inc.
  • 87. 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.
  • 88. Mark (aka “Trace”) ©2011 Azul Systems, Inc.
  • 89. Mark (aka “Trace”) Start from “roots” (thread stacks, statics, etc.) ©2011 Azul Systems, Inc.
  • 90. Mark (aka “Trace”) Start from “roots” (thread stacks, statics, etc.) “Paint” anything you can reach as “live” ©2011 Azul Systems, Inc.
  • 91. 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”). ©2011 Azul Systems, Inc.
  • 92. 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.
  • 94. Sweep Scan through the heap, identify “dead” objects and track them somehow (usually in some form of free list) ©2011 Azul Systems, Inc.
  • 95. 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.
  • 97. Compact Over time, heap will get “swiss cheesed”: contiguous dead space between objects may not be large enough to fit new objects (aka “fragmentation”) ©2011 Azul Systems, Inc.
  • 98. 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”) ©2011 Azul Systems, Inc.
  • 99. 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”) ©2011 Azul Systems, Inc.
  • 100. 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 ©2011 Azul Systems, Inc.
  • 101. 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.
  • 103. Copy A copying collector moves all lives objects from a “from” space to a “to” space & reclaims “from” space ©2011 Azul Systems, Inc.
  • 104. Copy A copying collector moves all lives 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. ©2011 Azul Systems, Inc.
  • 105. Copy A copying collector moves all lives 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 ©2011 Azul Systems, Inc.
  • 106. Copy A copying collector moves all lives 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 ©2011 Azul Systems, Inc.
  • 107. Copy A copying collector moves all lives 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.
  • 109. Mark/Sweep/Compact, Copy, Mark/Compact Copy requires 2x the max. live set to be reliable ©2011 Azul Systems, Inc.
  • 110. 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 ©2011 Azul Systems, Inc.
  • 111. 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) ©2011 Azul Systems, Inc.
  • 112. 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 ©2011 Azul Systems, Inc.
  • 113. 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 ©2011 Azul Systems, Inc.
  • 114. 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 ©2011 Azul Systems, Inc.
  • 115. 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.
  • 117. Generational Collection Generational Hypothesis: most objects die young ©2011 Azul Systems, Inc.
  • 118. 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 ©2011 Azul Systems, Inc.
  • 119. 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 ©2011 Azul Systems, Inc.
  • 120. 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.
  • 122. Generational Collection Requires a “Remembered set”: a way to track all references into the young generation from the outside ©2011 Azul Systems, Inc.
  • 123. 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 ©2011 Azul Systems, Inc.
  • 124. 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 ©2011 Azul Systems, Inc.
  • 125. 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.
  • 126. 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.
  • 127. How does the remembered set work? ©2011 Azul Systems, Inc.
  • 128. 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 ©2011 Azul Systems, Inc.
  • 129. 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 and OldGen object needs to be intercepted and tracked ©2011 Azul Systems, Inc.
  • 130. 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 and 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” ©2011 Azul Systems, Inc.
  • 131. 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 and 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. non- conditional ©2011 Azul Systems, Inc.
  • 132. The typical combos in commercial server JVMS ©2011 Azul Systems, Inc.
  • 133. The typical combos in commercial server JVMS Young generation usually uses a copying collector ©2011 Azul Systems, Inc.
  • 134. The typical combos in commercial server JVMS Young generation usually uses a copying collector Young generation is usually monolithic, stop-the-world ©2011 Azul Systems, Inc.
  • 135. 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 ©2011 Azul Systems, Inc.
  • 136. 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 mostly- Incremental-STW ©2011 Azul Systems, Inc.
  • 137. Useful terms for discussing garbage collection Mutator Generational Your program… Collects young objects and long lived objects separately. Parallel Can use multiple CPUs Promotion Allocation into old generation Concurrent Runs concurrently with program Marking Finding all live objects Pause A time duration in which the Sweeping mutator is not running any code Locating the dead objects Stop-The-World (STW) Compaction Something that is done in a pause Defragments heap Moves objects in memory Monolithic Stop-The-World Remaps all affected references Something that must be done in Frees contiguous memory regions it’s entirety in a single pause ©2011 Azul Systems, Inc.
  • 138. Useful terms for discussing garbage collection Mutator Generational Your program… Collects young objects and long lived objects separately. Parallel Can use multiple CPUs Promotion Allocation into old generation Concurrent Runs concurrently with program Marking Finding all live objects Pause A time duration in which the Sweeping mutator is not running any code Locating the dead objects Stop-The-World (STW) Compaction Something that is done in a pause Defragments heap Moves objects in memory Monolithic Stop-The-World Remaps all affected references Something that must be done in Frees contiguous memory regions it’s entirety in a single pause ©2011 Azul Systems, Inc.
  • 139. Useful metrics for discussing garbage collection Heap population (aka Live set) Cycle time How much of your heap is alive How long it takes the collector to free up memory Allocation rate How fast you allocate Marking time How long it takes the collector to find Mutation rate all live objects How fast your program updates references in memory Sweep time How long it takes to locate dead Heap Shape objects The shape of the live object graph * Relevant for Mark-Sweep * Hard to quantify as a metric... Compaction time Object Lifetime How long it takes to free up memory How long objects live by relocating objects * Relevant for Mark-Compact ©2011 Azul Systems, Inc.
  • 140. Useful metrics for discussing garbage collection Heap population (aka Live set) Cycle time How much of your heap is alive How long it takes the collector to free up memory Allocation rate How fast you allocate Marking time How long it takes the collector to find Mutation rate all live objects How fast your program updates references in memory Sweep time How long it takes to locate dead Heap Shape objects The shape of the live object graph * Relevant for Mark-Sweep * Hard to quantify as a metric... Compaction time Object Lifetime How long it takes to free up memory How long objects live by relocating objects * Relevant for Mark-Compact ©2011 Azul Systems, Inc.
  • 141. Useful metrics for discussing garbage collection Heap population (aka Live set) Cycle time How much of your heap is alive How long it takes the collector to free up memory Allocation rate How fast you allocate Marking time How long it takes the collector to find Mutation rate all live objects How fast your program updates references in memory Sweep time How long it takes to locate dead Heap Shape objects The shape of the live object graph * Relevant for Mark-Sweep * Hard to quantify as a metric... Compaction time Object Lifetime How long it takes to free up memory How long objects live by relocating objects * Relevant for Mark-Compact ©2011 Azul Systems, Inc.
  • 142. Useful metrics for discussing garbage collection Heap population (aka Live set) Cycle time How much of your heap is alive How long it takes the collector to free up memory Allocation rate How fast you allocate Marking time How long it takes the collector to find Mutation rate all live objects How fast your program updates references in memory Sweep time How long it takes to locate dead Heap Shape objects The shape of the live object graph * Relevant for Mark-Sweep * Hard to quantify as a metric... Compaction time Object Lifetime How long it takes to free up memory How long objects live by relocating objects * Relevant for Mark-Compact ©2011 Azul Systems, Inc.
  • 143. Useful metrics for discussing garbage collection Heap population (aka Live set) Cycle time How much of your heap is alive How long it takes the collector to free up memory Allocation rate How fast you allocate Marking time How long it takes the collector to find Mutation rate all live objects How fast your program updates references in memory Sweep time How long it takes to locate dead Heap Shape objects The shape of the live object graph * Relevant for Mark-Sweep * Hard to quantify as a metric... Compaction time Object Lifetime How long it takes to free up memory How long objects live by relocating objects * Relevant for Mark-Compact ©2011 Azul Systems, Inc.
  • 144. Empty memory and CPU/throughput ©2011 Azul Systems, Inc.
  • 145. Two Intuitive limits ©2011 Azul Systems, Inc.
  • 146. Two Intuitive limits 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 ©2011 Azul Systems, Inc.
  • 147. Two Intuitive limits 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 If we had infinite empty memory, we would never have to collect, and GC would take 0% of the CPU time ©2011 Azul Systems, Inc.
  • 148. Two Intuitive limits 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 If we had infinite empty memory, we would never have to collect, and GC would take 0% 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.
  • 149. Empty memory needs (empty memory == CPU power) ©2011 Azul Systems, Inc.
  • 150. 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 ©2011 Azul Systems, Inc.
  • 151. 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 ©2011 Azul Systems, Inc.
  • 152. 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) ©2011 Azul Systems, Inc.
  • 153. 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 ©2011 Azul Systems, Inc.
  • 154. 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.
  • 155. What empty memory controls ©2011 Azul Systems, Inc.
  • 156. What empty memory controls Empty memory controls efficiency (amount of collector work needed per amount of application work performed) ©2011 Azul Systems, Inc.
  • 157. 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) ©2011 Azul Systems, Inc.
  • 158. 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) ©2011 Azul Systems, Inc.
  • 159. 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.
  • 160. Some non monolithic-STW stuff ©2011 Azul Systems, Inc.
  • 162. Concurrent Marking Mark all reachable objects as “live”, but object graph is “mutating” under us. ©2011 Azul Systems, Inc.
  • 163. 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 ©2011 Azul Systems, Inc.
  • 164. 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) ©2011 Azul Systems, Inc.
  • 165. 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.
  • 167. Incremental Compaction Track cross-region remembered sets (which region points to which) ©2011 Azul Systems, Inc.
  • 168. 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 ©2011 Azul Systems, Inc.
  • 169. 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 ©2011 Azul Systems, Inc.
  • 170. 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.
  • 171. Delaying the inevitable ©2011 Azul Systems, Inc.
  • 172. Delaying the inevitable Some form of copying/compaction is inevitable in practice And compacting anything requires scanning/fixing all references to it ©2011 Azul Systems, Inc.
  • 173. Delaying the inevitable Some form of copying/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 ©2011 Azul Systems, Inc.
  • 174. Delaying the inevitable Some form of copying/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. Hope for short STW. But eventually, some old dead objects must be reclaimed ©2011 Azul Systems, Inc.
  • 175. Delaying the inevitable Some form of copying/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. Hope for short STW. 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 ©2011 Azul Systems, Inc.
  • 176. Delaying the inevitable Some form of copying/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. Hope for short STW. 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.
  • 178. The typical combos in commercial server JVMS ©2011 Azul Systems, Inc.
  • 179. The typical combos in commercial server JVMS Young generation usually uses a copying collector Young generation is usually monolithic, stop-the-world ©2011 Azul Systems, Inc.
  • 180. 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.
  • 181. HotSpot™ ParallelGC Collector mechanism classification ©2011 Azul Systems, Inc.
  • 182. HotSpot™ ParallelGC Collector mechanism classification Monolithic Stop-the-world copying NewGen ©2011 Azul Systems, Inc.
  • 183. HotSpot™ ParallelGC Collector mechanism classification Monolithic Stop-the-world copying NewGen Monolithic Stop-the-world Mark/Sweep/Compact OldGen ©2011 Azul Systems, Inc.
  • 184. HotSpot™ ConcMarkSweepGC (aka CMS) Collector mechanism classification ©2011 Azul Systems, Inc.
  • 185. HotSpot™ ConcMarkSweepGC (aka CMS) Collector mechanism classification Monolithic Stop-the-world copying NewGen (ParNew) ©2011 Azul Systems, Inc.
  • 186. 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) ©2011 Azul Systems, Inc.
  • 187. 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.
  • 188. HotSpot™ G1GC (aka “Garbage First”) Collector mechanism classification ©2011 Azul Systems, Inc.
  • 189. HotSpot™ G1GC (aka “Garbage First”) Collector mechanism classification Monolithic Stop-the-world copying NewGen ©2011 Azul Systems, Inc.
  • 190. 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 ©2011 Azul Systems, Inc.
  • 191. 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 ©2011 Azul Systems, Inc.
  • 192. 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.
  • 193. The “Application Memory Wall” ©2011 Azul Systems, Inc.
  • 194. Memory use How many of you use heap sizes of:  more than ½ GB?  more than 1 GB?  more than 2 GB?  more than 4 GB?  more than 10 GB?  more than 20 GB?  more than 50 GB? ©2011 Azul Systems, Inc.
  • 196. Reality check: servers in 2012 Retail prices, major web server store (US $, May 2012) 16 vCore, 96GB server ≈ $5K 16 vCore, 256GB server ≈ $9K 24 vCore, 384GB server ≈ $14K 32 vCore, 1TB server ≈ $35K
  • 197. Reality check: servers in 2012 Retail prices, major web server store (US $, May 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
  • 198. Reality check: servers in 2012 Retail prices, major web server store (US $, May 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
  • 199. The Application Memory Wall A simple observation: ©2011 Azul Systems, Inc.
  • 200. The Application Memory Wall A simple observation: Application instances appear to be unable to make effective use of modern server memory capacities ©2011 Azul Systems, Inc.

Hinweis der Redaktion

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n
  22. \n
  23. \n
  24. \n
  25. \n
  26. \n
  27. \n
  28. \n
  29. \n
  30. \n
  31. \n
  32. \n
  33. \n
  34. \n
  35. \n
  36. \n
  37. \n
  38. \n
  39. \n
  40. \n
  41. \n
  42. \n
  43. \n
  44. \n
  45. \n
  46. \n
  47. \n
  48. \n
  49. \n
  50. \n
  51. \n
  52. \n
  53. \n
  54. \n
  55. \n
  56. \n
  57. \n
  58. \n
  59. \n
  60. \n
  61. \n
  62. \n
  63. \n
  64. \n
  65. \n
  66. \n
  67. \n
  68. \n
  69. \n
  70. \n
  71. \n
  72. \n
  73. \n
  74. \n
  75. \n
  76. \n
  77. \n
  78. \n
  79. \n
  80. \n
  81. \n
  82. \n
  83. \n
  84. \n
  85. \n
  86. \n
  87. \n
  88. \n
  89. \n
  90. \n
  91. \n
  92. \n
  93. \n
  94. \n
  95. \n
  96. \n
  97. \n
  98. \n
  99. \n
  100. \n
  101. \n
  102. \n
  103. \n
  104. \n
  105. \n
  106. \n
  107. \n
  108. \n
  109. \n
  110. \n
  111. \n
  112. \n
  113. \n
  114. \n
  115. \n
  116. \n
  117. \n
  118. \n
  119. \n
  120. \n
  121. \n
  122. \n
  123. \n
  124. \n
  125. \n
  126. \n
  127. \n
  128. \n
  129. \n
  130. \n
  131. \n
  132. \n
  133. \n
  134. \n
  135. \n
  136. \n
  137. \n
  138. \n
  139. \n
  140. \n
  141. \n
  142. \n
  143. \n
  144. \n
  145. \n
  146. \n
  147. \n
  148. \n
  149. \n
  150. \n
  151. \n
  152. \n
  153. \n
  154. \n
  155. \n
  156. \n
  157. \n
  158. \n
  159. \n
  160. \n
  161. \n
  162. \n
  163. \n
  164. \n
  165. \n
  166. \n
  167. \n
  168. \n
  169. \n
  170. \n
  171. \n
  172. \n
  173. \n
  174. \n
  175. \n
  176. \n
  177. \n
  178. \n
  179. \n
  180. \n
  181. \n
  182. \n
  183. \n
  184. \n
  185. \n
  186. \n
  187. \n
  188. \n
  189. \n
  190. \n
  191. \n
  192. \n
  193. \n
  194. \n
  195. \n
  196. \n
  197. \n
  198. \n
  199. \n
  200. \n
  201. \n
  202. \n
  203. \n
  204. \n
  205. \n
  206. \n
  207. \n
  208. \n
  209. \n
  210. \n
  211. \n
  212. \n
  213. \n
  214. \n
  215. \n
  216. \n
  217. \n
  218. \n
  219. \n
  220. \n
  221. \n
  222. \n
  223. \n
  224. \n
  225. \n
  226. \n
  227. \n
  228. \n
  229. \n
  230. \n
  231. \n
  232. \n
  233. \n
  234. \n
  235. \n
  236. \n
  237. \n
  238. \n
  239. \n
  240. \n
  241. \n
  242. \n
  243. \n
  244. \n
  245. \n
  246. \n
  247. \n
  248. \n
  249. \n
  250. \n
  251. \n
  252. \n
  253. \n
  254. \n
  255. \n
  256. \n
  257. \n
  258. \n
  259. \n
  260. \n
  261. \n
  262. \n
  263. \n
  264. \n
  265. \n
  266. \n
  267. \n
  268. \n
  269. \n
  270. \n
  271. \n
  272. \n
  273. \n
  274. \n
  275. \n