sequence

This paper focuses on SATB of Garbage Collector

CMS, G1 and Shenandoah all adopt SATB technology in concurrent marking

Shenandoah

Shenandoah is oriented towards low-pause-time garbage collectors, whose GC cycles are mainly

  • Snapshot-at-the-beginning concurrent markIncluding Init Mark(Pause), Concurrent Mark, and Final Mark(Pause)
  • Concurrent evacuation(This stage uses Brooks Pointers(object version change with additional atomically changed indirection) copy)
  • Concurrent update references (optional)Including Init update Refs(Pause), Concurrent Update Refs, and Final Update Refs(Pause)

Shenandoah uses SATB techniques for concurrent marking

SATB

SATB is Snapshot At The Beginning.

  • Mark’s process is to iterate through the heap tag live object, using the three-color tag algorithm, the three colors are white(Indicates that the file has not been accessed), gray (But the reference it uses has not been fully scanned), black (Access and the reference used by it has been fully scanned), the whole three-color labeling algorithm is to traverse heap starting from GC Roots and mark white as gray and then gray as black for reachable objects; After traversal all reachable objects are black and all whites are recyclable
  • SATB仅仅对于在marking开始阶段进行”snapshot”(marked all reachable at mark start), but concurrent modification of a concurrent object may cause the object to miss marks, for example
    • A new reference to a White object to black, and then a reference to the white object removed from the gray object, causes the white object to miss flags
    • Adding a new reference to a White object to black and then deleting a reference to the white object from the gray object also causes the white object to miss flags
    • A new reference to black to a newly created White object, which no other Gray object references, also causes the white object to miss the mark
  • In marking phase, SATB marks the target reference object removed from gray object as gray, and the newly generated object referenced by black object as black. Because the snapshot is taken at the beginning, Floating Garbage may exist

summary

  • CMS, G1 and Shenandoah all adopt SATB technology when conducting concurrent marking; The SATB Concurrent Mark is the first cycle of the Shenandoah GC
  • Traversal heap tag live Object, using the three-color tag algorithm, these three colors are white(Indicates that the file has not been accessed), gray (But the reference it uses has not been fully scanned), black (Access and the reference used by it has been fully scanned), the whole three-color labeling algorithm is to traverse heap starting from GC Roots and mark white as gray and then gray as black for reachable objects; After traversal all reachable objects are black and all whites are recyclable
  • SATB仅仅对于在marking开始阶段进行”snapshot”(marked all reachable at mark start); In the marking phase, target reference objects removed from gray objects are marked gray, and newly generated objects from black references are marked black; Because the snapshot is taken at the beginning, Floating Garbage may exist

doc

  • snapshot-at-the-beginning
  • Shenandoah GC: Concurrent parallel marking
  • Floating Garbage
  • [HotSpot] VM understanding of Incremental Update and SATB
  • Some key technologies for the Java Hotspot G1 GC