diff src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp @ 6756:b2ef234911c9

7190666: G1: assert(_unused == 0) failed: Inconsistency in PLAB stats Summary: Reset the fields in ParGCAllocBuffer, that are used for accumulating values for the ResizePLAB sensors in PLABStats, to zero after flushing the values to the PLABStats fields. Flush PLABStats values only when retiring the final allocation buffers prior to disposing of a G1ParScanThreadState object, rather than when retiring every allocation buffer. Reviewed-by: jwilhelm, jmasa, ysr
author johnc
date Thu, 20 Sep 2012 09:52:56 -0700
parents aaf61e68b255
children 2e6857353b2c
line wrap: on
line diff
--- a/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp	Wed Sep 19 15:48:02 2012 -0700
+++ b/src/share/vm/gc_implementation/shared/parGCAllocBuffer.hpp	Thu Sep 20 09:52:56 2012 -0700
@@ -52,6 +52,10 @@
   static size_t FillerHeaderSize;
   static size_t AlignmentReserve;
 
+  // Flush the stats supporting ergonomic sizing of PLAB's
+  // Should not be called directly
+  void flush_stats(PLABStats* stats);
+
 public:
   // Initializes the buffer to be empty, but with the given "word_sz".
   // Must get initialized with "set_buf" for an allocation to succeed.
@@ -120,12 +124,22 @@
   }
 
   // Flush the stats supporting ergonomic sizing of PLAB's
-  void flush_stats(PLABStats* stats);
+  // and retire the current buffer.
   void flush_stats_and_retire(PLABStats* stats, bool end_of_gc, bool retain) {
     // We flush the stats first in order to get a reading of
     // unused space in the last buffer.
     if (ResizePLAB) {
       flush_stats(stats);
+
+      // Since we have flushed the stats we need to clear
+      // the _allocated and _wasted fields. Not doing so
+      // will artifically inflate the values in the stats
+      // to which we add them.
+      // The next time we flush these values, we will add
+      // what we have just flushed in addition to the size
+      // of the buffers allocated between now and then.
+      _allocated = 0;
+      _wasted = 0;
     }
     // Retire the last allocation buffer.
     retire(end_of_gc, retain);