7052429: G1: Avoid unnecessary scanning of humongous regions during concurrent marking
authorjohnc
Wed, 06 Feb 2013 14:50:37 -0800
changeset 15604 0209977cd9c4
parent 15496 7ff51ce6860c
child 15605 bf7de87bbe3a
child 15606 8cd2bedf376f
7052429: G1: Avoid unnecessary scanning of humongous regions during concurrent marking Summary: Skip unnecessary scanning of bitmap for unmarked humongous objects/regions. Reviewed-by: jwilhelm, johnc Contributed-by: Tao Mao <tao.mao@oracle.com>
hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp
hotspot/src/share/vm/runtime/globals.hpp
--- a/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Tue Feb 05 22:24:36 2013 -0800
+++ b/hotspot/src/share/vm/gc_implementation/g1/concurrentMark.cpp	Wed Feb 06 14:50:37 2013 -0800
@@ -4066,11 +4066,23 @@
                                _worker_id, _finger, _region_limit, _curr_region);
       }
 
-      // Let's iterate over the bitmap of the part of the
-      // region that is left.
-      if (mr.is_empty() || _nextMarkBitMap->iterate(&bitmap_closure, mr)) {
-        // We successfully completed iterating over the region. Now,
-        // let's give up the region.
+      HeapRegion* hr = _g1h->heap_region_containing(mr.start());
+      assert(!hr->isHumongous() || mr.start() == hr->bottom(),
+             "the start of HeapRegion and MemRegion should be consistent for humongous regions");
+
+      // The special case of the bitmap of a humongous region with its first
+      // bit NOT marked should be avoided from (wasteful) iterating.
+      // Note that the alternative case of the bitmap of a humongous region
+      // with its first bit marked is handled properly in the iterate() routine.
+      // Then, let's iterate over the bitmap of the part of the region that is
+      // left.
+      // If the iteration is successful, give up the region.
+      // Also note that the case of the bitmap of a humongous region with its
+      // first bit NOT marked is considered "successful", leveraging the fact
+      // that the entire bitmap consists of all 0's in such case.
+      if (mr.is_empty() ||
+          (hr != NULL && hr->isHumongous() && !_nextMarkBitMap->isMarked(mr.start())) ||
+          _nextMarkBitMap->iterate(&bitmap_closure, mr)) {
         giveup_current_region();
         regular_clock_call();
       } else {
--- a/hotspot/src/share/vm/runtime/globals.hpp	Tue Feb 05 22:24:36 2013 -0800
+++ b/hotspot/src/share/vm/runtime/globals.hpp	Wed Feb 06 14:50:37 2013 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -1816,7 +1816,7 @@
                                                                             \
   product(uintx, InitiatingHeapOccupancyPercent, 45,                        \
           "Percentage of the (entire) heap occupancy to start a "           \
-          "concurrent GC cycle. It us used by GCs that trigger a "          \
+          "concurrent GC cycle. It is used by GCs that trigger a "          \
           "concurrent GC cycle based on the occupancy of the entire heap, " \
           "not just one of the generations (e.g., G1). A value of 0 "       \
           "denotes 'do constant GC cycles'.")                               \