11
Balanced GC – Why, What & How Parameswaran Selvam IBM Runtimes – J9 VM J9 VM Knowledge Sharing Session

J9 Balanced GC

Embed Size (px)

Citation preview

Page 1: J9 Balanced GC

Balanced GC – Why, What & How

Parameswaran Selvam

IBM Runtimes – J9 VM

J9 VM Knowledge Sharing Session

Page 2: J9 Balanced GC

Balanced GC

§WHY?

– Application Pause Time increases as Java Heap size increases with existing GCpolicies

● Applications with Heap sizes > 20 GB are common

– A GC policy with short & constant Pause time, though not guaranteed

2

512 1024 4096 81920

0.5

1

1.5

2

2.5

RealityExpected

Heap Size

Pau

se T

ime

Page 3: J9 Balanced GC

Balanced GC

§WHAT is?

– Heap Layout

● Region based GC method● Divides Java Heap into fixed size regions ● Regions grouped/named into max 24 generations

● New Objects allocated/stored in regions tagged as 0th generation/Age 0 orEden space

Java Heap : Regions belong to different generations set

3

Page 4: J9 Balanced GC

Balanced GC

§WHAT is?

– GC Phases

● Partial Garbage Collect (PGC)– When Eden space becomes full

● Global Mark Phase (GMP)– When reaches certain threshold like free memory, allocation rate

● Global GC

– When PGC/GMP doesn’t yield returns or When application explicitlyinvoked

4

Page 5: J9 Balanced GC

Balanced GC

§WHAT is?

– Partial Garbage Collect (PGC)

● Stop The World(STW) GC execution, hence application threads executionstopped

● Picks up the regions belong/tag to eden space + other regions(which areidentified by GMP as regions contains more dead objects/memoryreclaimed)

● 2 algorithms/methods used

– Copy Forward– Mark & Compact

● PGC picks up a method based on heap availability

5

Page 6: J9 Balanced GC

Balanced GC

§WHAT is?

– Partial Garbage Collect (PGC) – Copy Forward

● Same as nursery/scavenger GC in GENCON(Generational Concurrent)

● Scans through objects in collection regions set

● Shifting the live object to its next generation region – promoting the object

Eden full – PGC triggered

PGC shifts/moves object

Before PGC

PGC – Copy Forward

After PGC6

Page 7: J9 Balanced GC

Balanced GC

§WHAT is?

– Partial Garbage Collect (PGC) – Mark Compact

● Scans through objects in collection regions set

● Mark the live objects in collection set regions

● Compact the regions based on their generation set

7

Eden full – PGC triggered

PGC – Mark Compact

PGC compact

Before PGC

After PGC

Page 8: J9 Balanced GC

Balanced GC

§WHAT is?

– Global Mark Phase (GMP)

● Stop The World GC operation

● Scans through the entire Java heap to build up the live objects data

● PGC consumes the live objects data prepared by GMP once GMPcompletes

● Makes use of idle processor time to do concurrent mark

Next PGC takes up GMPconstructed live objects dataset

8

Page 9: J9 Balanced GC

Balanced GC

9

§ How to?

– Monitor / Study GC execution

● -verbose:gc enables verbose GC and writes data into JVM stderr stream

● -Xverbosgclog:<filename> to redirect the output to file

● Use “Garbage Collection & Memory Visualizer” tool to interpret the verboseGC data

Page 10: J9 Balanced GC

Balanced GC

10

§ How to?

10

Page 11: J9 Balanced GC

Q & A

13