Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-7055086

G1: can rely on used_region_at_save_marks() outside a GC

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Not an Issue
    • Icon: P4 P4
    • tbd
    • hs22
    • hotspot
    • gc
    • generic
    • generic

      In G1 we can scan cards both during and outside a STW GC. We typically don't want to scan objects that have been copied to a region during a GC. So, we use the save_marks() mechanism to checkpoint top before we start copying objects into the region so that we bound any card scanning by the checkpointed top.

      To avoid calling save_marks() on all regions before a GC we rely on a timestamp mechanism. When we call save_marks() on a region we will start allocating to during the GC we tag said region with the current GC timestamp. So, the card scanning is bound by either top_at_save_marks(), if the region's timestamp is current, or top() if it's not. The timestamp is incremented once at the start of a GC which essentially invalidates all the previous save_marks() information.

      When we scan cards outside GC we always want to use top and ignore save_marks(). So the card scanning code looks like this:

        if (G1CollectedHeap::heap()->is_gc_active()) {
          mr = mr.intersection(used_region_at_save_marks());
        } else {
          mr = mr.intersection(used_region());
        }

      On a separate changeset (7039627) we are changing the code to also increment the timestamp at the end of a GC. This essentially invalidates the save_marks() information on all regions. So we have an opportunity to remove the above check and always rely on the used_region_at_save_marks() returning the right value whether we are during a pause or outside one.

            Unassigned Unassigned
            tonyp Tony Printezis
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: