changeset 9662:57093b085a8f

8073146: G1 merges thread local age tables too early with global age table Summary: Move merging of age and survivor table to the end of GC. Reviewed-by: mgerdin, david
author tschatzl
date Thu, 20 Aug 2015 15:17:43 +0200
parents ad916ca3715b
children 91bd6ad35898
files src/share/vm/gc/g1/g1CollectedHeap.cpp src/share/vm/gc/g1/g1ParScanThreadState.cpp src/share/vm/gc/g1/g1ParScanThreadState.hpp
diffstat 3 files changed, 9 insertions(+), 14 deletions(-) [+]
line wrap: on
line diff
--- a/src/share/vm/gc/g1/g1CollectedHeap.cpp	Thu Aug 20 15:17:43 2015 +0200
+++ b/src/share/vm/gc/g1/g1CollectedHeap.cpp	Thu Aug 20 15:17:43 2015 +0200
@@ -3760,8 +3760,7 @@
   cl.flush_rem_set_entries();
 }
 
-void
-G1CollectedHeap::setup_surviving_young_words() {
+void G1CollectedHeap::setup_surviving_young_words() {
   assert(_surviving_young_words == NULL, "pre-condition");
   uint array_length = g1_policy()->young_cset_region_length();
   _surviving_young_words = NEW_C_HEAP_ARRAY(size_t, (size_t) array_length, mtGC);
@@ -3777,17 +3776,15 @@
 #endif // !ASSERT
 }
 
-void
-G1CollectedHeap::update_surviving_young_words(size_t* surv_young_words) {
-  MutexLockerEx x(ParGCRareEvent_lock, Mutex::_no_safepoint_check_flag);
+void G1CollectedHeap::update_surviving_young_words(size_t* surv_young_words) {
+  assert_at_safepoint(true);
   uint array_length = g1_policy()->young_cset_region_length();
   for (uint i = 0; i < array_length; ++i) {
     _surviving_young_words[i] += surv_young_words[i];
   }
 }
 
-void
-G1CollectedHeap::cleanup_surviving_young_words() {
+void G1CollectedHeap::cleanup_surviving_young_words() {
   guarantee( _surviving_young_words != NULL, "pre-condition" );
   FREE_C_HEAP_ARRAY(size_t, _surviving_young_words);
   _surviving_young_words = NULL;
@@ -4605,10 +4602,6 @@
         _g1h->g1_policy()->phase_times()->record_thread_work_item(G1GCPhaseTimes::Termination, worker_id, evac_term_attempts);
       }
 
-      // Flush any statistics.
-      _g1h->g1_policy()->record_thread_age_table(pss->age_table());
-      _g1h->update_surviving_young_words(pss->surviving_young_words());
-
       assert(pss->queue_is_empty(), "should be empty");
 
       if (PrintTerminationStats) {
--- a/src/share/vm/gc/g1/g1ParScanThreadState.cpp	Thu Aug 20 15:17:43 2015 +0200
+++ b/src/share/vm/gc/g1/g1ParScanThreadState.cpp	Thu Aug 20 15:17:43 2015 +0200
@@ -72,8 +72,12 @@
 }
 
 G1ParScanThreadState::~G1ParScanThreadState() {
+  // Update allocation statistics.
   _plab_allocator->flush_and_retire_stats();
   delete _plab_allocator;
+  _g1h->g1_policy()->record_thread_age_table(&_age_table);
+  // Update heap statistics.
+  _g1h->update_surviving_young_words(_surviving_young_words);
   FREE_C_HEAP_ARRAY(size_t, _surviving_young_words_base);
 }
 
@@ -252,7 +256,7 @@
       } else {
         obj->set_mark(old_mark->set_age(age));
       }
-      age_table()->add(age, word_sz);
+      _age_table.add(age, word_sz);
     } else {
       obj->set_mark(old_mark);
     }
--- a/src/share/vm/gc/g1/g1ParScanThreadState.hpp	Thu Aug 20 15:17:43 2015 +0200
+++ b/src/share/vm/gc/g1/g1ParScanThreadState.hpp	Thu Aug 20 15:17:43 2015 +0200
@@ -87,8 +87,6 @@
 
   void set_ref_processor(ReferenceProcessor* rp) { _scanner.set_ref_processor(rp); }
 
-  ageTable*         age_table()       { return &_age_table;       }
-
 #ifdef ASSERT
   bool queue_is_empty() const { return _refs->is_empty(); }