changeset 50471:2143feab681a

8202140: TLAB logging is not correct for G1 Reviewed-by: tschatzl, sangheki
author sjohanss
date Wed, 02 May 2018 13:44:49 +0200
parents 9425445633cf
children cece972575ac
files src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp
diffstat 2 files changed, 10 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp	Wed May 02 13:44:46 2018 +0200
+++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.cpp	Wed May 02 13:44:49 2018 +0200
@@ -89,7 +89,7 @@
     }
     global_stats()->update_allocating_threads();
     global_stats()->update_number_of_refills(_number_of_refills);
-    global_stats()->update_allocation(_number_of_refills * desired_size());
+    global_stats()->update_allocation(_allocated_size);
     global_stats()->update_gc_waste(_gc_waste);
     global_stats()->update_slow_refill_waste(_slow_refill_waste);
     global_stats()->update_fast_refill_waste(_fast_refill_waste);
@@ -157,17 +157,19 @@
 }
 
 void ThreadLocalAllocBuffer::initialize_statistics() {
-    _number_of_refills = 0;
-    _fast_refill_waste = 0;
-    _slow_refill_waste = 0;
-    _gc_waste          = 0;
-    _slow_allocations  = 0;
+  _number_of_refills = 0;
+  _fast_refill_waste = 0;
+  _slow_refill_waste = 0;
+  _gc_waste          = 0;
+  _slow_allocations  = 0;
+  _allocated_size    = 0;
 }
 
 void ThreadLocalAllocBuffer::fill(HeapWord* start,
                                   HeapWord* top,
                                   size_t    new_size) {
   _number_of_refills++;
+  _allocated_size += new_size;
   print_stats("fill");
   assert(top <= start + new_size - alignment_reserve(), "size too small");
   initialize(start, top, start + new_size - alignment_reserve());
@@ -274,8 +276,7 @@
 
   Thread* thrd = myThread();
   size_t waste = _gc_waste + _slow_refill_waste + _fast_refill_waste;
-  size_t alloc = _number_of_refills * _desired_size;
-  double waste_percent = percent_of(waste, alloc);
+  double waste_percent = percent_of(waste, _allocated_size);
   size_t tlab_used  = Universe::heap()->tlab_used(thrd);
   log.trace("TLAB: %s thread: " INTPTR_FORMAT " [id: %2d]"
             " desired_size: " SIZE_FORMAT "KB"
--- a/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp	Wed May 02 13:44:46 2018 +0200
+++ b/src/hotspot/share/gc/shared/threadLocalAllocBuffer.hpp	Wed May 02 13:44:49 2018 +0200
@@ -58,6 +58,7 @@
   unsigned  _slow_refill_waste;
   unsigned  _gc_waste;
   unsigned  _slow_allocations;
+  size_t    _allocated_size;
 
   AdaptiveWeightedAverage _allocation_fraction;  // fraction of eden allocated in tlabs