Skip to content

Instantly share code, notes, and snippets.

@fmeyer
Last active April 24, 2023 12:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fmeyer/87fce5279bb06e215828e7732fed740e to your computer and use it in GitHub Desktop.
Save fmeyer/87fce5279bb06e215828e7732fed740e to your computer and use it in GitHub Desktop.

❯ tldw --ouline-summary https://www.youtube.com/watch\?v=OnodHoNYE1Y

I. Introduction

  • Speaker: Paul Sue, software director at Oracle and manager of the hotspot garbage collection team
  • The session is about ZGC and garbage collection
  • Java workloads vary in size, complexity, and performance priorities, so multiple collectors are needed to serve all.

II. Java collectors available in Hotspot

  • Serial GC: simple collector optimized for smaller memory footprint
  • Parallel GC: throughput-oriented collector
  • G1: default GC since JDK 9, provides a balance between throughput and latency
  • ZGC: focuses on low-latency, high scalability, and minimal tuning requirements

III. Selecting the best collector for your workload

  • It's not as simple as looking at the Heap size or other characteristics
  • Try the various GCs on your workload to find the best fit
  • The GC tuning guide provides advice on adjusting JVM settings and definitions of GC terms.

IV. Development timeline for ZGC

  • Initial investigation began in 2014
  • Released as an experimental feature in JDK 11 in 2018
  • Improvements and significant features added every six months.

V. Guiding principles behind ZGC's design and development

  • Scalable to handle Java heaps from a few hundred megabytes to multiple terabytes
  • Focuses on low latency with GC pause times less than a millisecond, regardless of Heap size
  • Maintains good overall application performance, ideally within 15% of the throughput performance of G1 on the same workload
  • Reduces the amount of tuning required to optimize performance.

VI. How ZGC accomplishes its goals

  • Concurrent collector: GC work is done while Java threads continue to execute
  • Parallel collector: work is split into multiple parts and run across many threads simultaneously
  • Compacting collector: moves objects around to fight fragmentation
  • Region-based collector: collects a subset of the Heap, typically those regions with the most garbage
  • Pneuma-aware collector: allocates objects in memory local to the CPU that the thread is executing on for the best memory latency
  • Auto-tuned collector: works well out of the box without complex configuration
  • Uses load barriers and colored pointers to achieve concurrency.

VII. GC cycle in ZGC

  • Blue arrows pointing down are GC save points, the only sources of GC pauses
  • Actual GC work happens in concurrent phases represented by horizontal arrows
  • Application continues to run during GC.

VIII. Performance numbers for ZGC

  • Results from SPECjbb2015 industry standard Java benchmark
  • ZGC has lower throughput score than G1, but lower latency score
  • ZGC has sub-millisecond pause times, even on multiple terabyte heaps.

IX. Generational ZGC

  • Weak generational hypothesis: most objects are short-lived, so dividing the Heap into two logical regions (Young and Old Generations) can improve efficiency
  • Handling higher allocation rates with lower Heap overhead reduces the likelihood of allocation stalls
  • Generational ZGC can achieve four times the throughput and use 25% of the memory compared to ZGC, while still maintaining the same sub-millisecond pause times.
  • The complexity of Generational ZGC is higher, but it minimizes tuning requirements.

X. More information on ZGC and Hotspot collectors

  • ZGC project%
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment